From 0b938642e1cab1cd6606181f3213afdcc73f96be Mon Sep 17 00:00:00 2001 From: milde Date: Mon, 19 Dec 2016 20:51:23 +0000 Subject: [PATCH] Recognize non-ASCII whitespace around inline literal, target and substitution. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@8003 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/HISTORY.txt | 10 +++--- docutils/docutils/parsers/rst/states.py | 6 ++-- .../test_parsers/test_rst/test_inline_markup.py | 41 ++++++++++++++++++++++ 3 files changed, 50 insertions(+), 7 deletions(-) diff --git a/docutils/HISTORY.txt b/docutils/HISTORY.txt index 86d89eb43..7d9328a08 100644 --- a/docutils/HISTORY.txt +++ b/docutils/HISTORY.txt @@ -24,6 +24,8 @@ Changes Since 0.13.1 * docutils/parsers/rst/states.py: - Added functionality: escaped whitespace in URI contexts. + - Recognize non-ASCII whitespace around inline literal, target, + and substitution. * docutils/utils/__init__.py: @@ -42,10 +44,10 @@ Release 0.13.1 (2016-12-09) docutils/parsers/rst/languages/fa.py docutils/languages/la.py docutils/parsers/rst/languages/la.py: - + - Apply [ 133 ] Persian mappings by Shahin Azad. - Apply [ 135 ] Language modules for Latvian by Alexander Smishlajev - + * docutils/nodes.py - Fix [ 253 ] Attribute key without value not allowed in XML. @@ -93,7 +95,7 @@ Release 0.13.1 (2016-12-09) * docutils/writers/_html_base.py - New auxiliary module for definitions common to all HTML writers. - + * docutils/writers/html5_polyglot/ - New HTML writer generating clean, polyglot_ markup conforming to @@ -131,7 +133,7 @@ Release 0.13.1 (2016-12-09) - Fix [ 286 ] Empty column title cause invalid latex file. - Fix [ 224 ] Fix rowspan support for tables. - + - Let LaTeX determine the column widths in tables with "colwidths-auto". Not suited for with multi-paragraph cells! diff --git a/docutils/docutils/parsers/rst/states.py b/docutils/docutils/parsers/rst/states.py index d64ad588c..76a633cfe 100644 --- a/docutils/docutils/parsers/rst/states.py +++ b/docutils/docutils/parsers/rst/states.py @@ -541,12 +541,12 @@ class Inliner: $ # end of string """ % args, re.VERBOSE | re.UNICODE), literal=re.compile(self.non_whitespace_before + '(``)' - + end_string_suffix), + + end_string_suffix, re.UNICODE), target=re.compile(self.non_whitespace_escape_before - + r'(`)' + end_string_suffix), + + r'(`)' + end_string_suffix, re.UNICODE), substitution_ref=re.compile(self.non_whitespace_escape_before + r'(\|_{0,2})' - + end_string_suffix), + + end_string_suffix, re.UNICODE), email=re.compile(self.email_pattern % args + '$', re.VERBOSE | re.UNICODE), uri=re.compile( diff --git a/docutils/test/test_parsers/test_rst/test_inline_markup.py b/docutils/test/test_parsers/test_rst/test_inline_markup.py index 8c22e7f92..94292791a 100755 --- a/docutils/test/test_parsers/test_rst/test_inline_markup.py +++ b/docutils/test/test_parsers/test_rst/test_inline_markup.py @@ -1791,6 +1791,47 @@ u"""\ LINE SEPARATOR """], +[u"""\ +inline markup separated by non-ASCII whitespace +\xa0**NO-BREAK SPACE**\xa0, \xa0``NO-BREAK SPACE``\xa0, \xa0`NO-BREAK SPACE`\xa0, +\u2000**EN QUAD**\u2000, \u2000``EN QUAD``\u2000, \u2000`EN QUAD`\u2000, +\u202f**NARROW NBSP**\u202f, \u202f``NARROW NBSP``\u202f, \u202f`NARROW NBSP`\u202f, +""", +u"""\ + + + inline markup separated by non-ASCII whitespace + \xa0 + + NO-BREAK SPACE + \xa0, \xa0 + + NO-BREAK SPACE + \xa0, \xa0 + + NO-BREAK SPACE + \xa0, + \u2000 + + EN QUAD + \u2000, \u2000 + + EN QUAD + \u2000, \u2000 + + EN QUAD + \u2000, + \u202f + + NARROW NBSP + \u202f, \u202f + + NARROW NBSP + \u202f, \u202f + + NARROW NBSP + \u202f, +"""], # « * » ‹ * › « * » ‹ * › « * » ‹ * › French, [u"""\ "Quoted" markup start-string (matched openers & closers) -> no markup: -- 2.11.4.GIT