mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merged in tk0miya/sphinx (pull request #307)
Add frame to code-block in LaTeX
This commit is contained in:
commit
1ff5ffe1ed
@ -96,7 +96,7 @@ class PygmentsBridge(object):
|
|||||||
source = source.translate(escape_hl_chars)
|
source = source.translate(escape_hl_chars)
|
||||||
# then, escape all characters nonrepresentable in LaTeX
|
# then, escape all characters nonrepresentable in LaTeX
|
||||||
source = source.translate(tex_hl_escape_map_new)
|
source = source.translate(tex_hl_escape_map_new)
|
||||||
return '\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n' + \
|
return '\\begin{Verbatim}[frame=single,commandchars=\\\\\\{\\}]\n' + \
|
||||||
source + '\\end{Verbatim}\n'
|
source + '\\end{Verbatim}\n'
|
||||||
|
|
||||||
def try_parse(self, src):
|
def try_parse(self, src):
|
||||||
@ -190,6 +190,8 @@ class PygmentsBridge(object):
|
|||||||
if self.dest == 'html':
|
if self.dest == 'html':
|
||||||
return hlsource
|
return hlsource
|
||||||
else:
|
else:
|
||||||
|
hlsource = re.sub(r'(?<=\\begin{Verbatim}\[)(?=commandchars)',
|
||||||
|
r'frame=single,', hlsource)
|
||||||
if not isinstance(hlsource, text_type): # Py2 / Pygments < 1.6
|
if not isinstance(hlsource, text_type): # Py2 / Pygments < 1.6
|
||||||
hlsource = hlsource.decode()
|
hlsource = hlsource.decode()
|
||||||
return hlsource.translate(tex_hl_escape_map_new)
|
return hlsource.translate(tex_hl_escape_map_new)
|
||||||
|
@ -136,7 +136,7 @@ def test_latex_escaping():
|
|||||||
r'\(\Gamma\)\textbackslash{}\(\infty\)\$')
|
r'\(\Gamma\)\textbackslash{}\(\infty\)\$')
|
||||||
# in verbatim code fragments
|
# in verbatim code fragments
|
||||||
yield (verify, u'::\n\n @Γ\\∞${}', None,
|
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'@\\(\\Gamma\\)\\PYGZbs{}\\(\\infty\\)\\PYGZdl{}\\PYGZob{}\\PYGZcb{}\n'
|
||||||
u'\\end{Verbatim}')
|
u'\\end{Verbatim}')
|
||||||
# in URIs
|
# in URIs
|
||||||
|
Loading…
Reference in New Issue
Block a user