From 24515962f18aa7430f6980ccfc258d5355708d7b Mon Sep 17 00:00:00 2001 From: Louis Date: Tue, 19 Apr 2016 16:55:44 +0200 Subject: [PATCH] LaTeX compilation of URLs containing weird characters works --- patacrep/data/templates/styles/crepbook.sty | 4 ++-- patacrep/templates.py | 2 ++ test/test_book/special.tex.control | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/patacrep/data/templates/styles/crepbook.sty b/patacrep/data/templates/styles/crepbook.sty index 8d7139c0..f89bebee 100644 --- a/patacrep/data/templates/styles/crepbook.sty +++ b/patacrep/data/templates/styles/crepbook.sty @@ -79,8 +79,8 @@ % Title page \long\def\subtitle#1{\long\def\@subtitle{#1}} \def\version#1{\def\@version{#1}} -\def\web#1{\def\@web{#1}} -\def\mail#1{\def\@mail{#1}} +\def\web#1{\def\@web{\url{#1}}} +\def\mail#1{\def\@mail{\href{mailto:#1}{\nolinkurl{#1}}}} \def\email#1{\def\@email{#1}} \def\picture#1{\def\@picture{#1}} \def\picturecopyright#1{\def\@picturecopyright{#1}} diff --git a/patacrep/templates.py b/patacrep/templates.py index c68f78cc..214320eb 100644 --- a/patacrep/templates.py +++ b/patacrep/templates.py @@ -56,6 +56,8 @@ TRANSLATION_MAP_URL = { '}': '\\' + urllib.parse.quote("}"), '%': '\\%', '\\': '\\\\', + '#': '\\#', + '&': '\\&', } def _escape_specials(text, *, chars=None, translation_map=None): diff --git a/test/test_book/special.tex.control b/test/test_book/special.tex.control index 7c8e24ca..8f7d845a 100644 --- a/test/test_book/special.tex.control +++ b/test/test_book/special.tex.control @@ -101,8 +101,8 @@ guitar, \subtitle{\& \% \$ \# \_ \} \{ \textasciitilde{} \textasciicircum{} \textbackslash{}} -\mail{foo@\\\%&$#_~^\%20\%7B\%7D} -\web{http://\\\%&$#_~^\%20\%7B\%7D} +\mail{foo@\\\%\&$\#_~^\%20\%7B\%7D} +\web{http://\\\%\&$\#_~^\%20\%7B\%7D} \picture{img/treble_a} \picturecopyright{Dbolton \url{http://commons.wikimedia.org/wiki/User:Dbolton}} \footer{Generated using Songbook (\url{http://www.patacrep.com})}