summaryrefslogtreecommitdiff
path: root/docutils
diff options
context:
space:
mode:
authorgrubert <grubert@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2007-11-12 13:34:59 +0000
committergrubert <grubert@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2007-11-12 13:34:59 +0000
commit132178e7793634abd4cd35719bc0bdf0c481e408 (patch)
treee80532349bc6d812d30cd46954add4311e0bd355 /docutils
parente41af5d1237430e98d50d3a8fd6d2588b24497da (diff)
downloaddocutils-132178e7793634abd4cd35719bc0bdf0c481e408.tar.gz
latex2e writer : Move usepackage hyperref after stylesheet inclusion.
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@5462 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils')
-rw-r--r--docutils/HISTORY.txt1
-rw-r--r--docutils/docutils/writers/latex2e/__init__.py9
-rw-r--r--docutils/test/functional/expected/latex_docinfo.tex4
-rw-r--r--docutils/test/functional/expected/standalone_rst_latex.tex4
-rwxr-xr-xdocutils/test/test_writers/test_latex2e.py4
5 files changed, 17 insertions, 5 deletions
diff --git a/docutils/HISTORY.txt b/docutils/HISTORY.txt
index 599f76f5a..a205c4088 100644
--- a/docutils/HISTORY.txt
+++ b/docutils/HISTORY.txt
@@ -116,6 +116,7 @@ Changes Since 0.4
* docutils/writers/latex2e/__init__.py:
+ - Move usepackage hyperref after stylesheet inclusion.
- Fix: scrartcl does not have chapter but scrreprt.
- Add newline after ``\end{verbatim}``.
- Merge smaller differences from latex2e_adaptive_preamble.
diff --git a/docutils/docutils/writers/latex2e/__init__.py b/docutils/docutils/writers/latex2e/__init__.py
index dc865c653..2c6ff6e63 100644
--- a/docutils/docutils/writers/latex2e/__init__.py
+++ b/docutils/docutils/writers/latex2e/__init__.py
@@ -569,7 +569,9 @@ class LaTeXTranslator(nodes.NodeVisitor):
# ---------
latex_head = '\\documentclass[%s]{%s}\n'
- linking = '\\usepackage[colorlinks=%s,linkcolor=%s,urlcolor=%s]{hyperref}\n'
+ linking = "\\ifthenelse{\\isundefined{\\hypersetup}}{\n" \
+ +"\\usepackage[colorlinks=%s,linkcolor=%s,urlcolor=%s]{hyperref}\n" \
+ +"}{}\n"
stylesheet = '\\input{%s}\n'
# add a generated on day , machine by user using docutils version.
generator = '% generated by Docutils <http://docutils.sourceforge.net/>\n'
@@ -693,7 +695,6 @@ class LaTeXTranslator(nodes.NodeVisitor):
'\\usepackage{color}\n',
'\\usepackage{multirow}\n',
'\\usepackage{ifthen}\n', # before hyperref!
- self.linking % (self.colorlinks, self.hyperlink_color, self.hyperlink_color),
self.typearea,
self.generator,
# latex lengths
@@ -717,6 +718,10 @@ class LaTeXTranslator(nodes.NodeVisitor):
if stylesheet:
settings.record_dependencies.add(stylesheet)
self.head_prefix.append(self.stylesheet % (stylesheet))
+ # hyperref after stylesheet
+ # TODO conditionally if no hyperref is used dont include
+ self.head_prefix.append( self.linking % (
+ self.colorlinks, self.hyperlink_color, self.hyperlink_color))
if self.linking: # and maybe check for pdf
self.pdfinfo = [ ]
diff --git a/docutils/test/functional/expected/latex_docinfo.tex b/docutils/test/functional/expected/latex_docinfo.tex
index b1a9a1962..a093c7965 100644
--- a/docutils/test/functional/expected/latex_docinfo.tex
+++ b/docutils/test/functional/expected/latex_docinfo.tex
@@ -12,7 +12,6 @@
\usepackage{color}
\usepackage{multirow}
\usepackage{ifthen}
-\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
\usepackage[DIV12]{typearea}
% generated by Docutils <http://docutils.sourceforge.net/>
\newlength{\admonitionwidth}
@@ -55,6 +54,9 @@
\newcommand{\rubric}[1]{\subsection*{~\hfill {\it #1} \hfill ~}}
\newcommand{\titlereference}[1]{\textsl{#1}}
% end of "some commands"
+\ifthenelse{\isundefined{\hypersetup}}{
+\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
+}{}
\title{}
\author{Foo Fred~\\
Food Foomatics {\&} Friends~\\
diff --git a/docutils/test/functional/expected/standalone_rst_latex.tex b/docutils/test/functional/expected/standalone_rst_latex.tex
index 15393fbed..a4c9c9f6a 100644
--- a/docutils/test/functional/expected/standalone_rst_latex.tex
+++ b/docutils/test/functional/expected/standalone_rst_latex.tex
@@ -12,7 +12,6 @@
\usepackage{color}
\usepackage{multirow}
\usepackage{ifthen}
-\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
\usepackage[DIV12]{typearea}
% generated by Docutils <http://docutils.sourceforge.net/>
\newlength{\admonitionwidth}
@@ -55,6 +54,9 @@
\newcommand{\rubric}[1]{\subsection*{~\hfill {\it #1} \hfill ~}}
\newcommand{\titlereference}[1]{\textsl{#1}}
% end of "some commands"
+\ifthenelse{\isundefined{\hypersetup}}{
+\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
+}{}
\title{reStructuredText Test Document\\
\large{Examples of Syntax Constructs}
}
diff --git a/docutils/test/test_writers/test_latex2e.py b/docutils/test/test_writers/test_latex2e.py
index ea7a81f2e..84e263f59 100755
--- a/docutils/test/test_writers/test_latex2e.py
+++ b/docutils/test/test_writers/test_latex2e.py
@@ -36,7 +36,6 @@ latex_head = """\
\\usepackage{color}
\\usepackage{multirow}
\\usepackage{ifthen}
-\\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
\\usepackage[DIV12]{typearea}
% generated by Docutils <http://docutils.sourceforge.net/>
\\newlength{\\admonitionwidth}
@@ -79,6 +78,9 @@ latex_head = """\
\\newcommand{\\rubric}[1]{\\subsection*{~\\hfill {\\it #1} \\hfill ~}}
\\newcommand{\\titlereference}[1]{\\textsl{#1}}
% end of "some commands"
+\\ifthenelse{\\isundefined{\\hypersetup}}{
+\\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
+}{}
"""
totest = {}