summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgrubert <grubert@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2006-11-28 15:18:45 +0000
committergrubert <grubert@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2006-11-28 15:18:45 +0000
commit2d679fd6beaab6fa73a9dcf55fb9acdc80e45655 (patch)
tree8f09eb9017079bc8d5a2044b4ca50d0bf9d16598
parentc1e00733c0c1f52392026a5beee4e5d02f136645 (diff)
downloaddocutils-2d679fd6beaab6fa73a9dcf55fb9acdc80e45655.tar.gz
Fix: output hypertargets
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@4819 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
-rw-r--r--HISTORY.txt1
-rw-r--r--docutils/writers/latex2e/__init__.py3
-rw-r--r--test/functional/expected/standalone_rst_latex.tex12
3 files changed, 10 insertions, 6 deletions
diff --git a/HISTORY.txt b/HISTORY.txt
index f96de4939..78f533535 100644
--- a/HISTORY.txt
+++ b/HISTORY.txt
@@ -87,6 +87,7 @@ Changes Since 0.4
* docutils/writers/latex2e/__init__.py:
+ - Fix: output ``hypertarget{ node.get(refid) }{}`` from visit_target.
- Add option --use-latex-abstract.
- Image width unit ``px`` is translated to ``pt``.
- Add image height support.
diff --git a/docutils/writers/latex2e/__init__.py b/docutils/writers/latex2e/__init__.py
index 1abdbe2a8..414424a0a 100644
--- a/docutils/writers/latex2e/__init__.py
+++ b/docutils/writers/latex2e/__init__.py
@@ -1924,6 +1924,9 @@ class LaTeXTranslator(nodes.NodeVisitor):
for id in node['ids']:
self.body.append('\\hypertarget{%s}{' % id)
self.context.append('}' * len(node['ids']))
+ elif node.get("refid"):
+ self.body.append('\\hypertarget{%s}{' % node.get("refid"))
+ self.context.append('}')
else:
self.context.append('')
diff --git a/test/functional/expected/standalone_rst_latex.tex b/test/functional/expected/standalone_rst_latex.tex
index efcbb0d8a..dabeac688 100644
--- a/test/functional/expected/standalone_rst_latex.tex
+++ b/test/functional/expected/standalone_rst_latex.tex
@@ -127,9 +127,9 @@ reStructuredText construct.
% This is a comment. Note how any initial comments are moved by
% transforms to after the document title, subtitle, and docinfo.
-% Above is the document title, and below is the subtitle.
+\hypertarget{doctitle}{}% Above is the document title, and below is the subtitle.
% They are transformed from section titles after parsing.
-% bibliographic fields (which also require a transform):
+\hypertarget{subtitle}{}% bibliographic fields (which also require a transform):
\hypertarget{table-of-contents}{}
\pdfbookmark[0]{Table of Contents}{table-of-contents}
\subsubsection*{~\hfill Table of Contents\hfill ~}
@@ -774,7 +774,7 @@ rendered separately and differently from footnotes.
Here's a reference to the above, [\hyperlink{cit2002}{CIT2002}], and a {\color{red}\bfseries{}{[}nonexistent{]}{\_}}
citation.
-
+\hypertarget{another-target}{}
%___________________________________________________________________________
@@ -783,7 +783,7 @@ citation.
\pdfbookmark[1]{2.13~~~Targets}{targets}
\pdfbookmark[1]{2.13~~~Targets}{another-target}
\subsection*{2.13~~~Targets}
-
+\hypertarget{example}{}
This paragraph is pointed to by the explicit ``example'' target. A
reference can be found under \href{\#inline-markup}{Inline Markup}, above. \href{\#inline-hyperlink-targets}{Inline
hyperlink targets} are also possible.
@@ -796,7 +796,7 @@ Explicit external targets are interpolated into references such as
Targets may be indirect and anonymous. Thus \href{\#id22}{this phrase} may also
refer to the \href{\#id22}{Targets} section.
-
+\hypertarget{id22}{}
Here's a {\color{red}\bfseries{}`hyperlink reference without a target`{\_}}, which generates an
error.
@@ -873,7 +873,7 @@ document (a document-wide \href{\#table-of-contents}{table of contents}).
An image directive (also clickable -{}- a hyperlink reference):
\href{\#directives}{\includegraphics{../../../docs/user/rst/images/title.png}}
Image with multiple IDs:
-
+\hypertarget{image-target-1}{}\hypertarget{image-target-2}{}\hypertarget{image-target-3}{}
\includegraphics{../../../docs/user/rst/images/title.png}
A centered image: