|
From: <mi...@us...> - 2015-03-19 09:22:18
|
Revision: 7848
http://sourceforge.net/p/docutils/code/7848
Author: milde
Date: 2015-03-19 09:22:15 +0000 (Thu, 19 Mar 2015)
Log Message:
-----------
Cleaner LaTeX code for literal blocks (use "alltt" environment).
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/test/functional/expected/standalone_rst_latex.tex
trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
trunk/docutils/test/test_writers/test_latex2e.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2015-03-17 17:30:47 UTC (rev 7847)
+++ trunk/docutils/HISTORY.txt 2015-03-19 09:22:15 UTC (rev 7848)
@@ -54,29 +54,28 @@
``default_stylesheet_path`` and ``default_template_path``.
- Fix [ 266 ] creating labels/class values in description list items.
-* docutils/writers/xhtml11/
+* docutils/writers/latex2e/__init__.py
- - New HTML writer generating `XHTML 1.1`_ styled with CSS2.1
- Moved to the docutils core from sandbox/html4strict.
+ - Fix [ 262 ] Use ``\linewidth`` instead of ``\textwidth`` for figures,
+ admonitions and docinfo.
-* docutils/writers/latex2e/__init__.py
-
- Use absolute path for ``default_template_path``.
- Removed deprecated options ``--use-latex-footnotes`` and
``--figure-footnotes``.
- - Cleaner LaTeX code for enumerations.
+ - Cleaner LaTeX code for enumerations and literal blocks.
* docutils/writers/odf_odt/__init__.py
- remove decode.encode of filename stored in zip.
-* docutils/writers/latex2e/__init__.py
+* docutils/writers/xhtml11/
- - Fix [ 262 ] Use ``\linewidth`` instead of ``\textwidth`` for figures,
- admonitions and docinfo.
+ - New HTML writer generating `XHTML 1.1`_ styled with CSS2.1
+ Moved to the docutils core from sandbox/html4strict.
+
* tools/
- New front-ends ``rst2xhtml.py`` and ``rst2html5.py`` for the
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2015-03-17 17:30:47 UTC (rev 7847)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2015-03-19 09:22:15 UTC (rev 7848)
@@ -692,7 +692,13 @@
class CharMaps(object):
"""LaTeX representations for active and Unicode characters."""
- # characters that always need escaping:
+ # characters that need escaping even in `alltt` environments:
+ alltt = {
+ ord('\\'): ur'\textbackslash{}',
+ ord('{'): ur'\{',
+ ord('}'): ur'\}',
+ }
+ # characters that normally need escaping:
special = {
ord('#'): ur'\#',
ord('$'): ur'\$',
@@ -701,9 +707,6 @@
ord('~'): ur'\textasciitilde{}',
ord('_'): ur'\_',
ord('^'): ur'\textasciicircum{}',
- ord('\\'): ur'\textbackslash{}',
- ord('{'): ur'\{',
- ord('}'): ur'\}',
# straight double quotes are 'active' in many languages
ord('"'): ur'\textquotedbl{}',
# Square brackets are ordinary chars and cannot be escaped with '\',
@@ -1123,8 +1126,8 @@
insert_non_breaking_blanks = False # replace blanks by "~"
insert_newline = False # add latex newline commands
literal = False # literal text (block or inline)
+ alltt = False # inside `alltt` environment
-
def __init__(self, document, babel_class=Babel):
nodes.NodeVisitor.__init__(self, document)
# Reporter
@@ -1418,16 +1421,17 @@
def encode(self, text):
"""Return text with 'problematic' characters escaped.
- * Escape the ten special printing characters ``# $ % & ~ _ ^ \ { }``,
+ * Escape the special printing characters ``# $ % & ~ _ ^ \ { }``,
square brackets ``[ ]``, double quotes and (in OT1) ``< | >``.
* Translate non-supported Unicode characters.
* Separate ``-`` (and more in literal text) to prevent input ligatures.
"""
if self.verbatim:
return text
-
# Set up the translation table:
- table = CharMaps.special.copy()
+ table = CharMaps.alltt.copy()
+ if not self.alltt:
+ table.update(CharMaps.special)
# keep the underscore in citation references
if self.inside_citation_reference_label:
del(table[ord('_')])
@@ -1825,7 +1829,7 @@
raise nodes.SkipNode
self.out.append('\\textbf{%s}: &\n\t' % self.language_label(name))
if name == 'address':
- self.insert_newline = 1
+ self.insert_newline = True
self.out.append('{\\raggedright\n')
self.context.append(' } \\\\\n')
else:
@@ -2027,7 +2031,7 @@
) + self.section_enumerator_separator
if self._enumeration_counters:
prefix += self._enumeration_counters[-1]
- # TODO: use LaTeX default for unspecified label-type?
+ # TODO: use LaTeX default for unspecified label-type?
# (needs change of parser)
prefix += node.get('prefix', '')
enumtype = types[node.get('enumtype' '')]
@@ -2403,7 +2407,8 @@
def visit_literal_block(self, node):
"""Render a literal block."""
# environments and packages to typeset literal blocks
- packages = {'listing': r'\usepackage{moreverb}',
+ packages = {'alltt': r'\usepackage{alltt}',
+ 'listing': r'\usepackage{moreverb}',
'lstlisting': r'\usepackage{listings}',
'Verbatim': r'\usepackage{fancyvrb}',
# 'verbatim': '',
@@ -2413,37 +2418,33 @@
# no quote inside tables, to avoid vertical space between
# table border and literal block.
# BUG: fails if normal text precedes the literal block.
- self.out.append('%\n\\begin{quote}')
+ self.out.append('%\n\\begin{quote}\n')
self.context.append('\n\\end{quote}\n')
else:
self.out.append('\n')
self.context.append('\n')
if self.literal_block_env != '' and self.is_plaintext(node):
- self.requirements['literal_block'] = packages.get(
- self.literal_block_env, '')
+ environment = self.literal_block_env
self.verbatim = True
- self.out.append('\\begin{%s}%s\n' % (self.literal_block_env,
- self.literal_block_options))
else:
- self.literal = True
- self.insert_newline = True
- self.insert_non_breaking_blanks = True
- if 'code' in node['classes'] and (
- self.settings.syntax_highlight != 'none'):
+ environment = 'alltt'
+ self.alltt = True
+ if ('code' in node['classes']
+ and self.settings.syntax_highlight != 'none'):
self.requirements['color'] = PreambleCmds.color
self.fallbacks['code'] = PreambleCmds.highlight_rules
- self.out.append('{\\ttfamily \\raggedright \\noindent\n')
+ self.requirements['literal_block'] = packages.get(environment, '')
+ self.out.append('\\begin{%s}%s\n' %
+ (environment, self.literal_block_options))
+ self.context.append('\n\\end{%s}' % environment)
+
+
def depart_literal_block(self, node):
- if self.verbatim:
- self.out.append('\n\\end{%s}\n' % self.literal_block_env)
- self.verbatim = False
- else:
- self.out.append('\n}')
- self.insert_non_breaking_blanks = False
- self.insert_newline = False
- self.literal = False
+ self.verbatim = False
+ self.alltt = False
self.out.append(self.context.pop())
+ self.out.append(self.context.pop())
## def visit_meta(self, node):
## self.out.append('[visit_meta]\n')
@@ -2470,7 +2471,10 @@
if node.get('ids'):
math_code = '\n'.join([math_code] + self.ids_to_labels(node))
if math_env == '$':
- wrapper = u'$%s$'
+ if self.alltt:
+ wrapper = u'\(%s\)'
+ else:
+ wrapper = u'$%s$'
else:
wrapper = u'\n'.join(['%%',
r'\begin{%s}' % math_env,
Modified: trunk/docutils/test/functional/expected/standalone_rst_latex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2015-03-17 17:30:47 UTC (rev 7847)
+++ trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2015-03-19 09:22:15 UTC (rev 7848)
@@ -14,6 +14,7 @@
\usepackage{float} % float configuration
\floatplacement{figure}{H} % place figures here definitely
\usepackage{graphicx}
+\usepackage{alltt}
\usepackage{multirow}
\usepackage{pifont}
\setcounter{secnumdepth}{0}
@@ -567,21 +568,23 @@
Literal blocks are indicated with a double-colon (“::”) at the end of
the preceding paragraph (over there \texttt{-{}->}). They can be indented:
%
-\begin{quote}{\ttfamily \raggedright \noindent
-if~literal\_block:\\
-~~~~text~=~'is~left~as-is'\\
-~~~~spaces\_and\_linebreaks~=~'are~preserved'\\
-~~~~markup\_processing~=~None
-}
+\begin{quote}
+\begin{alltt}
+if literal_block:
+ text = 'is left as-is'
+ spaces_and_linebreaks = 'are preserved'
+ markup_processing = None
+\end{alltt}
\end{quote}
Or they can be quoted without indentation:
%
-\begin{quote}{\ttfamily \raggedright \noindent
->{}>~Great~idea!\\
->\\
->~Why~didn't~I~think~of~that?
-}
+\begin{quote}
+\begin{alltt}
+>> Great idea!
+>
+> Why didn't I think of that?
+\end{alltt}
\end{quote}
@@ -717,12 +720,13 @@
\label{doctest-blocks}%
}
%
-\begin{quote}{\ttfamily \raggedright \noindent
->{}>{}>~print~'Python-specific~usage~examples;~begun~with~\textquotedbl{}>{}>{}>\textquotedbl{}'\\
-Python-specific~usage~examples;~begun~with~\textquotedbl{}>{}>{}>\textquotedbl{}\\
->{}>{}>~print~'(cut~and~pasted~from~interactive~Python~sessions)'\\
-(cut~and~pasted~from~interactive~Python~sessions)
-}
+\begin{quote}
+\begin{alltt}
+>>> print 'Python-specific usage examples; begun with ">>>"'
+Python-specific usage examples; begun with ">>>"
+>>> print '(cut and pasted from interactive Python sessions)'
+(cut and pasted from interactive Python sessions)
+\end{alltt}
\end{quote}
@@ -1150,18 +1154,20 @@
Compound 2, a literal block:
%
-\begin{quote}{\ttfamily \raggedright \noindent
-Compound~2,~literal.
-}
+\begin{quote}
+\begin{alltt}
+Compound 2, literal.
+\end{alltt}
\end{quote}
Compound 2, this is a test.
Compound 3, only consisting of one paragraph.
%
-\begin{quote}{\ttfamily \raggedright \noindent
-Compound~4.\\
-This~one~starts~with~a~literal~block.
-}
+\begin{quote}
+\begin{alltt}
+Compound 4.
+This one starts with a literal block.
+\end{alltt}
\end{quote}
Compound 4, a paragraph.
@@ -1211,14 +1217,15 @@
\label{parsed-literal-blocks}%
}
%
-\begin{quote}{\ttfamily \raggedright \noindent
-This~is~a~parsed~literal~block.\\
-~~~~This~line~is~indented.~~The~next~line~is~blank.\\
-~\\
-Inline~markup~is~supported,~e.g.~\emph{emphasis},~\textbf{strong},~\texttt{literal\\
-text},~footnotes\DUfootnotemark{id22}{id8}{1},~%
-\phantomsection\label{hyperlink-targets}hyperlink~targets,~and~\href{http://www.python.org/}{references}.
-}
+\begin{quote}
+\begin{alltt}
+This is a parsed literal block.
+ This line is indented. The next line is blank.
+
+Inline markup is supported, e.g. \emph{emphasis}, \textbf{strong}, \texttt{literal
+text}, footnotes\DUfootnotemark{id22}{id8}{1}, %
+\phantomsection\label{hyperlink-targets}hyperlink targets, and \href{http://www.python.org/}{references}.
+\end{alltt}
\end{quote}
@@ -1233,19 +1240,21 @@
conversions in order to get identical results with/without installed
Pygments highlighter.)
%
-\begin{quote}{\ttfamily \raggedright \noindent
-print~'This~is~Python~code.'
-}
+\begin{quote}
+\begin{alltt}
+print 'This is Python code.'
+\end{alltt}
\end{quote}
The \texttt{:number-lines:} option (with optional start value) generates line
numbers:
%
-\begin{quote}{\ttfamily \raggedright \noindent
-\DUrole{ln}{~8~}\#~print~integers~from~0~to~9:\\
-\DUrole{ln}{~9~}for~i~in~range(10):\\
-\DUrole{ln}{10~}~~~~print~i
-}
+\begin{quote}
+\begin{alltt}
+\DUrole{ln}{ 8 }# print integers from 0 to 9:
+\DUrole{ln}{ 9 }for i in range(10):
+\DUrole{ln}{10 } print i
+\end{alltt}
\end{quote}
For inline code snippets, there is the \DUroletitlereference{code} role, which can be used
@@ -1259,10 +1268,11 @@
The \texttt{:code:} option of the \DUroletitlereference{include} directive sets the included content
as a code block, here the rst file \texttt{header\_footer.txt} with line numbers:
%
-\begin{quote}{\ttfamily \raggedright \noindent
-\DUrole{ln}{1~}..~header::~Document~header\\
-\DUrole{ln}{2~}..~footer::~Document~footer
-}
+\begin{quote}
+\begin{alltt}
+\DUrole{ln}{1 }.. header:: Document header
+\DUrole{ln}{2 }.. footer:: Document footer
+\end{alltt}
\end{quote}
@@ -1490,14 +1500,15 @@
The following works in most browsers but does not validate
(\texttt{<style>} is only allowed in the document head):
%
-\begin{quote}{\ttfamily \raggedright \noindent
-..~raw::~html\\
-~\\
-~~<style~type=\textquotedbl{}text/css\textquotedbl{}><!-{}-\\
-~~~.green~\{color:~green;\}\\
-~~~.sc~\{font-variant:~small-caps;\}\\
-~~~-{}-></style>
-}
+\begin{quote}
+\begin{alltt}
+.. raw:: html
+
+ <style type="text/css"><!-{}-
+ .green \{color: green;\}
+ .sc \{font-variant: small-caps;\}
+ -{}-></style>
+\end{alltt}
\end{quote}
\DUrole{green}{\DUrole{sc}{\foreignlanguage{british}{British colourful text in small-caps}}}.
@@ -2232,11 +2243,12 @@
(some have an Euro sign at its place). You might see an error
like:
%
-\begin{quote}{\ttfamily \raggedright \noindent
-!~Package~textcomp~Error:~Symbol~\textbackslash{}textcurrency~not~provided~by\\
-(textcomp)~~~~~~~~~~~~~~~~font~family~ptm~in~TS1~encoding.\\
-(textcomp)~~~~~~~~~~~~~~~~Default~family~used~instead.
-}
+\begin{quote}
+\begin{alltt}
+! Package textcomp Error: Symbol \textbackslash{}textcurrency not provided by
+(textcomp) font family ptm in TS1 encoding.
+(textcomp) Default family used instead.
+\end{alltt}
\end{quote}
(which in case of font family ptm is a false positive). Add either
@@ -2277,9 +2289,10 @@
The special chars verbatim:
%
-\begin{quote}{\ttfamily \raggedright \noindent
-\#~\$~\%~\&~\textasciitilde{}~\_~\textasciicircum{}~\textbackslash{}~\{~\}
-}
+\begin{quote}
+\begin{alltt}
+# $ % & ~ _ ^ \textbackslash{} \{ \}
+\end{alltt}
\end{quote}
However also \emph{square brackets} {[}{]} need special care.
@@ -2319,9 +2332,10 @@
The OT1 font-encoding has different characters for the less-than,
greater-than and bar, < | >, except for typewriter font \DUroletitlereference{cmtt}:
%
-\begin{quote}{\ttfamily \raggedright \noindent
-<~|~>
-}
+\begin{quote}
+\begin{alltt}
+< | >
+\end{alltt}
\end{quote}
@@ -2439,10 +2453,11 @@
\item Unbalanced braces, \{ or \}, will fail (both with href and url):
%
-\begin{quote}{\ttfamily \raggedright \noindent
-`file~with~\{~<../strange\{name>`\_\_\\
-`<../strange\{name>`\_\_
-}
+\begin{quote}
+\begin{alltt}
+`file with \{ <../strange\{name>`__
+`<../strange\{name>`__
+\end{alltt}
\end{quote}
while balanced braces are suported:
Modified: trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2015-03-17 17:30:47 UTC (rev 7847)
+++ trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2015-03-19 09:22:15 UTC (rev 7848)
@@ -12,6 +12,7 @@
\usepackage{float} % float configuration
\floatplacement{figure}{H} % place figures here definitely
\usepackage{graphicx}
+\usepackage{alltt}
\usepackage{multirow}
\setcounter{secnumdepth}{0}
\usepackage{longtable,ltcaption,array}
@@ -566,21 +567,23 @@
Literal blocks are indicated with a double-colon (“::”) at the end of
the preceding paragraph (over there \texttt{-->}). They can be indented:
%
-\begin{quote}{\ttfamily \raggedright \noindent
-if~literal\_block:\\
-~~~~text~=~'is~left~as-is'\\
-~~~~spaces\_and\_linebreaks~=~'are~preserved'\\
-~~~~markup\_processing~=~None
-}
+\begin{quote}
+\begin{alltt}
+if literal_block:
+ text = 'is left as-is'
+ spaces_and_linebreaks = 'are preserved'
+ markup_processing = None
+\end{alltt}
\end{quote}
Or they can be quoted without indentation:
%
-\begin{quote}{\ttfamily \raggedright \noindent
->>~Great~idea!\\
->\\
->~Why~didn't~I~think~of~that?
-}
+\begin{quote}
+\begin{alltt}
+>> Great idea!
+>
+> Why didn't I think of that?
+\end{alltt}
\end{quote}
@@ -716,12 +719,13 @@
\label{doctest-blocks}%
}
%
-\begin{quote}{\ttfamily \raggedright \noindent
->>>~print~'Python-specific~usage~examples;~begun~with~\textquotedbl{}>>>\textquotedbl{}'\\
-Python-specific~usage~examples;~begun~with~\textquotedbl{}>>>\textquotedbl{}\\
->>>~print~'(cut~and~pasted~from~interactive~Python~sessions)'\\
-(cut~and~pasted~from~interactive~Python~sessions)
-}
+\begin{quote}
+\begin{alltt}
+>>> print 'Python-specific usage examples; begun with ">>>"'
+Python-specific usage examples; begun with ">>>"
+>>> print '(cut and pasted from interactive Python sessions)'
+(cut and pasted from interactive Python sessions)
+\end{alltt}
\end{quote}
@@ -1149,18 +1153,20 @@
Compound 2, a literal block:
%
-\begin{quote}{\ttfamily \raggedright \noindent
-Compound~2,~literal.
-}
+\begin{quote}
+\begin{alltt}
+Compound 2, literal.
+\end{alltt}
\end{quote}
Compound 2, this is a test.
Compound 3, only consisting of one paragraph.
%
-\begin{quote}{\ttfamily \raggedright \noindent
-Compound~4.\\
-This~one~starts~with~a~literal~block.
-}
+\begin{quote}
+\begin{alltt}
+Compound 4.
+This one starts with a literal block.
+\end{alltt}
\end{quote}
Compound 4, a paragraph.
@@ -1210,14 +1216,15 @@
\label{parsed-literal-blocks}%
}
%
-\begin{quote}{\ttfamily \raggedright \noindent
-This~is~a~parsed~literal~block.\\
-~~~~This~line~is~indented.~~The~next~line~is~blank.\\
-~\\
-Inline~markup~is~supported,~e.g.~\emph{emphasis},~\textbf{strong},~\texttt{literal\\
-text},~footnotes\DUfootnotemark{id22}{id8}{1},~%
-\phantomsection\label{hyperlink-targets}hyperlink~targets,~and~\href{http://www.python.org/}{references}.
-}
+\begin{quote}
+\begin{alltt}
+This is a parsed literal block.
+ This line is indented. The next line is blank.
+
+Inline markup is supported, e.g. \emph{emphasis}, \textbf{strong}, \texttt{literal
+text}, footnotes\DUfootnotemark{id22}{id8}{1}, %
+\phantomsection\label{hyperlink-targets}hyperlink targets, and \href{http://www.python.org/}{references}.
+\end{alltt}
\end{quote}
@@ -1232,19 +1239,21 @@
conversions in order to get identical results with/without installed
Pygments highlighter.)
%
-\begin{quote}{\ttfamily \raggedright \noindent
-print~'This~is~Python~code.'
-}
+\begin{quote}
+\begin{alltt}
+print 'This is Python code.'
+\end{alltt}
\end{quote}
The \texttt{:number-lines:} option (with optional start value) generates line
numbers:
%
-\begin{quote}{\ttfamily \raggedright \noindent
-\DUrole{ln}{~8~}\#~print~integers~from~0~to~9:\\
-\DUrole{ln}{~9~}for~i~in~range(10):\\
-\DUrole{ln}{10~}~~~~print~i
-}
+\begin{quote}
+\begin{alltt}
+\DUrole{ln}{ 8 }# print integers from 0 to 9:
+\DUrole{ln}{ 9 }for i in range(10):
+\DUrole{ln}{10 } print i
+\end{alltt}
\end{quote}
For inline code snippets, there is the \DUroletitlereference{code} role, which can be used
@@ -1258,10 +1267,11 @@
The \texttt{:code:} option of the \DUroletitlereference{include} directive sets the included content
as a code block, here the rst file \texttt{header\_footer.txt} with line numbers:
%
-\begin{quote}{\ttfamily \raggedright \noindent
-\DUrole{ln}{1~}..~header::~Document~header\\
-\DUrole{ln}{2~}..~footer::~Document~footer
-}
+\begin{quote}
+\begin{alltt}
+\DUrole{ln}{1 }.. header:: Document header
+\DUrole{ln}{2 }.. footer:: Document footer
+\end{alltt}
\end{quote}
@@ -1489,14 +1499,15 @@
The following works in most browsers but does not validate
(\texttt{<style>} is only allowed in the document head):
%
-\begin{quote}{\ttfamily \raggedright \noindent
-..~raw::~html\\
-~\\
-~~<style~type=\textquotedbl{}text/css\textquotedbl{}><!--\\
-~~~.green~\{color:~green;\}\\
-~~~.sc~\{font-variant:~small-caps;\}\\
-~~~--></style>
-}
+\begin{quote}
+\begin{alltt}
+.. raw:: html
+
+ <style type="text/css"><!--
+ .green \{color: green;\}
+ .sc \{font-variant: small-caps;\}
+ --></style>
+\end{alltt}
\end{quote}
\DUrole{green}{\DUrole{sc}{\foreignlanguage{british}{British colourful text in small-caps}}}.
@@ -2000,11 +2011,12 @@
(some have an Euro sign at its place). You might see an error
like:
%
-\begin{quote}{\ttfamily \raggedright \noindent
-!~Package~textcomp~Error:~Symbol~\textbackslash{}textcurrency~not~provided~by\\
-(textcomp)~~~~~~~~~~~~~~~~font~family~ptm~in~TS1~encoding.\\
-(textcomp)~~~~~~~~~~~~~~~~Default~family~used~instead.
-}
+\begin{quote}
+\begin{alltt}
+! Package textcomp Error: Symbol \textbackslash{}textcurrency not provided by
+(textcomp) font family ptm in TS1 encoding.
+(textcomp) Default family used instead.
+\end{alltt}
\end{quote}
(which in case of font family ptm is a false positive). Add either
@@ -2045,9 +2057,10 @@
The special chars verbatim:
%
-\begin{quote}{\ttfamily \raggedright \noindent
-\#~\$~\%~\&~\textasciitilde{}~\_~\textasciicircum{}~\textbackslash{}~\{~\}
-}
+\begin{quote}
+\begin{alltt}
+# $ % & ~ _ ^ \textbackslash{} \{ \}
+\end{alltt}
\end{quote}
However also \emph{square brackets} {[}{]} need special care.
@@ -2087,9 +2100,10 @@
The OT1 font-encoding has different characters for the less-than,
greater-than and bar, < | >, except for typewriter font \DUroletitlereference{cmtt}:
%
-\begin{quote}{\ttfamily \raggedright \noindent
-<~|~>
-}
+\begin{quote}
+\begin{alltt}
+< | >
+\end{alltt}
\end{quote}
@@ -2207,10 +2221,11 @@
\item Unbalanced braces, \{ or \}, will fail (both with href and url):
%
-\begin{quote}{\ttfamily \raggedright \noindent
-`file~with~\{~<../strange\{name>`\_\_\\
-`<../strange\{name>`\_\_
-}
+\begin{quote}
+\begin{alltt}
+`file with \{ <../strange\{name>`__
+`<../strange\{name>`__
+\end{alltt}
\end{quote}
while balanced braces are suported:
Modified: trunk/docutils/test/test_writers/test_latex2e.py
===================================================================
--- trunk/docutils/test/test_writers/test_latex2e.py 2015-03-17 17:30:47 UTC (rev 7847)
+++ trunk/docutils/test/test_writers/test_latex2e.py 2015-03-19 09:22:15 UTC (rev 7848)
@@ -104,6 +104,12 @@
r"""\usepackage{textcomp} % text symbol macros
"""))
+head_alltt = head_template.substitute(
+ dict(parts, requirements = parts['requirements'] +
+r"""\usepackage{alltt}
+"""))
+
+
totest = {}
totest_latex_toc = {}
totest_latex_sectnum = {}
@@ -500,23 +506,38 @@
totest['bracket_protection'] = [
# input
+["""
+* [no option] to this item
+""",
+head + r"""%
+\begin{itemize}
+
+\item {[}no option{]} to this item
+
+\end{itemize}
+
+\end{document}
+"""],
+]
+
+totest['literal_block'] = [
+# input
["""\
-::
+Test special characters { [ \\\\ ] } in literal block::
- something before to get a end of line.
- [
+ { [ ( \macro
- the empty line gets tested too
- ]
+ } ] )
""",
-head + r"""%
-\begin{quote}{\ttfamily \raggedright \noindent
-something~before~to~get~a~end~of~line.\\
-{[}\\
-~\\
-the~empty~line~gets~tested~too\\
-{]}
-}
+head_alltt + r"""
+Test special characters \{ {[} \textbackslash{} {]} \} in literal block:
+%
+\begin{quote}
+\begin{alltt}
+\{ [ ( \textbackslash{}macro
+
+\} ] )
+\end{alltt}
\end{quote}
\end{document}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|