summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgrubert <grubert@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2008-02-15 19:25:44 +0000
committergrubert <grubert@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2008-02-15 19:25:44 +0000
commit4f269eb57cbde8662984ae36d72230953c9a8290 (patch)
tree0ca30f89a837f694c5c58cf185c67cef87d95467
parent40dc78620d1888b6e5bede399c32dcd02f46386f (diff)
downloaddocutils-lossless-rst-writer@5513.tar.gz
Fix: escaping ``%`` in href urls.lossless-rst-writer@5513
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@5512 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
-rw-r--r--HISTORY.txt1
-rw-r--r--docutils/writers/latex2e/__init__.py2
-rwxr-xr-xtest/test_writers/test_latex2e.py17
3 files changed, 19 insertions, 1 deletions
diff --git a/HISTORY.txt b/HISTORY.txt
index ce3b179da..a1e378863 100644
--- a/HISTORY.txt
+++ b/HISTORY.txt
@@ -117,6 +117,7 @@ Changes Since 0.4
* docutils/writers/latex2e/__init__.py:
+ - Fix: escaping ``%`` in href urls.
- Move usepackage hyperref after stylesheet inclusion.
- Fix: scrartcl does not have chapter but scrreprt.
- Add newline after ``\end{verbatim}``.
diff --git a/docutils/writers/latex2e/__init__.py b/docutils/writers/latex2e/__init__.py
index 2c6ff6e63..a72d22049 100644
--- a/docutils/writers/latex2e/__init__.py
+++ b/docutils/writers/latex2e/__init__.py
@@ -1858,7 +1858,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
href = hash_char + self.document.nameids[node['refname']]
else:
raise AssertionError('Unknown reference.')
- self.body.append('\\href{%s}{' % href)
+ self.body.append('\\href{%s}{' % href.replace("%", "\\%"))
if self._reference_label and not node.has_key('refuri'):
self.body.append('\\%s{%s}}' % (self._reference_label,
href.replace(hash_char, '')))
diff --git a/test/test_writers/test_latex2e.py b/test/test_writers/test_latex2e.py
index 84e263f59..fea5e537c 100755
--- a/test/test_writers/test_latex2e.py
+++ b/test/test_writers/test_latex2e.py
@@ -87,6 +87,23 @@ totest = {}
totest_latex_toc = {}
totest_latex_citations = {}
+totest['url_chars'] = [
+["http://nowhere/url_with%28parens%29",
+latex_head + """\
+\\title{}
+\\author{}
+\\date{}
+\\raggedbottom
+\\begin{document}
+
+\\setlength{\\locallinewidth}{\\linewidth}
+
+\\href{http://nowhere/url_with\\%28parens\\%29}{http://nowhere/url{\\_}with{\\%}28parens{\\%}29}
+
+\\end{document}
+"""],
+]
+
totest['table_of_contents'] = [
# input
["""\