summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormilde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2013-01-17 15:48:30 +0000
committermilde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2013-01-17 15:48:30 +0000
commitd50ae48c6bd935772929abdddc49f1bd5e607330 (patch)
tree7d5ceb27d3fd5fe2e0fe805bce6d9df5afbef054
parentd123ce247f5ed7d6047a73c244b459061d91a9eb (diff)
downloaddocutils-d50ae48c6bd935772929abdddc49f1bd5e607330.tar.gz
Fix literal use of babel shorthands (straight quote, tilde, ...).
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@7589 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
-rw-r--r--HISTORY.txt6
-rw-r--r--docutils/writers/latex2e/__init__.py106
-rw-r--r--test/functional/expected/cyrillic.tex12
-rw-r--r--test/functional/expected/latex_babel.tex61
-rw-r--r--test/functional/expected/standalone_rst_latex.tex28
-rw-r--r--test/functional/expected/standalone_rst_xetex.tex30
-rw-r--r--test/functional/expected/xetex-cyrillic.tex14
-rw-r--r--test/functional/input/cyrillic.txt6
-rw-r--r--test/functional/input/latex_babel.txt36
-rw-r--r--test/functional/tests/latex_babel.py10
-rw-r--r--test/functional/tests/latex_cyrillic.py3
-rw-r--r--test/functional/tests/xetex_cyrillic.py2
-rwxr-xr-xtest/test_writers/test_latex2e.py5
13 files changed, 227 insertions, 92 deletions
diff --git a/HISTORY.txt b/HISTORY.txt
index 31df77cfd..5e770e8f5 100644
--- a/HISTORY.txt
+++ b/HISTORY.txt
@@ -23,9 +23,11 @@ Changes Since 0.10
* docutils/writers/latex2e/__init__.py
- Drop the simple algorithm replacing straight double quotes with
- English typographic ones. Use the SmartQuotes transform
- (``--smart-quotes=True``) instead.
+ English typographic ones.
+ Activate the SmartQuotes_ transform if you want this feature.
+ - Fix literal use of babel shorthands (straight quote, tilde, ...).
+.. _SmartQuotes: docs/user/config.html#smart-quotes
Release 0.10 (2012-12-16)
=========================
diff --git a/docutils/writers/latex2e/__init__.py b/docutils/writers/latex2e/__init__.py
index 9a0149e3b..4d932c07c 100644
--- a/docutils/writers/latex2e/__init__.py
+++ b/docutils/writers/latex2e/__init__.py
@@ -305,7 +305,7 @@ class Babel(object):
'en-GB': 'british',
'en-NZ': 'newzealand',
'en-US': 'american',
- 'eo': 'esperanto', # '^' is active
+ 'eo': 'esperanto',
'es': 'spanish',
'et': 'estonian',
'eu': 'basque',
@@ -335,12 +335,12 @@ class Babel(object):
'nb': 'norsk', # Norwegian Bokmal
'nl': 'dutch',
'nn': 'nynorsk', # Norwegian Nynorsk
- 'no': 'norsk', # Norwegian Bokmal
+ 'no': 'norsk', # Norwegian (Bokmal)
'pl': 'polish',
'pt': 'portuges',
'pt-BR': 'brazil',
'ro': 'romanian',
- 'ru': 'russian', # '"' is active
+ 'ru': 'russian',
'se': 'samin', # North Sami
# sh-Cyrl: Serbo-Croatian, Cyrillic script
'sh-Latn': 'serbian', # Serbo-Croatian, Latin script
@@ -348,7 +348,7 @@ class Babel(object):
'sl': 'slovene',
'sq': 'albanian',
# 'sr-Cyrl': Serbian, Cyrillic script (sr-cyrl)
- 'sr-Latn': 'serbian', # Serbian, Latin script, " active.
+ 'sr-Latn': 'serbian', # Serbian, Latin script
'sv': 'swedish',
# 'th': 'thai',
'tr': 'turkish',
@@ -361,49 +361,59 @@ class Babel(object):
warn_msg = 'Language "%s" not supported by LaTeX (babel)'
- # double quotes are "active" in some languages (e.g. German).
- literal_double_quote = u'"'
- # Languages with active ``"``, defining ``\dq``:
- active_dq_languages = ('bulgarian',
- 'czech',
- 'estonian',
- 'german', 'ngerman', 'austrian', 'naustrian',
- 'icelandic',
- 'norsk', 'nynorsk',
- 'polish',
- 'russian',
- 'slovak',
- 'swedish',
- 'ukrainian',
- 'uppersorbian',)
- # Languages with active ``"``, not defining ``\dq``
- # TODO: complete set of languages with active ``"``,
- # care for other active characters.
- active_dq_languages_2 = ('danish',
- 'dutch',
- 'italian', 'latin')
+ # "Active characters" are shortcuts that start a LaTeX macro and may need
+ # escaping for literals use. Characters that prevent literal use (e.g.
+ # starting accent macros like "a -> ä) will be deactivated if one of the
+ # defining languages is used in the document.
+ # Special cases:
+ # ~ (tilde) -- used in estonian, basque, galician, and old versions of
+ # spanish -- cannot be deactivated as it denotes a no-break space macro,
+ # " (straight quote) -- used in albanian, austrian, basque
+ # brazil, bulgarian, catalan, czech, danish, dutch, estonian,
+ # finnish, galician, german, icelandic, italian, latin, naustrian,
+ # ngerman, norsk, nynorsk, polish, portuges, russian, serbian, slovak,
+ # slovene, spanish, swedish, ukrainian, and uppersorbian --
+ # is escaped as ``\textquotedbl``.
+ active_chars = {# TeX/Babel-name: active characters to deactivate
+ # 'breton': ':;!?' # ensure whitespace
+ # 'esperanto': '^',
+ # 'estonian': '~"`',
+ # 'french': ':;!?' # ensure whitespace
+ 'galician': '.<>', # also '~"'
+ # 'magyar': '`', # for special hyphenation cases
+ 'spanish': '.<>', # old versions also '~'
+ # 'turkish': ':!=' # ensure whitespace
+ }
def __init__(self, language_code, reporter=None):
self.reporter = reporter
self.language = self.language_name(language_code)
self.otherlanguages = {}
- self.quote_index = 0
- # language dependent configuration:
- if self.language in active_dq_languages:
- self.literal_double_quote = ur'\dq{}'
- elif self.language in active_dq_languages_2:
- self.literal_double_quote = ur'{\char`\"}'
def __call__(self):
"""Return the babel call with correct options and settings"""
languages = sorted(self.otherlanguages.keys())
languages.append(self.language or 'english')
self.setup = [r'\usepackage[%s]{babel}' % ','.join(languages)]
- if 'spanish' in languages:
- # reset active chars to the original meaning:
- self.setup.append(
- r'\addto\shorthandsspanish{\spanishdeactivate{."~<>}}')
- # or prepend r'\def\spanishoptions{es-noshorthands}'
+ # Deactivate "active characters"
+ shorthands = []
+ for c in ''.join([self.active_chars.get(l, '') for l in languages]):
+ if c not in shorthands:
+ shorthands.append(c)
+ if shorthands:
+ self.setup.append(r'\AtBeginDocument{\shorthandoff{%s}}'
+ % ''.join(shorthands))
+ # Including '~' in shorthandoff prevents its use as no-break space
+ if 'galician' in languages:
+ self.setup.append(r'\deactivatetilden % restore ~ in Galician')
+ if 'estonian' in languages:
+ self.setup.extend([r'\makeatletter',
+ r' \addto\extrasestonian{\bbl@deactivate{~}}',
+ r'\makeatother'])
+ if 'basque' in languages:
+ self.setup.extend([r'\makeatletter',
+ r' \addto\extrasbasque{\bbl@deactivate{~}}',
+ r'\makeatother'])
if (languages[-1] == 'english' and
'french' in self.otherlanguages.keys()):
self.setup += ['% Prevent side-effects if French hyphenation '
@@ -702,6 +712,8 @@ class CharMaps(object):
ord('\\'): ur'\textbackslash{}',
ord('{'): ur'\{',
ord('}'): ur'\}',
+ # straight double quotes are 'active' in many languages
+ ord('"'): ur'\textquotedbl{}',
# Square brackets are ordinary chars and cannot be escaped with '\',
# so we put them in a group '{[}'. (Alternative: ensure that all
# macros with optional arguments are terminated with {} and text
@@ -710,7 +722,8 @@ class CharMaps(object):
# group, e.g. ``\item[{\hyperref[label]{text}}]``.
ord('['): ur'{[}',
ord(']'): ur'{]}',
- # the soft hyphen is unknown in 8-bit text and not properly handled by XeTeX
+ # the soft hyphen is unknown in 8-bit text
+ # and not properly handled by XeTeX
0x00AD: ur'\-', # SOFT HYPHEN
}
# Unicode chars that are not recognized by LaTeX's utf8 encoding
@@ -1261,9 +1274,19 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.requirements['_inputenc'] = (r'\usepackage[%s]{inputenc}'
% self.latex_encoding)
# TeX font encoding
- if self.font_encoding and not self.is_xetex:
- self.requirements['_fontenc'] = (r'\usepackage[%s]{fontenc}' %
- self.font_encoding)
+ if not self.is_xetex:
+ if self.font_encoding:
+ self.requirements['_fontenc'] = (r'\usepackage[%s]{fontenc}' %
+ self.font_encoding)
+ # ensure \textquotedbl is defined:
+ for enc in self.font_encoding.split(','):
+ enc = enc.strip()
+ if enc == 'OT1':
+ self.requirements['_textquotedblOT1'] = (
+ r'\DeclareTextSymbol{\textquotedbl}{OT1}{`\"}')
+ elif enc not in ('T1', 'T2A', 'T2B', 'T2C', 'T4', 'T5'):
+ self.requirements['_textquotedbl'] = (
+ r'\DeclareTextSymbolDefault{\textquotedbl}{T1}')
# page layout with typearea (if there are relevant document options)
if (settings.documentclass.find('scr') == -1 and
(self.documentoptions.find('DIV') != -1 or
@@ -1423,9 +1446,6 @@ class LaTeXTranslator(nodes.NodeVisitor):
# Set up the translation table:
table = CharMaps.special.copy()
- # double quotes are 'active' in some languages
- # TODO: use \textquotedbl if font encoding is T1?
- table[ord('"')] = self.babel.literal_double_quote
# keep the underscore in citation references
if self.inside_citation_reference_label:
del(table[ord('_')])
diff --git a/test/functional/expected/cyrillic.tex b/test/functional/expected/cyrillic.tex
index 740241904..90dff86c3 100644
--- a/test/functional/expected/cyrillic.tex
+++ b/test/functional/expected/cyrillic.tex
@@ -37,28 +37,28 @@
\label{id1}%
}
-первый пример: "Здравствуй, мир!"
+первый пример: «Здравствуй, мир!»
\section{Title%
\label{title}%
}
-\otherlanguage{english}{first example: "Hello world".}
+\foreignlanguage{english}{first example: “Hello world”.}
\section{Notes%
\label{notes}%
}
-This example tests rendering of Latin and Cyrillic characters by the LaTeX
+\foreignlanguage{english}{This example tests rendering of Latin and Cyrillic characters by the LaTeX
and XeTeX writers. Check the compiled PDF for garbage characters in text and
-bookmarks.
+bookmarks.}
-To work around a problem with Cyrillic in PDF-bookmarks in \DUroletitlereference{hyperref}
+\foreignlanguage{english}{To work around a problem with Cyrillic in PDF-bookmarks in \DUroletitlereference{hyperref}
versions older than v6.79g 2009/11/20, the test caller \texttt{latex\_cyrillic.py}
sets \texttt{hyperref\_options} to \texttt{'unicode=true'} while \texttt{xetex\_cyrillic.py}
sets it to \texttt{'unicode=false'}. The recommended option for current
-(2011-08-24) hyperref versions is \texttt{'pdfencoding=auto'}.
+(2011-08-24) hyperref versions is \texttt{'pdfencoding=auto'}.}
\end{document}
diff --git a/test/functional/expected/latex_babel.tex b/test/functional/expected/latex_babel.tex
new file mode 100644
index 000000000..5f89f91d6
--- /dev/null
+++ b/test/functional/expected/latex_babel.tex
@@ -0,0 +1,61 @@
+\documentclass[a4paper]{article}
+% generated by Docutils <http://docutils.sourceforge.net/>
+\usepackage{fixltx2e} % LaTeX patches, \textsubscript
+\usepackage{cmap} % fix search and cut-and-paste in Acrobat
+\usepackage{ifthen}
+\usepackage[T1]{fontenc}
+\usepackage[utf8]{inputenc}
+\usepackage[basque,esperanto,estonian,galician,ngerman,english]{babel}
+\AtBeginDocument{\shorthandoff{.<>}}
+\deactivatetilden % restore ~ in Galician
+\makeatletter
+ \addto\extrasestonian{\bbl@deactivate{~}}
+\makeatother
+\makeatletter
+ \addto\extrasbasque{\bbl@deactivate{~}}
+\makeatother
+
+%%% Custom LaTeX preamble
+% PDF Standard Fonts
+\usepackage{mathptmx} % Times
+\usepackage[scaled=.90]{helvet}
+\usepackage{courier}
+
+%%% User specified packages and stylesheets
+
+%%% Fallback definitions for Docutils-specific commands
+
+% hyperlinks:
+\ifthenelse{\isundefined{\hypersetup}}{
+ \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
+ \urlstyle{same} % normal text font (alternatives: tt, rm, sf)
+}{}
+
+
+%%% Body
+\begin{document}
+
+The \href{http://www.ctan.org/packages/babel}{babel} package introduces the concept of \textquotedbl{}shorthands\textquotedbl{}: additional
+characters that introduce a latex macro. Most common is the active double
+quote (\textquotedbl{}). Problematic is the tilde character (\textasciitilde{}) which is regularely used
+for no-break spaces but redefined by some language definition files:
+
+English: 'an' \textquotedbl{}active\textquotedbl{}-quote, \textasciicircum{}circumflex, and~no-break~spaces
+
+\foreignlanguage{basque}{Basque: 'an' \textquotedbl{}active\textquotedbl{}-quote, \textasciicircum{}circumflex, and~no-break~spaces}
+
+\foreignlanguage{esperanto}{Esperanto: 'an' \textquotedbl{}active\textquotedbl{}-quote, \textasciicircum{}circumflex, and~no-break~spaces}
+
+\foreignlanguage{estonian}{Estonian: 'an' \textquotedbl{}active\textquotedbl{}-quote, \textasciicircum{}circumflex, and~no-break~spaces}
+
+\foreignlanguage{galician}{Galician: 'an' \textquotedbl{}active\textquotedbl{}-quote, \textasciicircum{}circumflex, and~no-break~spaces}
+
+\foreignlanguage{ngerman}{German: 'an' \textquotedbl{}active\textquotedbl{}-quote, \textasciicircum{}circumflex, and~no-break~spaces}
+
+Spanish: option clash with Galician!
+
+% .. class:: language-es
+%
+% Spanish: 'an' "active"-quote, ^circumflex, and no-break spaces
+
+\end{document}
diff --git a/test/functional/expected/standalone_rst_latex.tex b/test/functional/expected/standalone_rst_latex.tex
index 1ba0875ed..767db1c30 100644
--- a/test/functional/expected/standalone_rst_latex.tex
+++ b/test/functional/expected/standalone_rst_latex.tex
@@ -359,7 +359,7 @@ reference to the \hyperref[doctitle]{doctitle} and the \hyperref[subtitle]{subti
The default role for interpreted text is \DUroletitlereference{Title Reference}. Here are
some explicit interpreted text roles: a PEP reference (\href{http://www.python.org/dev/peps/pep-0287}{PEP 287}); an
RFC reference (\href{http://www.faqs.org/rfcs/rfc2822.html}{RFC 2822}); an abbreviation (\DUrole{abbreviation}{abb.}), an acronym
-(\DUrole{acronym}{reST}), code (\texttt{\DUrole{code}{print "hello world"}}); a \textsubscript{subscript};
+(\DUrole{acronym}{reST}), code (\texttt{\DUrole{code}{print \textquotedbl{}hello world\textquotedbl{}}}); a \textsubscript{subscript};
a \textsuperscript{superscript} and explicit roles for \DUroletitlereference{Docutils}’
\emph{standard} \textbf{inline} \texttt{markup}.
@@ -701,7 +701,7 @@ A line block, like the following poem by Christian Morgenstern, can
also be centre-aligned:
\begin{DUlineblock}{0em}
-\otherlanguage{ngerman}{\DUrole{align-center}{
+\foreignlanguage{ngerman}{\DUrole{align-center}{
\item[] \textbf{Die Trichter}
\item[]
\item[] Zwei Trichter wandeln durch die Nacht.
@@ -742,7 +742,7 @@ a class attribute:
%
%
\begin{quote}
-\otherlanguage{french}{
+\foreignlanguage{french}{
ReStructuredText est un langage de balisage léger utilisé
notamment dans la documentation du langage Python.
}
@@ -754,8 +754,8 @@ notamment dans la documentation du langage Python.
}
%
\begin{quote}{\ttfamily \raggedright \noindent
->{}>{}>~print~'Python-specific~usage~examples;~begun~with~">{}>{}>"'\\
-Python-specific~usage~examples;~begun~with~">{}>{}>"\\
+>{}>{}>~print~'Python-specific~usage~examples;~begun~with~\textquotedbl{}>{}>{}>\textquotedbl{}'\\
+Python-specific~usage~examples;~begun~with~\textquotedbl{}>{}>{}>\textquotedbl{}\\
>{}>{}>~print~'(cut~and~pasted~from~interactive~Python~sessions)'\\
(cut~and~pasted~from~interactive~Python~sessions)
}
@@ -1512,7 +1512,7 @@ body row 3
\item A language-switching role:
-Let’s count in German \otherlanguage{ngerman}{eins zwei drei}.
+Let’s count in German \foreignlanguage{ngerman}{eins zwei drei}.
\item A role with multiple class attributes, styled with raw directives:
@@ -1525,14 +1525,14 @@ The following works in most browsers but does not validate
\begin{quote}{\ttfamily \raggedright \noindent
..~raw::~html\\
~\\
-~~<style~type="text/css"><!-{}-\\
+~~<style~type=\textquotedbl{}text/css\textquotedbl{}><!-{}-\\
~~~.green~\{color:~green;\}\\
~~~.sc~\{font-variant:~small-caps;\}\\
~~~-{}-></style>
}
\end{quote}
-\otherlanguage{british}{\DUrole{green}{\DUrole{sc}{British colourful text in small-caps}}}.
+\foreignlanguage{british}{\DUrole{green}{\DUrole{sc}{British colourful text in small-caps}}}.
\end{itemize}
@@ -1821,7 +1821,7 @@ is contained in a quote
These are all ASCII characters except a-zA-Z0-9 and space:
-\texttt{!!!"{}"{}"\#\#\#\$\$\$\%\%\%\&\&\&'{}'{}'((()))***+++,{},{},-{}-{}-...///:::}
+\texttt{!!!\textquotedbl{}\textquotedbl{}\textquotedbl{}\#\#\#\$\$\$\%\%\%\&\&\&'{}'{}'((()))***+++,{},{},-{}-{}-...///:::}
\texttt{;;;<{}<{}<===>{}>{}>???@@@{[}{[}{[}\textbackslash{}\textbackslash{}\textbackslash{}{]}{]}{]}\textasciicircum{}\textasciicircum{}\textasciicircum{}\_\_\_`{}`{}`\{\{\{|||\}\}\}\textasciitilde{}\textasciitilde{}\textasciitilde{}}
@@ -2521,7 +2521,7 @@ section, “Docutils System Messages”:
{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~104
\hyperlink{id28}{
-Undefined substitution referenced: "problematic".
+Undefined substitution referenced: \textquotedbl{}problematic\textquotedbl{}.
}}
\DUadmonition[system-message]{
@@ -2531,7 +2531,7 @@ Undefined substitution referenced: "problematic".
{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~391
\hyperlink{id46}{
-Unknown target name: "5".
+Unknown target name: \textquotedbl{}5\textquotedbl{}.
}}
\DUadmonition[system-message]{
@@ -2541,7 +2541,7 @@ Unknown target name: "5".
{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~400
\hyperlink{id48}{
-Unknown target name: "nonexistent".
+Unknown target name: \textquotedbl{}nonexistent\textquotedbl{}.
}}
\DUadmonition[system-message]{
@@ -2551,7 +2551,7 @@ Unknown target name: "nonexistent".
{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~427
\hyperlink{id50}{
-Unknown target name: "hyperlink reference without a target".
+Unknown target name: \textquotedbl{}hyperlink reference without a target\textquotedbl{}.
}}
\DUadmonition[system-message]{
@@ -2561,7 +2561,7 @@ Unknown target name: "hyperlink reference without a target".
{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~440
\hyperlink{id52}{
-Duplicate target name, cannot be used as a unique reference: "duplicate target names".
+Duplicate target name, cannot be used as a unique reference: \textquotedbl{}duplicate target names\textquotedbl{}.
}}
\end{document}
diff --git a/test/functional/expected/standalone_rst_xetex.tex b/test/functional/expected/standalone_rst_xetex.tex
index 0876e9bce..fc9a4768e 100644
--- a/test/functional/expected/standalone_rst_xetex.tex
+++ b/test/functional/expected/standalone_rst_xetex.tex
@@ -28,7 +28,7 @@
% Linux Libertine (free, wide coverage, not only for Linux)
\setmainfont{Linux Libertine O}
\setsansfont{Linux Biolinum O}
-\setmonofont[HyphenChar=None]{DejaVu Sans Mono}
+\setmonofont[HyphenChar=None,Scale=MatchLowercase]{DejaVu Sans Mono}
%%% User specified packages and stylesheets
@@ -358,7 +358,7 @@ reference to the \hyperref[doctitle]{doctitle} and the \hyperref[subtitle]{subti
The default role for interpreted text is \DUroletitlereference{Title Reference}. Here are
some explicit interpreted text roles: a PEP reference (\href{http://www.python.org/dev/peps/pep-0287}{PEP 287}); an
RFC reference (\href{http://www.faqs.org/rfcs/rfc2822.html}{RFC 2822}); an abbreviation (\DUrole{abbreviation}{abb.}), an acronym
-(\DUrole{acronym}{reST}), code (\texttt{\DUrole{code}{print "hello world"}}); a \textsubscript{subscript};
+(\DUrole{acronym}{reST}), code (\texttt{\DUrole{code}{print \textquotedbl{}hello world\textquotedbl{}}}); a \textsubscript{subscript};
a \textsuperscript{superscript} and explicit roles for \DUroletitlereference{Docutils}’
\emph{standard} \textbf{inline} \texttt{markup}.
@@ -700,7 +700,7 @@ A line block, like the following poem by Christian Morgenstern, can
also be centre-aligned:
\begin{DUlineblock}{0em}
-\otherlanguage{german}{\DUrole{align-center}{
+\foreignlanguage{german}{\DUrole{align-center}{
\item[] \textbf{Die Trichter}
\item[]
\item[] Zwei Trichter wandeln durch die Nacht.
@@ -741,7 +741,7 @@ a class attribute:
%
%
\begin{quote}
-\otherlanguage{french}{
+\foreignlanguage{french}{
ReStructuredText est un langage de balisage léger utilisé
notamment dans la documentation du langage Python.
}
@@ -753,8 +753,8 @@ notamment dans la documentation du langage Python.
}
%
\begin{quote}{\ttfamily \raggedright \noindent
->>>~print~'Python-specific~usage~examples;~begun~with~">>>"'\\
-Python-specific~usage~examples;~begun~with~">>>"\\
+>>>~print~'Python-specific~usage~examples;~begun~with~\textquotedbl{}>>>\textquotedbl{}'\\
+Python-specific~usage~examples;~begun~with~\textquotedbl{}>>>\textquotedbl{}\\
>>>~print~'(cut~and~pasted~from~interactive~Python~sessions)'\\
(cut~and~pasted~from~interactive~Python~sessions)
}
@@ -1511,7 +1511,7 @@ body row 3
\item A language-switching role:
-Let’s count in German \otherlanguage{german}{eins zwei drei}.
+Let’s count in German \foreignlanguage{german}{eins zwei drei}.
\item A role with multiple class attributes, styled with raw directives:
@@ -1524,14 +1524,14 @@ The following works in most browsers but does not validate
\begin{quote}{\ttfamily \raggedright \noindent
..~raw::~html\\
~\\
-~~<style~type="text/css"><!--\\
+~~<style~type=\textquotedbl{}text/css\textquotedbl{}><!--\\
~~~.green~\{color:~green;\}\\
~~~.sc~\{font-variant:~small-caps;\}\\
~~~--></style>
}
\end{quote}
-\otherlanguage{british}{\DUrole{green}{\DUrole{sc}{British colourful text in small-caps}}}.
+\foreignlanguage{british}{\DUrole{green}{\DUrole{sc}{British colourful text in small-caps}}}.
\end{itemize}
@@ -1632,7 +1632,7 @@ is contained in a quote
These are all ASCII characters except a-zA-Z0-9 and space:
-\texttt{!!!"""\#\#\#\$\$\$\%\%\%\&\&\&'''((()))***+++,,,---...///:::}
+\texttt{!!!\textquotedbl{}\textquotedbl{}\textquotedbl{}\#\#\#\$\$\$\%\%\%\&\&\&'''((()))***+++,,,---...///:::}
\texttt{;;;<<<===>>>???@@@{[}{[}{[}\textbackslash{}\textbackslash{}\textbackslash{}{]}{]}{]}\textasciicircum{}\textasciicircum{}\textasciicircum{}\_\_\_```\{\{\{|||\}\}\}\textasciitilde{}\textasciitilde{}\textasciitilde{}}
@@ -2344,7 +2344,7 @@ section, “Docutils System Messages”:
{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~104
\hyperlink{id28}{
-Undefined substitution referenced: "problematic".
+Undefined substitution referenced: \textquotedbl{}problematic\textquotedbl{}.
}}
\DUadmonition[system-message]{
@@ -2354,7 +2354,7 @@ Undefined substitution referenced: "problematic".
{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~391
\hyperlink{id45}{
-Unknown target name: "5".
+Unknown target name: \textquotedbl{}5\textquotedbl{}.
}}
\DUadmonition[system-message]{
@@ -2364,7 +2364,7 @@ Unknown target name: "5".
{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~400
\hyperlink{id47}{
-Unknown target name: "nonexistent".
+Unknown target name: \textquotedbl{}nonexistent\textquotedbl{}.
}}
\DUadmonition[system-message]{
@@ -2374,7 +2374,7 @@ Unknown target name: "nonexistent".
{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~427
\hyperlink{id49}{
-Unknown target name: "hyperlink reference without a target".
+Unknown target name: \textquotedbl{}hyperlink reference without a target\textquotedbl{}.
}}
\DUadmonition[system-message]{
@@ -2384,7 +2384,7 @@ Unknown target name: "hyperlink reference without a target".
{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~440
\hyperlink{id51}{
-Duplicate target name, cannot be used as a unique reference: "duplicate target names".
+Duplicate target name, cannot be used as a unique reference: \textquotedbl{}duplicate target names\textquotedbl{}.
}}
\end{document}
diff --git a/test/functional/expected/xetex-cyrillic.tex b/test/functional/expected/xetex-cyrillic.tex
index 945dad910..e711374c0 100644
--- a/test/functional/expected/xetex-cyrillic.tex
+++ b/test/functional/expected/xetex-cyrillic.tex
@@ -13,7 +13,7 @@
% Linux Libertine (free, wide coverage, not only for Linux)
\setmainfont{Linux Libertine O}
\setsansfont{Linux Biolinum O}
-\setmonofont[HyphenChar=None]{DejaVu Sans Mono}
+\setmonofont[HyphenChar=None,Scale=MatchLowercase]{DejaVu Sans Mono}
%%% User specified packages and stylesheets
@@ -37,28 +37,28 @@
\label{id1}%
}
-первый пример: "Здравствуй, мир!"
+первый пример: «Здравствуй, мир!»
\section{Title%
\label{title}%
}
-\otherlanguage{english}{first example: "Hello world".}
+\foreignlanguage{english}{first example: “Hello world”.}
\section{Notes%
\label{notes}%
}
-This example tests rendering of Latin and Cyrillic characters by the LaTeX
+\foreignlanguage{english}{This example tests rendering of Latin and Cyrillic characters by the LaTeX
and XeTeX writers. Check the compiled PDF for garbage characters in text and
-bookmarks.
+bookmarks.}
-To work around a problem with Cyrillic in PDF-bookmarks in \DUroletitlereference{hyperref}
+\foreignlanguage{english}{To work around a problem with Cyrillic in PDF-bookmarks in \DUroletitlereference{hyperref}
versions older than v6.79g 2009/11/20, the test caller \texttt{latex\_cyrillic.py}
sets \texttt{hyperref\_options} to \texttt{'unicode=true'} while \texttt{xetex\_cyrillic.py}
sets it to \texttt{'unicode=false'}. The recommended option for current
-(2011-08-24) hyperref versions is \texttt{'pdfencoding=auto'}.
+(2011-08-24) hyperref versions is \texttt{'pdfencoding=auto'}.}
\end{document}
diff --git a/test/functional/input/cyrillic.txt b/test/functional/input/cyrillic.txt
index 2696522ff..38de95383 100644
--- a/test/functional/input/cyrillic.txt
+++ b/test/functional/input/cyrillic.txt
@@ -10,15 +10,17 @@ Title
first example: "Hello world".
-.. class:: language-en
-
Notes
-----
+.. class:: language-en
+
This example tests rendering of Latin and Cyrillic characters by the LaTeX
and XeTeX writers. Check the compiled PDF for garbage characters in text and
bookmarks.
+.. class:: language-en
+
To work around a problem with Cyrillic in PDF-bookmarks in `hyperref`
versions older than v6.79g 2009/11/20, the test caller ``latex_cyrillic.py``
sets ``hyperref_options`` to ``'unicode=true'`` while ``xetex_cyrillic.py``
diff --git a/test/functional/input/latex_babel.txt b/test/functional/input/latex_babel.txt
new file mode 100644
index 000000000..b749ab69b
--- /dev/null
+++ b/test/functional/input/latex_babel.txt
@@ -0,0 +1,36 @@
+The babel_ package introduces the concept of "shorthands": additional
+characters that introduce a latex macro. Most common is the active double
+quote ("). Problematic is the tilde character (~) which is regularely used
+for no-break spaces but redefined by some language definition files:
+
+English: 'an' "active"-quote, ^circumflex, and no-break spaces
+
+.. class:: language-eu
+
+Basque: 'an' "active"-quote, ^circumflex, and no-break spaces
+
+.. class:: language-eo
+
+Esperanto: 'an' "active"-quote, ^circumflex, and no-break spaces
+
+.. class:: language-et
+
+Estonian: 'an' "active"-quote, ^circumflex, and no-break spaces
+
+.. class:: language-gl
+
+Galician: 'an' "active"-quote, ^circumflex, and no-break spaces
+
+.. class:: language-de
+
+German: 'an' "active"-quote, ^circumflex, and no-break spaces
+
+Spanish: option clash with Galician!
+
+..
+ .. class:: language-es
+
+ Spanish: 'an' "active"-quote, ^circumflex, and no-break spaces
+
+
+.. _babel: http://www.ctan.org/packages/babel
diff --git a/test/functional/tests/latex_babel.py b/test/functional/tests/latex_babel.py
new file mode 100644
index 000000000..de109b71e
--- /dev/null
+++ b/test/functional/tests/latex_babel.py
@@ -0,0 +1,10 @@
+# Source and destination file names.
+test_source = "latex_babel.txt"
+test_destination = "latex_babel.tex"
+
+# Keyword parameters passed to publish_file.
+reader_name = "standalone"
+parser_name = "rst"
+writer_name = "latex"
+
+# Extra setting we need
diff --git a/test/functional/tests/latex_cyrillic.py b/test/functional/tests/latex_cyrillic.py
index 9003f1d4f..13dc7a496 100644
--- a/test/functional/tests/latex_cyrillic.py
+++ b/test/functional/tests/latex_cyrillic.py
@@ -13,3 +13,6 @@ settings_overrides['hyperref_options'] = 'unicode=true'
settings_overrides['font_encoding'] = 'T1,T2A'
settings_overrides['stylesheet'] = 'cmlgc'
settings_overrides['language_code'] = 'ru'
+
+# use "smartquotes" transition:
+settings_overrides['smart_quotes'] = True
diff --git a/test/functional/tests/xetex_cyrillic.py b/test/functional/tests/xetex_cyrillic.py
index f301ad564..7cc0533c6 100644
--- a/test/functional/tests/xetex_cyrillic.py
+++ b/test/functional/tests/xetex_cyrillic.py
@@ -11,3 +11,5 @@ settings_overrides['language_code'] = 'ru'
# language to work around a problem with cyrillic in PDF-bookmarks in
# hyperref versions < v6.79g 2009/11/20
settings_overrides['hyperref_options'] = 'unicode=false'
+# use "smartquotes" transition:
+settings_overrides['smart_quotes'] = True
diff --git a/test/test_writers/test_latex2e.py b/test/test_writers/test_latex2e.py
index a45366931..d7b6223f8 100755
--- a/test/test_writers/test_latex2e.py
+++ b/test/test_writers/test_latex2e.py
@@ -116,9 +116,9 @@ r"""\usepackage{ifthen}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[spanish,english]{babel}
-\addto\shorthandsspanish{\spanishdeactivate{."~<>}}
+\AtBeginDocument{\shorthandoff{.<>}}
""")) + r"""
-Und damit \otherlanguage{spanish}{basta}!
+Und damit \foreignlanguage{spanish}{basta}!
\end{document}
"""],
@@ -605,7 +605,6 @@ two stylesheets embedded in the header
"""],
]
-
if __name__ == '__main__':
import unittest
unittest.main(defaultTest='suite')