diff options
| author | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2013-01-04 17:17:38 +0000 |
|---|---|---|
| committer | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2013-01-04 17:17:38 +0000 |
| commit | eb61ea089f3e22e8540e046a1f2c3a3000ea3dd2 (patch) | |
| tree | d3976d266a38bf963b16a3dfcd728db767db3640 /docutils | |
| parent | 0c2338b73d9e01087c8fdd96c98e2321dac66d88 (diff) | |
| download | docutils-eb61ea089f3e22e8540e046a1f2c3a3000ea3dd2.tar.gz | |
smartquotes: Skip emtpy text tokens without updating the last character.
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@7585 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils')
| -rw-r--r-- | docutils/docutils/transforms/universal.py | 2 | ||||
| -rw-r--r-- | docutils/docutils/utils/smartquotes.py | 9 | ||||
| -rw-r--r-- | docutils/test/test_transforms/test_smartquotes.py | 16 |
3 files changed, 20 insertions, 7 deletions
diff --git a/docutils/docutils/transforms/universal.py b/docutils/docutils/transforms/universal.py index 75a47fcd6..76f08db02 100644 --- a/docutils/docutils/transforms/universal.py +++ b/docutils/docutils/transforms/universal.py @@ -261,7 +261,7 @@ class SmartQuotes(Transform): if not isinstance(txtnode.parent, nodes.option_string)] - # language: use smart-quotes for language "lang" + # language: use typographical quotes for language "lang" lang = node.get_language_code(document_language) # use alternative form if `smart-quotes` setting starts with "alt": if alternative: diff --git a/docutils/docutils/utils/smartquotes.py b/docutils/docutils/utils/smartquotes.py index e5deea3ac..b5449fd5f 100644 --- a/docutils/docutils/utils/smartquotes.py +++ b/docutils/docutils/utils/smartquotes.py @@ -382,7 +382,7 @@ class smartchars(object): # For other languages see: # http://en.wikipedia.org/wiki/Non-English_usage_of_quotation_marks # http://de.wikipedia.org/wiki/Anf%C3%BChrungszeichen#Andere_Sprachen - quotes = {'af': u'“”‘’', + quotes = {'af': u'“”‘’', 'af-x-altquot': u'„”‚’', 'ca': u'«»“”', 'ca-x-altquot': u'“”‘’', @@ -507,14 +507,15 @@ def educate_tokens(text_tokens, attr=default_smartypants_attr, language='en'): for (ttype, text) in text_tokens: - # skip HTML and/or XML tags (do not update last character) - if ttype == 'tag': + # skip HTML and/or XML tags as well as emtpy text tokens + # without updating the last character + if ttype == 'tag' or not text: yield text continue # skip literal text (math, literal, raw, ...) if ttype == 'literal': - prev_token_last_char = text[-1] + prev_token_last_char = text[-1:] yield text continue diff --git a/docutils/test/test_transforms/test_smartquotes.py b/docutils/test/test_transforms/test_smartquotes.py index 14332d2e1..3c059133a 100644 --- a/docutils/test/test_transforms/test_smartquotes.py +++ b/docutils/test/test_transforms/test_smartquotes.py @@ -95,9 +95,12 @@ u"""\ Quotes and inline-elements: * Around "_`targets`", "*emphasized*" or "``literal``" text - and links to "targets_". + and links to "targets_". * Inside *"emphasized"* or other `inline "roles"` + +Do not drop characters from intra-word inline markup like +*re*\ ``Structured``\ *Text*. """, u"""\ <document source="test data"> @@ -127,7 +130,16 @@ u"""\ “emphasized” or other \n\ <title_reference> - inline “roles”\ + inline “roles” + <paragraph> + Do not drop characters from intra-word inline markup like + <emphasis> + re + <literal> + Structured + <emphasis> + Text + .\ """], ["""\ .. class:: language-de |
