summaryrefslogtreecommitdiff
path: root/docutils
diff options
context:
space:
mode:
authormilde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2017-08-08 21:39:19 +0000
committermilde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2017-08-08 21:39:19 +0000
commit046dfee06c6f9f7db3255452d90d3d2134c17176 (patch)
tree29f437120ca243819fe98cc569cfdaf759eebbb0 /docutils
parente1683f43e96c114c43c154967ef4b47e1f9c2338 (diff)
downloaddocutils-046dfee06c6f9f7db3255452d90d3d2134c17176.tar.gz
Fix [ 323 ]: do not add ``\\\\phantomsection`` and whitespace to ``parts["title"].
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@8161 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils')
-rw-r--r--docutils/HISTORY.txt14
-rw-r--r--docutils/docutils/writers/latex2e/__init__.py18
-rw-r--r--docutils/docutils/writers/latex2e/default.tex6
-rw-r--r--docutils/test/functional/expected/cyrillic.tex1
-rw-r--r--docutils/test/functional/expected/latex_babel.tex1
-rw-r--r--docutils/test/functional/expected/latex_cornercases.tex9
-rw-r--r--docutils/test/functional/expected/latex_docinfo.tex6
-rw-r--r--docutils/test/functional/expected/standalone_rst_latex.tex9
-rw-r--r--docutils/test/functional/expected/standalone_rst_xetex.tex5
-rw-r--r--docutils/test/functional/expected/xetex-cyrillic.tex1
-rwxr-xr-xdocutils/test/test_writers/test_latex2e.py7
11 files changed, 31 insertions, 46 deletions
diff --git a/docutils/HISTORY.txt b/docutils/HISTORY.txt
index f80bd60d6..80c2bac59 100644
--- a/docutils/HISTORY.txt
+++ b/docutils/HISTORY.txt
@@ -16,13 +16,19 @@
Changes Since 0.14
==================
-* infrastructure automatisms
+* General
+
+ - infrastructure automatisms.
+
+* docutils/writers/latex2e/__init__.py
+
+ - Fix [ 323 ] don't add ``\phantomsection`` and whitespace to
+ ``parts['title'].
+
Release 0.14 (2017-08-03)
=========================
-As rc2.
-
* docs/ref/docutils.dtd:
- Enable validation of Docutils XML documents against the DTD:
@@ -117,7 +123,7 @@ As rc2.
documents.
- The heading/title of admonitions now reflects the language
specified by the ``language`` setting.
- - Fixed [ 306 ] only first of multiple "image" directives with the same URL
+ - Fixed [ 306 ] only first of multiple "image" directives with the same URL
shown in output.
- Fixed [ 282 ] python3: AttributeError.
diff --git a/docutils/docutils/writers/latex2e/__init__.py b/docutils/docutils/writers/latex2e/__init__.py
index d21b10ef6..ea625ad29 100644
--- a/docutils/docutils/writers/latex2e/__init__.py
+++ b/docutils/docutils/writers/latex2e/__init__.py
@@ -217,9 +217,9 @@ class Writer(writers.Writer):
config_section_dependencies = ('writers',)
head_parts = ('head_prefix', 'requirements', 'latex_preamble',
- 'stylesheet', 'fallbacks', 'pdfsetup',
- 'title', 'subtitle', 'titledata')
- visitor_attributes = head_parts + ('body_pre_docinfo', 'docinfo',
+ 'stylesheet', 'fallbacks', 'pdfsetup', 'titledata')
+ visitor_attributes = head_parts + ('title', 'subtitle',
+ 'body_pre_docinfo', 'docinfo',
'dedication', 'abstract', 'body')
output = None
@@ -596,8 +596,7 @@ PreambleCmds.lineblock = r"""
}{}"""
# PreambleCmds.lineblock._depends = 'providelength'
-PreambleCmds.linking = r"""
-%% hyperlinks:
+PreambleCmds.linking = r"""%% hyperlinks:
\ifthenelse{\isundefined{\hypersetup}}{
\usepackage[%s]{hyperref}
\usepackage{bookmark}
@@ -1687,6 +1686,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.out.append('}\n')
def visit_author(self, node):
+ self.pdfauthor.append(self.attval(node.astext()))
self.visit_docinfo_item(node, 'author')
def depart_author(self, node):
@@ -1922,8 +1922,6 @@ class LaTeXTranslator(nodes.NodeVisitor):
'\\end{center}\n')
def visit_docinfo_item(self, node, name):
- if name == 'author':
- self.pdfauthor.append(self.attval(node.astext()))
if self.use_latex_docinfo:
if name in ('author', 'organization', 'contact', 'address'):
# We attach these to the last author. If any of them precedes
@@ -1989,12 +1987,10 @@ class LaTeXTranslator(nodes.NodeVisitor):
# 'author', 'organization', 'contact', 'address' and 'date')
if self.title or (
self.use_latex_docinfo and (self.author_stack or self.date)):
- # with the default template, titledata is written to the preamble
- self.titledata.append('%%% Title Data')
# \title (empty \title prevents error with \maketitle)
+ title = [''.join(self.title)]
if self.title:
- self.title.insert(0, '\\phantomsection%\n ')
- title = [''.join(self.title)] + self.title_labels
+ title += self.title_labels
if self.subtitle:
title += [r'\\ % subtitle',
r'\DUdocumentsubtitle{%s}' % ''.join(self.subtitle)
diff --git a/docutils/docutils/writers/latex2e/default.tex b/docutils/docutils/writers/latex2e/default.tex
index 98f6396cb..8a39d80cf 100644
--- a/docutils/docutils/writers/latex2e/default.tex
+++ b/docutils/docutils/writers/latex2e/default.tex
@@ -6,9 +6,9 @@ $latex_preamble
%%% User specified packages and stylesheets
$stylesheet
%%% Fallback definitions for Docutils-specific commands
-$fallbacks$pdfsetup
-$titledata
+$fallbacks
+$pdfsetup
%%% Body
\begin{document}
-$body_pre_docinfo$docinfo$dedication$abstract$body
+$titledata$body_pre_docinfo$docinfo$dedication$abstract$body
\end{document}
diff --git a/docutils/test/functional/expected/cyrillic.tex b/docutils/test/functional/expected/cyrillic.tex
index d562fd6ca..28a48dcc1 100644
--- a/docutils/test/functional/expected/cyrillic.tex
+++ b/docutils/test/functional/expected/cyrillic.tex
@@ -28,7 +28,6 @@
\urlstyle{same} % normal text font (alternatives: tt, rm, sf)
}{}
-
%%% Body
\begin{document}
diff --git a/docutils/test/functional/expected/latex_babel.tex b/docutils/test/functional/expected/latex_babel.tex
index 106dcb6f5..14cdbac03 100644
--- a/docutils/test/functional/expected/latex_babel.tex
+++ b/docutils/test/functional/expected/latex_babel.tex
@@ -31,7 +31,6 @@
\urlstyle{same} % normal text font (alternatives: tt, rm, sf)
}{}
-
%%% Body
\begin{document}
diff --git a/docutils/test/functional/expected/latex_cornercases.tex b/docutils/test/functional/expected/latex_cornercases.tex
index 25079a4a1..175511ee6 100644
--- a/docutils/test/functional/expected/latex_cornercases.tex
+++ b/docutils/test/functional/expected/latex_cornercases.tex
@@ -37,15 +37,12 @@
pdftitle={Some Tests for the LaTeX Writer},
}
-%%% Title Data
-\title{\phantomsection%
- Some Tests for the LaTeX Writer%
+%%% Body
+\begin{document}
+\title{Some Tests for the LaTeX Writer%
\label{some-tests-for-the-latex-writer}}
\author{}
\date{}
-
-%%% Body
-\begin{document}
\maketitle
These tests contain unusual combinations of syntax elements which may cause
diff --git a/docutils/test/functional/expected/latex_docinfo.tex b/docutils/test/functional/expected/latex_docinfo.tex
index a51d15891..0be892f78 100644
--- a/docutils/test/functional/expected/latex_docinfo.tex
+++ b/docutils/test/functional/expected/latex_docinfo.tex
@@ -25,7 +25,8 @@
pdfauthor={Foo Fred;Bar Barney}
}
-%%% Title Data
+%%% Body
+\begin{document}
\title{}
\author{Foo Fred\\
Food Foomatics \& Friends\\
@@ -38,9 +39,6 @@ Bar-BQ Bar\\
Barbara St 16\\
South Barwell}
\date{}
-
-%%% Body
-\begin{document}
\maketitle
\end{document}
diff --git a/docutils/test/functional/expected/standalone_rst_latex.tex b/docutils/test/functional/expected/standalone_rst_latex.tex
index 42fe61553..6b4222fc2 100644
--- a/docutils/test/functional/expected/standalone_rst_latex.tex
+++ b/docutils/test/functional/expected/standalone_rst_latex.tex
@@ -196,9 +196,9 @@
pdfauthor={David Goodger;Me;Myself;I}
}
-%%% Title Data
-\title{\phantomsection%
- reStructuredText Test Document%
+%%% Body
+\begin{document}
+\title{reStructuredText Test Document%
\label{restructuredtext-test-document}%
\label{doctitle}%
\\ % subtitle%
@@ -207,9 +207,6 @@
\label{subtitle}}
\author{}
\date{}
-
-%%% Body
-\begin{document}
\maketitle
% Docinfo
diff --git a/docutils/test/functional/expected/standalone_rst_xetex.tex b/docutils/test/functional/expected/standalone_rst_xetex.tex
index 058c20e5c..111f6eb7f 100644
--- a/docutils/test/functional/expected/standalone_rst_xetex.tex
+++ b/docutils/test/functional/expected/standalone_rst_xetex.tex
@@ -186,7 +186,6 @@
\hspace*{\fill}\hrulefill\hspace*{\fill}
\vskip 0.5\baselineskip
}
-
% hyperlinks:
\ifthenelse{\isundefined{\hypersetup}}{
\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
@@ -198,9 +197,7 @@
pdfauthor={David Goodger;Me;Myself;I}
}
-%%% Title Data
-\title{\phantomsection%
- reStructuredText Test Document%
+\title{reStructuredText Test Document%
\label{restructuredtext-test-document}%
\label{doctitle}%
\\ % subtitle%
diff --git a/docutils/test/functional/expected/xetex-cyrillic.tex b/docutils/test/functional/expected/xetex-cyrillic.tex
index 13727e7de..8268a71d9 100644
--- a/docutils/test/functional/expected/xetex-cyrillic.tex
+++ b/docutils/test/functional/expected/xetex-cyrillic.tex
@@ -26,7 +26,6 @@
% titlereference role
\providecommand*{\DUroletitlereference}[1]{\textsl{#1}}
-
% hyperlinks:
\ifthenelse{\isundefined{\hypersetup}}{
\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue,unicode=false]{hyperref}
diff --git a/docutils/test/test_writers/test_latex2e.py b/docutils/test/test_writers/test_latex2e.py
index 6a3ada132..0c68f8cb1 100755
--- a/docutils/test/test_writers/test_latex2e.py
+++ b/docutils/test/test_writers/test_latex2e.py
@@ -45,10 +45,9 @@ $latex_preamble
$stylesheet
%%% Fallback definitions for Docutils-specific commands
$fallbacks$pdfsetup
-$titledata
%%% Body
\begin{document}
-""")
+$titledata""")
parts = dict(
head_prefix = r"""\documentclass[a4paper]{article}
@@ -899,9 +898,7 @@ head_template.substitute(dict(parts,
pdfsetup=parts['pdfsetup'] + r"""\hypersetup{
pdftitle={This is the Title},
}
-""", titledata=r"""%%% Title Data
-\title{\phantomsection%
- This is the \emph{Title}%
+""", titledata=r"""\title{This is the \emph{Title}%
\label{this-is-the-title}%
\\ % subtitle%
\DUdocumentsubtitle{This is the \emph{Subtitle}}%