diff options
author | Jonathan Protzenko <jonathan.protzenko@gmail.com> | 2013-08-21 18:37:00 +0200 |
---|---|---|
committer | Jonathan Protzenko <jonathan.protzenko@gmail.com> | 2013-08-21 18:37:00 +0200 |
commit | b570f7c18d9dea76f6122bf8491aa2370e9264e6 (patch) | |
tree | 73b12b043bc80cab01815be1ae9128134056e176 /pygments/cmdline.py | |
parent | 1ea0fa53d253eae501f0a48611dd01493240b34d (diff) | |
download | pygments-b570f7c18d9dea76f6122bf8491aa2370e9264e6.tar.gz |
Update the patch from #493 to work with tip.
Diffstat (limited to 'pygments/cmdline.py')
-rw-r--r-- | pygments/cmdline.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/pygments/cmdline.py b/pygments/cmdline.py index c25204bf..0957b9c1 100644 --- a/pygments/cmdline.py +++ b/pygments/cmdline.py @@ -16,6 +16,7 @@ from pygments import __version__, highlight from pygments.util import ClassNotFound, OptionError, docstring_headline from pygments.lexers import get_all_lexers, get_lexer_by_name, get_lexer_for_filename, \ find_lexer_class, guess_lexer, TextLexer +from pygments.formatters.latex import LatexEmbededLexer, LatexFormatter from pygments.formatters import get_all_formatters, get_formatter_by_name, \ get_formatter_for_filename, find_formatter_class, \ TerminalFormatter # pylint:disable-msg=E0611 @@ -402,6 +403,15 @@ def main(args=sys.argv): else: code = sys.stdin.read() + # When using the LaTeX formatter and the option `escapeinside` is + # specified, we need a special lexer which collects escaped text + # before running the chosen language lexer. + escapeinside = parsed_opts.get('escapeinside', '') + if len(escapeinside) == 2 and isinstance(fmter, LatexFormatter): + left = escapeinside[0] + right = escapeinside[1] + lexer = LatexEmbededLexer(left, right, lexer) + # No encoding given? Use latin1 if output file given, # stdin/stdout encoding otherwise. # (This is a compromise, I'm not too happy with it...) |