|
From: <mi...@us...> - 2021-09-11 11:18:06
|
Revision: 8823
http://sourceforge.net/p/docutils/code/8823
Author: milde
Date: 2021-09-11 11:18:03 +0000 (Sat, 11 Sep 2021)
Log Message:
-----------
LaTeX writer: no newline before raw directives in compound blocks.
Based on patch 3 in patches #183 by Clement Pit-Claudel.
Modified Paths:
--------------
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/test/test_writers/test_latex2e.py
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2021-09-11 11:17:53 UTC (rev 8822)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2021-09-11 11:18:03 UTC (rev 8823)
@@ -2713,7 +2713,8 @@
def visit_raw(self, node):
if not 'latex' in node.get('format', '').split():
raise nodes.SkipNode
- if not self.is_inline(node):
+ if not (self.is_inline(node)
+ or isinstance(node.parent, nodes.compound)):
self.out.append('\n')
self.visit_inline(node)
# append "as-is" skipping any LaTeX-encoding
Modified: trunk/docutils/test/test_writers/test_latex2e.py
===================================================================
--- trunk/docutils/test/test_writers/test_latex2e.py 2021-09-11 11:17:53 UTC (rev 8822)
+++ trunk/docutils/test/test_writers/test_latex2e.py 2021-09-11 11:18:03 UTC (rev 8823)
@@ -188,7 +188,7 @@
-------
Paragraph 2.
""",
-## # expected output
+# expected output
head_template.substitute(dict(parts,
requirements=parts['requirements'] + '\\setcounter{secnumdepth}{0}\n',
fallbacks=r"""
@@ -235,7 +235,7 @@
.. [3] 1. enumeration
""",
-## # expected output
+# expected output
head_template.substitute(dict(parts,
fallbacks=r"""
% numerical or symbol footnotes with hyperlinks and backlinks
@@ -276,7 +276,7 @@
first section
-------------
""",
-## # expected output
+# expected output
head_template.substitute(dict(parts,
requirements=parts['requirements'] + '\\setcounter{secnumdepth}{0}\n'
)) + r"""
@@ -302,7 +302,7 @@
first section
-------------
""",
-## # expected output
+# expected output
head_template.substitute(dict(parts,
requirements=parts['requirements'] + '\\setcounter{secnumdepth}{0}\n'
)) + r"""
@@ -328,7 +328,7 @@
first section
-------------
""",
-## # expected output
+# expected output
head_template.substitute(dict(parts,
requirements=parts['requirements'] + '\\setcounter{secnumdepth}{0}\n'
)) + r"""
@@ -356,7 +356,7 @@
first chapter
-------------
""",
-## # expected output
+# expected output
head_template.substitute(dict(parts,
head_prefix=r"""\documentclass[a4paper]{book}
""",
@@ -386,7 +386,7 @@
first section
-------------
""",
-## # expected output
+# expected output
head_template.substitute(dict(parts, requirements = parts['requirements'] +
r"""\setcounter{secnumdepth}{0}
""")) + r"""
@@ -411,7 +411,7 @@
first section
-------------
""",
-## # expected output
+# expected output
head_template.substitute(dict(parts,
requirements=parts['requirements'] + '\\setcounter{secnumdepth}{0}\n'
)) + r"""
@@ -434,7 +434,7 @@
.. [my_cite2006]
The underscore is mishandled.
""",
-## # expected output
+# expected output
head + r"""
Just a test citation \cite{my_cite2006}.
@@ -1009,6 +1009,40 @@
\end{document}
"""],
+[r""".. compound::
+
+ Compound paragraph
+
+ .. raw:: LaTeX
+
+ raw LaTeX block
+
+ compound paragraph continuation.
+""",
+head_template.substitute(
+ dict(parts,
+ fallbacks = r"""
+% class handling for environments (block-level elements)
+% \begin{DUclass}{spam} tries \DUCLASSspam and
+% \end{DUclass}{spam} tries \endDUCLASSspam
+\ifx\DUclass\undefined % poor man's "provideenvironment"
+ \newenvironment{DUclass}[1]%
+ {% "#1" does not work in end-part of environment.
+ \def\DocutilsClassFunctionName{DUCLASS#1}
+ \csname \DocutilsClassFunctionName \endcsname}%
+ {\csname end\DocutilsClassFunctionName \endcsname}%
+\fi
+"""
+ )
+) + r"""
+\begin{DUclass}{compound}
+Compound paragraph
+raw LaTeX block
+compound paragraph continuation.
+\end{DUclass}
+
+\end{document}
+"""],
]
totest['title_with_inline_markup'] = [
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|