diff options
| -rw-r--r-- | docutils/HISTORY.txt | 1 | ||||
| -rw-r--r-- | docutils/docutils/utils/smartquotes.py | 5 | ||||
| -rw-r--r-- | docutils/test/test_transforms/test_smartquotes.py | 66 |
3 files changed, 71 insertions, 1 deletions
diff --git a/docutils/HISTORY.txt b/docutils/HISTORY.txt index 541bb0cb9..0592fb18a 100644 --- a/docutils/HISTORY.txt +++ b/docutils/HISTORY.txt @@ -64,6 +64,7 @@ Changes Since 0.13.1 - New quote definitions for hr, hsb, hu, lv, sh, sl, sr. - Fix [ 313 ] Differentiate apostrophe from closing single quote (if possible). + - Fix [ 317 ] Extra space inserted with French smartquotes. * docutils/writers/_html_base.py diff --git a/docutils/docutils/utils/smartquotes.py b/docutils/docutils/utils/smartquotes.py index b07118edc..6fb54e4e0 100644 --- a/docutils/docutils/utils/smartquotes.py +++ b/docutils/docutils/utils/smartquotes.py @@ -588,7 +588,10 @@ def educate_tokens(text_tokens, attr=default_smartypants_attr, language='en'): text = educateSingleBackticks(text, language) if do_quotes: - text = educateQuotes(prev_token_last_char+text, language)[1:] + # Replace plain quotes to prevent converstion to + # 2-character sequence in French. + context = prev_token_last_char.replace('"',';').replace("'",';') + text = educateQuotes(context+text, language)[1:] if do_stupefy: text = stupefyEntities(text, language) diff --git a/docutils/test/test_transforms/test_smartquotes.py b/docutils/test/test_transforms/test_smartquotes.py index 4e5b4e53d..a16025213 100644 --- a/docutils/test/test_transforms/test_smartquotes.py +++ b/docutils/test/test_transforms/test_smartquotes.py @@ -153,6 +153,72 @@ u"""\ .\ """], ["""\ +Do not convert context-character at inline-tag boundaries +(in French, smart quotes expand to two characters). + +.. class:: language-fr-ch-x-altquot + + Around "_`targets`", "*emphasized*" or "``literal``" text + and links to "targets_". + + Inside *"emphasized"* or other `inline "roles"`: + (``"string"``), (``'string'``), *\\"betont\\"*, \\"*betont*". + + Do not drop characters from intra-word inline markup like + *re*\ ``Structured``\ *Text*. +""", +u"""\ +<document source="test data"> + <paragraph> + Do not convert context-character at inline-tag boundaries + (in French, smart quotes expand to two characters). + <paragraph classes="language-fr-ch-x-altquot"> + Around «\u202f + <target ids="targets" names="targets"> + targets + \u202f», «\u202f + <emphasis> + emphasized + \u202f» or «\u202f + <literal> + literal + \u202f» text + and links to «\u202f + <reference name="targets" refname="targets"> + targets + \u202f». + <paragraph classes="language-fr-ch-x-altquot"> + Inside \n\ + <emphasis> + «\u202femphasized\u202f» + or other \n\ + <title_reference> + inline «\u202froles\u202f» + : + ( + <literal> + "string" + ), ( + <literal> + 'string' + ), + <emphasis> + «\u202fbetont\u202f» + , «\u202f + <emphasis> + betont + \u202f». + <paragraph classes="language-fr-ch-x-altquot"> + Do not drop characters from intra-word inline markup like + <emphasis> + re + <literal> + Structured + <emphasis> + Text + . +"""], +["""\ .. class:: language-de German "smart quotes" and 'secondary smart quotes'. |
