diff options
author | Georg Brandl <georg@python.org> | 2016-01-04 11:18:25 +0100 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2016-01-04 11:18:25 +0100 |
commit | c010a7f2b09682f4cb2ecbb77b0286d9f4c1853e (patch) | |
tree | 7ec8c2dcf8caafa22187d51a383617888c6e7ef3 | |
parent | fc18d3d35ffb5ba43f68f2dffb1d84dd177c3618 (diff) | |
parent | 210fa81ad1123aff13511978e773ee463af49f58 (diff) | |
download | pygments-c010a7f2b09682f4cb2ecbb77b0286d9f4c1853e.tar.gz |
merge
-rw-r--r-- | pygments/formatters/html.py | 10 | ||||
-rw-r--r-- | pygments/lexers/int_fiction.py | 1 | ||||
-rw-r--r-- | tests/examplefiles/inform6_example | 7 | ||||
-rw-r--r-- | tests/test_html_formatter.py | 8 |
4 files changed, 23 insertions, 3 deletions
diff --git a/pygments/formatters/html.py b/pygments/formatters/html.py index 0985025f..a0087515 100644 --- a/pygments/formatters/html.py +++ b/pygments/formatters/html.py @@ -321,6 +321,12 @@ class HtmlFormatter(Formatter): .. versionadded:: 1.6 + `filename` + A string used to generate a filename when rendering <pre> blocks, + for example if displaying source code. + + .. versionadded:: 2.1 + **Subclassing the HTML formatter** @@ -388,6 +394,7 @@ class HtmlFormatter(Formatter): self.noclobber_cssfile = get_bool_opt(options, 'noclobber_cssfile', False) self.tagsfile = self._decodeifneeded(options.get('tagsfile', '')) self.tagurlformat = self._decodeifneeded(options.get('tagurlformat', '')) + self.filename = self._decodeifneeded(options.get('filename', '')) if self.tagsfile: if not ctags: @@ -692,6 +699,9 @@ class HtmlFormatter(Formatter): style.append('line-height: 125%') style = '; '.join(style) + if self.filename: + yield 0, ('<span class="filename">' + self.filename + '</span>') + yield 0, ('<pre' + (style and ' style="%s"' % style) + '>') for tup in inner: yield tup diff --git a/pygments/lexers/int_fiction.py b/pygments/lexers/int_fiction.py index 25c472b1..724f9b27 100644 --- a/pygments/lexers/int_fiction.py +++ b/pygments/lexers/int_fiction.py @@ -285,6 +285,7 @@ class Inform6Lexer(RegexLexer): include('_whitespace'), (r';', Punctuation, '#pop'), (r'\*', Punctuation), + (r'"', String.Double, 'plain-string'), (_name, Name.Variable) ], # Array diff --git a/tests/examplefiles/inform6_example b/tests/examplefiles/inform6_example index 73cdd087..6fa1fe5b 100644 --- a/tests/examplefiles/inform6_example +++ b/tests/examplefiles/inform6_example @@ -8,8 +8,8 @@ Switches d2SDq; Constant Story "Informal Testing"; Constant Headline "^Not a game.^";!% This is a comment, not ICL. -Release 2; -Serial "140308"; +Release 3; +Serial "151213"; Version 5; Ifndef TARGET_ZCODE; @@ -174,7 +174,8 @@ Extend 'wave' replace * -> NewWave; Extend only 'feel' 'touch' replace * noun -> Feel; -[ TestSub a b o; +[ TestSub "a\ + " b o "@@98"; ! Not an escape sequence. string 25 low_string; print "Test what?> "; table->0 = 260; diff --git a/tests/test_html_formatter.py b/tests/test_html_formatter.py index a82aaaf7..567de51f 100644 --- a/tests/test_html_formatter.py +++ b/tests/test_html_formatter.py @@ -192,3 +192,11 @@ class HtmlFormatterTest(unittest.TestCase): fmt.format(tokensource, outfile) self.assertTrue('<a href="test_html_formatter.py#L-165">test_ctags</a>' in outfile.getvalue()) + + def test_filename(self): + optdict = dict(filename="test.py") + outfile = StringIO() + fmt = HtmlFormatter(**optdict) + fmt.format(tokensource, outfile) + html = outfile.getvalue() + self.assertTrue(re.search("<span class=\"filename\">test.py</span><pre>", html)) |