|
From: <mi...@us...> - 2015-03-19 15:55:01
|
Revision: 7849
http://sourceforge.net/p/docutils/code/7849
Author: milde
Date: 2015-03-19 15:54:58 +0000 (Thu, 19 Mar 2015)
Log Message:
-----------
Fix the latest latex writer patch: no "alltt" in parsed literal blocks.
More inline markup examples for functional test of parsed literal blocks.
Modified Paths:
--------------
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/test/functional/expected/standalone_rst_html4css1.html
trunk/docutils/test/functional/expected/standalone_rst_html_base.html
trunk/docutils/test/functional/expected/standalone_rst_latex.tex
trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt
trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
trunk/docutils/test/functional/expected/standalone_rst_xhtml11.xhtml
trunk/docutils/test/functional/input/data/latex_encoding.txt
trunk/docutils/test/functional/input/data/standard.txt
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2015-03-19 09:22:15 UTC (rev 7848)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2015-03-19 15:54:58 UTC (rev 7849)
@@ -1151,7 +1151,7 @@
self.section_enumerator_separator = (
settings.section_enumerator_separator.replace('_', r'\_'))
# literal blocks:
- self.literal_block_env = ''
+ self.literal_block_env = 'alltt'
self.literal_block_options = ''
if settings.literal_block_env != '':
(none,
@@ -2417,30 +2417,39 @@
if not self.active_table.is_open():
# no quote inside tables, to avoid vertical space between
# table border and literal block.
- # BUG: fails if normal text precedes the literal block.
+ # TODO: fails if normal text precedes the literal block.
+ # check parent node instead?
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):
+
+ if self.is_plaintext(node):
environment = self.literal_block_env
- self.verbatim = True
+ self.requirements['literal_block'] = packages.get(environment, '')
+ if environment == 'alltt':
+ self.alltt = True
+ else:
+ self.verbatim = True
+ self.out.append('\\begin{%s}%s\n' %
+ (environment, self.literal_block_options))
+ self.context.append('\n\\end{%s}' % environment)
else:
- environment = 'alltt'
- self.alltt = True
- if ('code' in node['classes']
- and self.settings.syntax_highlight != 'none'):
+ self.literal = True
+ self.insert_newline = True
+ self.insert_non_breaking_blanks = 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.context.append('\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):
+ 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())
Modified: trunk/docutils/test/functional/expected/standalone_rst_html4css1.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html4css1.html 2015-03-19 09:22:15 UTC (rev 7848)
+++ trunk/docutils/test/functional/expected/standalone_rst_html4css1.html 2015-03-19 15:54:58 UTC (rev 7849)
@@ -836,7 +836,9 @@
This line is indented. The next line is blank.
Inline markup is supported, e.g. <em>emphasis</em>, <strong>strong</strong>, <tt class="docutils literal">literal
-text</tt>, footnotes <a class="footnote-reference" href="#id8" id="id22">[1]</a>, <span class="target" id="hyperlink-targets">hyperlink targets</span>, and <a class="reference external" href="http://www.python.org/">references</a>.
+text</tt>, <sub>sub-</sub> and <sup>super</sup>scripts,
+inline formulas: <span class="formula"><i>A</i> = 2<i>π</i><i>r</i><sup>2</sup></span>,
+footnotes <a class="footnote-reference" href="#id8" id="id22">[1]</a>, <span class="target" id="hyperlink-targets">hyperlink targets</span>, and <a class="reference external" href="http://www.python.org/">references</a>.
</pre>
</div>
<div class="section" id="code">
Modified: trunk/docutils/test/functional/expected/standalone_rst_html_base.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html_base.html 2015-03-19 09:22:15 UTC (rev 7848)
+++ trunk/docutils/test/functional/expected/standalone_rst_html_base.html 2015-03-19 15:54:58 UTC (rev 7849)
@@ -811,7 +811,9 @@
This line is indented. The next line is blank.
Inline markup is supported, e.g. <em>emphasis</em>, <strong>strong</strong>, <span class="docutils literal">literal
-text</span>, footnotes <a class="footnote-reference" href="#id8" id="id22">[1]</a>, <span class="target" id="hyperlink-targets">hyperlink targets</span>, and <a class="reference external" href="http://www.python.org/">references</a>.</pre>
+text</span>, <sub>sub-</sub> and <sup>super</sup>scripts,
+inline formulas: <span class="formula"><i>A</i> = 2<i>π</i><i>r</i><sup>2</sup></span>,
+footnotes <a class="footnote-reference" href="#id8" id="id22">[1]</a>, <span class="target" id="hyperlink-targets">hyperlink targets</span>, and <a class="reference external" href="http://www.python.org/">references</a>.</pre>
</div>
<div class="section" id="code">
<h3><a class="toc-backref" href="#id95"><span class="sectnum">2.14.9</span> Code</a></h3>
Modified: trunk/docutils/test/functional/expected/standalone_rst_latex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2015-03-19 09:22:15 UTC (rev 7848)
+++ trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2015-03-19 15:54:58 UTC (rev 7849)
@@ -1218,14 +1218,16 @@
}
%
\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}
+{\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},~\textsubscript{sub-}~and~\textsuperscript{super}scripts,\\
+inline~formulas:~$A = 2 \pi r^2$,\\
+footnotes\DUfootnotemark{id22}{id8}{1},~%
+\phantomsection\label{hyperlink-targets}hyperlink~targets,~and~\href{http://www.python.org/}{references}.
+}
\end{quote}
@@ -1250,11 +1252,11 @@
numbers:
%
\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}
+{\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
+}
\end{quote}
For inline code snippets, there is the \DUroletitlereference{code} role, which can be used
@@ -1269,10 +1271,10 @@
as a code block, here the rst file \texttt{header\_footer.txt} with line numbers:
%
\begin{quote}
-\begin{alltt}
-\DUrole{ln}{1 }.. header:: Document header
-\DUrole{ln}{2 }.. footer:: Document footer
-\end{alltt}
+{\ttfamily \raggedright \noindent
+\DUrole{ln}{1~}..~header::~Document~header\\
+\DUrole{ln}{2~}..~footer::~Document~footer
+}
\end{quote}
@@ -2299,7 +2301,7 @@
%
\begin{quote}
-item and all the other commands with optional arguments check
+Commands with optional arguments (e.g. \texttt{\textbackslash{}item}) check
if the token right after the macro name is an opening bracket.
In that case the contents between that bracket and the following
closing bracket on the same grouping level are taken as the
Modified: trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt 2015-03-19 09:22:15 UTC (rev 7848)
+++ trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt 2015-03-19 15:54:58 UTC (rev 7849)
@@ -1607,7 +1607,18 @@
<literal>
literal
text
- , footnotes
+ ,
+ <subscript>
+ sub-
+ and
+ <superscript>
+ super
+ scripts,
+ inline formulas:
+ <math>
+ A = 2 \pi r^2
+ ,
+ footnotes
<footnote_reference ids="id22" refid="id8">
1
,
Modified: trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2015-03-19 09:22:15 UTC (rev 7848)
+++ trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2015-03-19 15:54:58 UTC (rev 7849)
@@ -1217,14 +1217,16 @@
}
%
\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}
+{\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},~\textsubscript{sub-}~and~\textsuperscript{super}scripts,\\
+inline~formulas:~$A = 2 \pi r^2$,\\
+footnotes\DUfootnotemark{id22}{id8}{1},~%
+\phantomsection\label{hyperlink-targets}hyperlink~targets,~and~\href{http://www.python.org/}{references}.
+}
\end{quote}
@@ -1249,11 +1251,11 @@
numbers:
%
\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}
+{\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
+}
\end{quote}
For inline code snippets, there is the \DUroletitlereference{code} role, which can be used
@@ -1268,10 +1270,10 @@
as a code block, here the rst file \texttt{header\_footer.txt} with line numbers:
%
\begin{quote}
-\begin{alltt}
-\DUrole{ln}{1 }.. header:: Document header
-\DUrole{ln}{2 }.. footer:: Document footer
-\end{alltt}
+{\ttfamily \raggedright \noindent
+\DUrole{ln}{1~}..~header::~Document~header\\
+\DUrole{ln}{2~}..~footer::~Document~footer
+}
\end{quote}
@@ -2067,7 +2069,7 @@
%
\begin{quote}
-item and all the other commands with optional arguments check
+Commands with optional arguments (e.g. \texttt{\textbackslash{}item}) check
if the token right after the macro name is an opening bracket.
In that case the contents between that bracket and the following
closing bracket on the same grouping level are taken as the
Modified: trunk/docutils/test/functional/expected/standalone_rst_xhtml11.xhtml
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_xhtml11.xhtml 2015-03-19 09:22:15 UTC (rev 7848)
+++ trunk/docutils/test/functional/expected/standalone_rst_xhtml11.xhtml 2015-03-19 15:54:58 UTC (rev 7849)
@@ -813,7 +813,10 @@
This line is indented. The next line is blank.
Inline markup is supported, e.g. <em>emphasis</em>, <strong>strong</strong>, <span class="docutils literal">literal
-text</span>, footnotes <a class="footnote-reference" href="#id8" id="id22">[1]</a>, <span class="target" id="hyperlink-targets">hyperlink targets</span>, and <a class="reference external" href="http://www.python.org/">references</a>.</pre>
+text</span>, <sub>sub-</sub> and <sup>super</sup>scripts,
+inline formulas: <math xmlns="http://www.w3.org/1998/Math/MathML">
+<mrow><mi>A</mi><mo>=</mo><mn>2</mn><mi>π</mi><msup><mi>r</mi><mn>2</mn></msup></mrow></math>,
+footnotes <a class="footnote-reference" href="#id8" id="id22">[1]</a>, <span class="target" id="hyperlink-targets">hyperlink targets</span>, and <a class="reference external" href="http://www.python.org/">references</a>.</pre>
</div>
<div class="section" id="code">
<h3><a class="toc-backref" href="#id96"><span class="sectnum">2.14.9</span> Code</a></h3>
Modified: trunk/docutils/test/functional/input/data/latex_encoding.txt
===================================================================
--- trunk/docutils/test/functional/input/data/latex_encoding.txt 2015-03-19 09:22:15 UTC (rev 7848)
+++ trunk/docutils/test/functional/input/data/latex_encoding.txt 2015-03-19 15:54:58 UTC (rev 7849)
@@ -14,7 +14,7 @@
However also *square brackets* [] need special care.
- \item and all the other commands with optional arguments check
+ Commands with optional arguments (e.g. ``\item``) check
if the token right after the macro name is an opening bracket.
In that case the contents between that bracket and the following
closing bracket on the same grouping level are taken as the
Modified: trunk/docutils/test/functional/input/data/standard.txt
===================================================================
--- trunk/docutils/test/functional/input/data/standard.txt 2015-03-19 09:22:15 UTC (rev 7848)
+++ trunk/docutils/test/functional/input/data/standard.txt 2015-03-19 15:54:58 UTC (rev 7849)
@@ -317,8 +317,8 @@
also be centre-aligned:
.. class:: language-de align-center
-
-| **Die Trichter**
+
+| **Die Trichter**
|
| Zwei Trichter wandeln durch die Nacht.
| Durch ihres Rumpfs verengten Schacht
@@ -752,7 +752,9 @@
This line is indented. The next line is blank.
Inline markup is supported, e.g. *emphasis*, **strong**, ``literal
- text``, footnotes [1]_, _`hyperlink targets`, and `references
+ text``, :sub:`sub-` and :sup:`super`\ scripts,
+ inline formulas: :math:`A = 2 \pi r^2`,
+ footnotes [1]_, _`hyperlink targets`, and `references
<http://www.python.org/>`_.
Code
@@ -787,7 +789,7 @@
.. role:: tex(code)
:language: tex
-Docutils uses LaTeX syntax for math directives and roles:
+Docutils uses LaTeX syntax for math directives and roles:
:tex:`\alpha = f(x)` prints :math:`\alpha = f(x)`.
The ``:code:`` option of the `include` directive sets the included content
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|