Beispiel #1
0
	def code(self, node):
		import html
		assert self.snippet == None, "code tag placed in the scene twice"
		text = deindent(node.decode_contents())
		try:
			escape = bool(node.attrs.get('escape', True))
		except:
			escape = True
		if escape:
			text = html.unescape(text)
		self.snippet = Snippet(text, lang=node.attrs.get('lang',''))
		self._push_snippet()
Beispiel #2
0
 def test_get_formatter(self):
     snippet = Snippet({}, mock.sentinel.tokens)
     self.assertIsInstance(snippet._get_formatter(), HtmlFormatter)
Beispiel #3
0
 def test_has_formatted_source(self, get_formatter):
     snippet = Snippet({}, mock.sentinel.tokens)
     snippet.get_formatted_source()
     self.assertEqual(get_formatter.return_value.format.call_count, 1)
     self.assertIs(get_formatter.return_value.format.call_args[0][0], mock.sentinel.tokens)