summaryrefslogtreecommitdiff
path: root/pygments/cmdline.py
diff options
context:
space:
mode:
authorTim Hatch <tim@timhatch.com>2014-04-14 13:47:40 -0400
committerTim Hatch <tim@timhatch.com>2014-04-14 13:47:40 -0400
commit06a720cca67ff19f873f8066c17cf4ea90ab0f0f (patch)
tree2901fe8e218cce5a8e788645d41aec654f297e23 /pygments/cmdline.py
parent02683b5def213065f6b893f91fc54f313141fbdf (diff)
parent5d57fe78405ac06a306f5ed2dd1b630a909cbdfb (diff)
downloadpygments-06a720cca67ff19f873f8066c17cf4ea90ab0f0f.tar.gz
Merged in yloiseau/pygments-main (pull request #309)
Diffstat (limited to 'pygments/cmdline.py')
-rw-r--r--pygments/cmdline.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/pygments/cmdline.py b/pygments/cmdline.py
index af8d48ea..7c23ebee 100644
--- a/pygments/cmdline.py
+++ b/pygments/cmdline.py
@@ -19,6 +19,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 LatexEmbeddedLexer, LatexFormatter
from pygments.formatters import get_all_formatters, get_formatter_by_name, \
get_formatter_for_filename, find_formatter_class, \
TerminalFormatter # pylint:disable-msg=E0611
@@ -405,6 +406,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 = LatexEmbeddedLexer(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...)