SF.net SVN: docutils:[10160 ] trunk/docutils
milde--- via Docutils-checkins <[email protected]> Tue, 10 Jun 2025 09:57:33 +0000
| Newsgroups | gmane.text.docutils.cvs |
|---|---|
| Message-ID | <[email protected]> |
Revision: 10160
http://sourceforge.net/p/docutils/code/10160
Author: milde
Date: 2025-06-10 09:57:32 +0000 (Tue, 10 Jun 2025)
Log Message:
-----------
LaTeX writer: Don't merge paragraphs if there is a `<target>` between them.
`visit_target()` must keep a blank line between block-level elements.
Most targets with ID are inline elements, because the `PropagateTargets`
transform transfers the ID of a most block-level targets to the next element.
However, a target keeps its ID if the next element is invisible (e.g. a pending
node from a "class" directive, a comment, or a substitution definition).
Modified Paths:
--------------
trunk/docutils/HISTORY.rst
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/test/functional/expected/latex_memoir.tex
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.rst
===================================================================
--- trunk/docutils/HISTORY.rst 2025-06-08 21:24:13 UTC (rev 10159)
+++ trunk/docutils/HISTORY.rst 2025-06-10 09:57:32 UTC (rev 10160)
@@ -34,6 +34,7 @@
node's IDs.
- Disable "hyperref" footnote handling to avoid "empty anchor" warnings.
- Re-style system messages.
+ - Don't merge paragraphs if there is a target between them.
* docutils/writers/manpage.py
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2025-06-08 21:24:13 UTC (rev 10159)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2025-06-10 09:57:32 UTC (rev 10160)
@@ -3111,7 +3111,9 @@
or 'refname' in node): # unresolved internal link
## self.out.append('%% %s\n' % node) # for debugging
return
- self.out.append('%\n')
+ if self.is_inline(node):
+ self.out.append('%')
+ self.out.append('\n')
self.visit_inline(node)
def depart_target(self, node) -> None:
Modified: trunk/docutils/test/functional/expected/latex_memoir.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_memoir.tex 2025-06-08 21:24:13 UTC (rev 10159)
+++ trunk/docutils/test/functional/expected/latex_memoir.tex 2025-06-10 09:57:32 UTC (rev 10160)
@@ -398,7 +398,7 @@
\item Nested item 3.
\item This nested list should be compacted by the HTML writer.
-%
+
\phantomsection\label{target}
% Even if this item contains a target and a comment.
\end{itemize}
Modified: trunk/docutils/test/functional/expected/standalone_rst_latex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2025-06-08 21:24:13 UTC (rev 10159)
+++ trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2025-06-10 09:57:32 UTC (rev 10160)
@@ -392,7 +392,7 @@
\item Nested item 3.
\item This nested list should be compacted by the HTML writer.
-%
+
\phantomsection\label{target}
% Even if this item contains a target and a comment.
\end{itemize}
Modified: trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2025-06-08 21:24:13 UTC (rev 10159)
+++ trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2025-06-10 09:57:32 UTC (rev 10160)
@@ -384,7 +384,7 @@
\item Nested item 3.
\item This nested list should be compacted by the HTML writer.
-%
+
\phantomsection\label{target}
% Even if this item contains a target and a comment.
\end{itemize}
Modified: trunk/docutils/test/test_writers/test_latex2e.py
===================================================================
--- trunk/docutils/test/test_writers/test_latex2e.py 2025-06-08 21:24:13 UTC (rev 10159)
+++ trunk/docutils/test/test_writers/test_latex2e.py 2025-06-10 09:57:32 UTC (rev 10160)
@@ -308,6 +308,25 @@
\\hline
\\end{longtable*}
"""],
+# Test handling of IDs and custom class values
+# --------------------------------------------
+# targets with ID
+["""\
+A paragraph with _`inline target`.
+
+.. _block target:
+
+.. class:: custom paragraph
+
+Next paragraph.
+""",
+r"""
+A paragraph with %
+\phantomsection\label{inline-target}inline target.
+
+\phantomsection\label{block-target}
+\DUrole{custom}{\DUrole{paragraph}{Next paragraph.}}
+"""],
# table with IDs and custom + special class values
["""\
.. class:: cls1
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.