diff options
author | tk0miya <i.tkomiya@gmail.com> | 2014-10-08 21:52:33 +0900 |
---|---|---|
committer | tk0miya <i.tkomiya@gmail.com> | 2014-10-08 21:52:33 +0900 |
commit | 461deca6a38133a7508679b060755197f6993b13 (patch) | |
tree | 3d1b8122b2d48f3e564ae313412be8565fda468f | |
parent | fbcaa3ed26ef775f0568f71ee8765c13467ca667 (diff) | |
download | sphinx-461deca6a38133a7508679b060755197f6993b13.tar.gz |
Add frame to code-block in LaTeX
-rw-r--r-- | sphinx/highlighting.py | 4 | ||||
-rw-r--r-- | tests/test_markup.py | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/sphinx/highlighting.py b/sphinx/highlighting.py index c2d2e89a..e257c370 100644 --- a/sphinx/highlighting.py +++ b/sphinx/highlighting.py @@ -96,7 +96,7 @@ class PygmentsBridge(object): source = source.translate(escape_hl_chars) # then, escape all characters nonrepresentable in LaTeX source = source.translate(tex_hl_escape_map_new) - return '\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n' + \ + return '\\begin{Verbatim}[frame=single,commandchars=\\\\\\{\\}]\n' + \ source + '\\end{Verbatim}\n' def try_parse(self, src): @@ -190,6 +190,8 @@ class PygmentsBridge(object): if self.dest == 'html': return hlsource else: + hlsource = re.sub(r'(?<=\\begin{Verbatim}\[)(?=commandchars)', + r'frame=single,', hlsource) if not isinstance(hlsource, text_type): # Py2 / Pygments < 1.6 hlsource = hlsource.decode() return hlsource.translate(tex_hl_escape_map_new) diff --git a/tests/test_markup.py b/tests/test_markup.py index 88b8a2c7..8bac6324 100644 --- a/tests/test_markup.py +++ b/tests/test_markup.py @@ -136,7 +136,7 @@ def test_latex_escaping(): r'\(\Gamma\)\textbackslash{}\(\infty\)\$') # in verbatim code fragments yield (verify, u'::\n\n @Γ\\∞${}', None, - u'\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n' + u'\\begin{Verbatim}[frame=single,commandchars=\\\\\\{\\}]\n' u'@\\(\\Gamma\\)\\PYGZbs{}\\(\\infty\\)\\PYGZdl{}\\PYGZob{}\\PYGZcb{}\n' u'\\end{Verbatim}') # in URIs |