|
From: <mi...@us...> - 2018-01-16 13:31:00
|
Revision: 8212
http://sourceforge.net/p/docutils/code/8212
Author: milde
Date: 2018-01-16 13:30:57 +0000 (Tue, 16 Jan 2018)
Log Message:
-----------
Fix [ 251 ] system_message.copy() TypeError. Fix nodes.Element.copy()
Avoid clash with multiple values for keyword argument "rawsource".
Let nodes.Element.copy() also copy "document", "line",
and "source" attributes.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/nodes.py
trunk/docutils/test/test_nodes.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2018-01-14 17:37:13 UTC (rev 8211)
+++ trunk/docutils/HISTORY.txt 2018-01-16 13:30:57 UTC (rev 8212)
@@ -29,11 +29,13 @@
* docutils/nodes.py
- `Text.rstrip` and `Text.lstrip` now handle `rawsource` attribute.
-
+ - Fix [ 251 ] system_message.copy() TypeError.
+ Element.copy() also copies `document`, `line`, and `source` attributes.
+
* docutils/parsers/rst/states.py:
- Allow embedded colons in field list field names.
- - Add "rawsource" attribute for text of inline elements and definition
+ - Add `rawsource` attribute for text of inline elements and definition
list terms.
* docutils/parsers/rst/directives/html.py:
Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py 2018-01-14 17:37:13 UTC (rev 8211)
+++ trunk/docutils/docutils/nodes.py 2018-01-16 13:30:57 UTC (rev 8212)
@@ -1005,7 +1005,11 @@
for child in self.children])
def copy(self):
- return self.__class__(rawsource=self.rawsource, **self.attributes)
+ obj = self.__class__(rawsource=self.rawsource, **self.attributes)
+ obj.document = self.document
+ obj.source = self.source
+ obj.line = self.line
+ return obj
def deepcopy(self):
copy = self.copy()
@@ -1472,8 +1476,11 @@
self.current_line = offset + 1
def copy(self):
- return self.__class__(self.settings, self.reporter,
+ obj = self.__class__(self.settings, self.reporter,
**self.attributes)
+ obj.source = self.source
+ obj.line = self.line
+ return obj
def get_decoration(self):
if not self.decoration:
@@ -1672,11 +1679,12 @@
"""
def __init__(self, message=None, *children, **attributes):
+ rawsource = attributes.get('rawsource', '')
if message:
p = paragraph('', message)
children = (p,) + children
try:
- Element.__init__(self, '', *children, **attributes)
+ Element.__init__(self, rawsource, *children, **attributes)
except:
print 'system_message: children=%r' % (children,)
raise
@@ -1752,8 +1760,12 @@
for line in internals]))
def copy(self):
- return self.__class__(self.transform, self.details, self.rawsource,
+ obj = self.__class__(self.transform, self.details, self.rawsource,
**self.attributes)
+ obj.document = self.document
+ obj.source = self.source
+ obj.line = self.line
+ return obj
class raw(Special, Inline, PreBibliographic, FixedTextElement):
Modified: trunk/docutils/test/test_nodes.py
===================================================================
--- trunk/docutils/test/test_nodes.py 2018-01-14 17:37:13 UTC (rev 8211)
+++ trunk/docutils/test/test_nodes.py 2018-01-16 13:30:57 UTC (rev 8212)
@@ -616,6 +616,9 @@
self.assertEqual(e.rawsource, 'rawsource')
self.assertEqual(e_copy.rawsource, e.rawsource)
self.assertEqual(e_copy['att'], 'e')
+ self.assertEqual(e_copy.document, e.document)
+ self.assertEqual(e_copy.source, e.source)
+ self.assertEqual(e_copy.line, e.line)
# Children are not copied.
self.assertEqual(len(e_copy), 0)
# Deep copy:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2018-01-19 13:45:38
|
Revision: 8214
http://sourceforge.net/p/docutils/code/8214
Author: milde
Date: 2018-01-19 13:45:35 +0000 (Fri, 19 Jan 2018)
Log Message:
-----------
Drop empty lines in Text.pformat() and revert [r8194].
Keep "rawsource" attribute untouched in Text.rstrip() and
Text.lstrip().
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/nodes.py
trunk/docutils/test/test_nodes.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2018-01-16 20:43:16 UTC (rev 8213)
+++ trunk/docutils/HISTORY.txt 2018-01-19 13:45:35 UTC (rev 8214)
@@ -28,9 +28,8 @@
* docutils/nodes.py
- - `Text.rstrip` and `Text.lstrip` now handle `rawsource` attribute.
- Fix [ 251 ] system_message.copy() TypeError.
- Element.copy() also copies `document`, `line`, and `source` attributes.
+ - Element.copy() also copies `document`, `line`, and `source` attributes.
* docutils/parsers/rst/states.py:
Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py 2018-01-16 20:43:16 UTC (rev 8213)
+++ trunk/docutils/docutils/nodes.py 2018-01-19 13:45:35 UTC (rev 8214)
@@ -376,11 +376,11 @@
return self.copy()
def pformat(self, indent=' ', level=0):
- result = []
indent = indent * level
- for line in self.splitlines():
- result.append(indent + line + '\n')
- return ''.join(result)
+ lines = [indent+line for line in self.astext().splitlines()]
+ if not lines:
+ return ''
+ return '\n'.join(lines) + '\n'
# rstrip and lstrip are used by substitution definitions where
# they are expected to return a Text instance, this was formerly
@@ -387,14 +387,10 @@
# taken care of by UserString.
def rstrip(self, chars=None):
- node = self.__class__(reprunicode.rstrip(self, chars))
- node.rawsource = self.rawsource.rstrip((chars or ' \n\t\r')+'\\')
- return node
+ return self.__class__(reprunicode.rstrip(self, chars), self.rawsource)
+
def lstrip(self, chars=None):
- node = self.__class__(reprunicode.lstrip(self, chars))
- node.rawsource = re.sub(ur'^(\\?[%s])+'%(chars or ' \n\t\r'), u'',
- self.rawsource)
- return node
+ return self.__class__(reprunicode.lstrip(self, chars), self.rawsource)
class Element(Node):
Modified: trunk/docutils/test/test_nodes.py
===================================================================
--- trunk/docutils/test/test_nodes.py 2018-01-16 20:43:16 UTC (rev 8213)
+++ trunk/docutils/test/test_nodes.py 2018-01-19 13:45:35 UTC (rev 8214)
@@ -59,9 +59,7 @@
stripped = text.lstrip().rstrip()
stripped2 = text.lstrip(' wahn').rstrip(' wahn')
self.assertEqual(stripped, u'was noch')
- self.assertEqual(stripped.rawsource, u'\was\\ noch')
self.assertEqual(stripped2, u's noc')
- self.assertEqual(stripped2.rawsource, u's\\ noc')
def test_asciirestriction(self):
if sys.version_info < (3,):
@@ -606,14 +604,14 @@
return x not in self.testlist
def test_copy(self):
- grandchild = nodes.Text('rawsource')
- child = nodes.emphasis('rawsource', grandchild, att='child')
- e = nodes.Element('rawsource', child, att='e')
+ grandchild = nodes.Text('mytext')
+ child = nodes.emphasis('mytext', grandchild, att='child')
+ e = nodes.Element('mytext', child, att='e')
# Shallow copy:
e_copy = e.copy()
self.assertTrue(e is not e_copy)
# Internal attributes (like `rawsource`) are also copied.
- self.assertEqual(e.rawsource, 'rawsource')
+ self.assertEqual(e.rawsource, 'mytext')
self.assertEqual(e_copy.rawsource, e.rawsource)
self.assertEqual(e_copy['att'], 'e')
self.assertEqual(e_copy.document, e.document)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2018-06-05 13:38:10
|
Revision: 8217
http://sourceforge.net/p/docutils/code/8217
Author: milde
Date: 2018-06-05 13:38:08 +0000 (Tue, 05 Jun 2018)
Log Message:
-----------
Html5 writer: Correctly sort docinfo and subtitle into "parts" dict.
Modified Paths:
--------------
trunk/docutils/docutils/writers/_html_base.py
trunk/docutils/test/DocutilsTestSupport.py
trunk/docutils/test/functional/expected/standalone_rst_html5.html
Added Paths:
-----------
trunk/docutils/test/test_writers/test_html5_polyglot_parts.py
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2018-06-05 13:37:44 UTC (rev 8216)
+++ trunk/docutils/docutils/writers/_html_base.py 2018-06-05 13:38:08 UTC (rev 8217)
@@ -681,6 +681,7 @@
self.body.append('</dd>\n')
def visit_docinfo(self, node):
+ self.context.append(len(self.body))
classes = 'docinfo'
if (self.is_compactable(node)):
classes += ' simple'
@@ -688,6 +689,9 @@
def depart_docinfo(self, node):
self.body.append('</dl>\n')
+ start = self.context.pop()
+ self.docinfo = self.body[start:]
+ self.body = []
def visit_docinfo_item(self, node, name, meta=True):
if meta:
@@ -1403,7 +1407,7 @@
classes = 'sidebar-subtitle'
elif isinstance(node.parent, nodes.document):
classes = 'subtitle'
- self.in_document_title = len(self.body)
+ self.in_document_title = len(self.body)+1
elif isinstance(node.parent, nodes.section):
classes = 'section-subtitle'
self.body.append(self.starttag(node, 'p', '', CLASS=classes))
@@ -1410,7 +1414,7 @@
def depart_subtitle(self, node):
self.body.append('</p>\n')
- if self.in_document_title:
+ if isinstance(node.parent, nodes.document):
self.subtitle = self.body[self.in_document_title:-1]
self.in_document_title = 0
self.body_pre_docinfo.extend(self.body)
Modified: trunk/docutils/test/DocutilsTestSupport.py
===================================================================
--- trunk/docutils/test/DocutilsTestSupport.py 2018-06-05 13:37:44 UTC (rev 8216)
+++ trunk/docutils/test/DocutilsTestSupport.py 2018-06-05 13:38:08 UTC (rev 8217)
@@ -757,28 +757,6 @@
writer_name=self.writer_name)
-class HtmlPublishPartsTestSuite(CustomTestSuite):
-
- def generateTests(self, dict, dictname='totest'):
- for name, (settings_overrides, cases) in dict.items():
- settings = self.suite_settings.copy()
- settings.update(settings_overrides)
- for casenum in range(len(cases)):
- case = cases[casenum]
- run_in_debugger = False
- if len(case)==3:
- if case[2]:
- run_in_debugger = True
- else:
- continue
- self.addTestCase(
- HtmlWriterPublishPartsTestCase, 'test_publish',
- input=case[0], expected=case[1],
- id='%s[%r][%s]' % (dictname, name, casenum),
- run_in_debugger=run_in_debugger,
- suite_settings=settings)
-
-
class HtmlWriterPublishPartsTestCase(WriterPublishTestCase):
"""
@@ -855,6 +833,29 @@
return '{' + ',\n '.join(output) + '}\n'
+class HtmlPublishPartsTestSuite(CustomTestSuite):
+
+ testcase_class = HtmlWriterPublishPartsTestCase
+
+ def generateTests(self, dict, dictname='totest'):
+ for name, (settings_overrides, cases) in dict.items():
+ settings = self.suite_settings.copy()
+ settings.update(settings_overrides)
+ for casenum in range(len(cases)):
+ case = cases[casenum]
+ run_in_debugger = False
+ if len(case)==3:
+ if case[2]:
+ run_in_debugger = True
+ else:
+ continue
+ self.addTestCase(self.testcase_class, 'test_publish',
+ input=case[0], expected=case[1],
+ id='%s[%r][%s]' % (dictname, name, casenum),
+ run_in_debugger=run_in_debugger,
+ suite_settings=settings)
+
+
def exception_data(func, *args, **kwds):
"""
Execute `func(*args, **kwds)` and return the resulting exception, the
Modified: trunk/docutils/test/functional/expected/standalone_rst_html5.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html5.html 2018-06-05 13:37:44 UTC (rev 8216)
+++ trunk/docutils/test/functional/expected/standalone_rst_html5.html 2018-06-05 13:38:08 UTC (rev 8217)
@@ -26,7 +26,6 @@
<div class="document" id="restructuredtext-test-document">
<span id="doctitle"></span>
<h1 class="title">reStructuredText Test Document</h1>
-
<p class="subtitle" id="examples-of-syntax-constructs"><span id="subtitle"></span>Examples of Syntax Constructs</p>
<dl class="docinfo">
<dt class="author">Author</dt>
Added: trunk/docutils/test/test_writers/test_html5_polyglot_parts.py
===================================================================
--- trunk/docutils/test/test_writers/test_html5_polyglot_parts.py (rev 0)
+++ trunk/docutils/test/test_writers/test_html5_polyglot_parts.py 2018-06-05 13:38:08 UTC (rev 8217)
@@ -0,0 +1,450 @@
+#! /usr/bin/env python
+
+# $Id$
+# Author: reggie dugard <re...@us...>
+# Copyright: This module has been placed in the public domain.
+
+"""
+Test for fragment code in HTML writer.
+
+Note: the 'body' and 'whole' entries have been removed from the parts
+dictionaries (redundant), along with 'meta' and 'stylesheet' entries with
+standard values, and any entries with empty values.
+"""
+
+from __init__ import DocutilsTestSupport
+from DocutilsTestSupport import (HtmlWriterPublishPartsTestCase,
+ HtmlPublishPartsTestSuite)
+from docutils import core, __version__
+
+
+class Html5WriterPublishPartsTestCase(HtmlWriterPublishPartsTestCase):
+ """Test case for HTML5 writer via the publish_parts interface."""
+
+ writer_name = 'html5'
+ standard_content_type_template = ('<meta charset="%s"/>\n')
+ standard_generator_template = (
+ '<meta name="generator"'
+ ' content="Docutils %s: http://docutils.sourceforge.net/" />\n')
+ standard_html_meta_value = (standard_content_type_template
+ + standard_generator_template % __version__)
+ standard_meta_value = standard_html_meta_value % 'utf-8'
+ standard_html_prolog = '<!DOCTYPE html>\n'
+
+class Html5PublishPartsTestSuite(HtmlPublishPartsTestSuite):
+
+ testcase_class = Html5WriterPublishPartsTestCase
+
+
+def suite():
+ s = Html5PublishPartsTestSuite()
+ s.generateTests(totest)
+ return s
+
+
+totest = {}
+
+totest['Title promotion'] = ({'stylesheet_path': '',
+ 'embed_stylesheet': 0}, [
+["""\
+Simple String
+""",
+"""\
+{'fragment': '''<p>Simple String</p>\\n''',
+ 'html_body': '''<div class="document">
+<p>Simple String</p>
+</div>\\n''',
+ 'html_head': '''...<title><string></title>\\n'''}
+"""],
+["""\
+Simple String with *markup*
+""",
+"""\
+{'fragment': '''<p>Simple String with <em>markup</em></p>\\n''',
+ 'html_body': '''<div class="document">
+<p>Simple String with <em>markup</em></p>
+</div>\\n''',
+ 'html_head': '''...<title><string></title>\\n'''}
+"""],
+["""\
+Simple String with an even simpler ``inline literal``
+""",
+"""\
+{'fragment': '''<p>Simple String with an even simpler <span class="docutils literal">inline literal</span></p>\\n''',
+ 'html_body': '''<div class="document">
+<p>Simple String with an even simpler <span class="docutils literal">inline literal</span></p>
+</div>\\n''',
+ 'html_head': '''...<title><string></title>\\n'''}
+"""],
+["""\
+A simple `anonymous reference`__
+
+__ http://www.test.com/test_url
+""",
+"""\
+{'fragment': '''<p>A simple <a class="reference external" href="http://www.test.com/test_url">anonymous reference</a></p>\\n''',
+ 'html_body': '''<div class="document">
+<p>A simple <a class="reference external" href="http://www.test.com/test_url">anonymous reference</a></p>
+</div>\\n''',
+ 'html_head': '''...<title><string></title>\\n'''}
+"""],
+["""\
+One paragraph.
+
+Two paragraphs.
+""",
+"""\
+{'fragment': '''<p>One paragraph.</p>
+<p>Two paragraphs.</p>\\n''',
+ 'html_body': '''<div class="document">
+<p>One paragraph.</p>
+<p>Two paragraphs.</p>
+</div>\\n''',
+ 'html_head': '''...<title><string></title>\\n'''}
+"""],
+["""\
+A simple `named reference`_ with stuff in between the
+reference and the target.
+
+.. _`named reference`: http://www.test.com/test_url
+""",
+"""\
+{'fragment': '''<p>A simple <a class="reference external" href="http://www.test.com/test_url">named reference</a> with stuff in between the
+reference and the target.</p>\\n''',
+ 'html_body': '''<div class="document">
+<p>A simple <a class="reference external" href="http://www.test.com/test_url">named reference</a> with stuff in between the
+reference and the target.</p>
+</div>\\n''',
+ 'html_head': '''...<title><string></title>\\n'''}
+"""],
+["""\
++++++
+Title
++++++
+
+Subtitle
+========
+
+Some stuff
+
+Section
+-------
+
+Some more stuff
+
+Another Section
+...............
+
+And even more stuff
+""",
+"""\
+{'fragment': '''<p>Some stuff</p>
+<div class="section" id="section">
+<h1>Section</h1>
+<p>Some more stuff</p>
+<div class="section" id="another-section">
+<h2>Another Section</h2>
+<p>And even more stuff</p>
+</div>
+</div>\\n''',
+ 'html_body': '''<div class="document" id="title">
+<h1 class="title">Title</h1>
+<p class="subtitle" id="subtitle">Subtitle</p>
+<p>Some stuff</p>
+<div class="section" id="section">
+<h1>Section</h1>
+<p>Some more stuff</p>
+<div class="section" id="another-section">
+<h2>Another Section</h2>
+<p>And even more stuff</p>
+</div>
+</div>
+</div>\\n''',
+ 'html_head': '''...<title>Title</title>\\n''',
+ 'html_subtitle': '''<p class="subtitle" id="subtitle">Subtitle</p>\\n''',
+ 'html_title': '''<h1 class="title">Title</h1>\\n''',
+ 'subtitle': '''Subtitle''',
+ 'title': '''Title'''}
+"""],
+["""\
++++++
+Title
++++++
+
+:author: me
+
+Some stuff
+""",
+"""\
+{'docinfo': '''<dl class="docinfo simple">
+<dt class="author">Author</dt>
+<dd class="author"><p>me</p></dd>
+</dl>\\n''',
+ 'fragment': '''<p>Some stuff</p>\\n''',
+ 'html_body': '''<div class="document" id="title">
+<h1 class="title">Title</h1>
+<dl class="docinfo simple">
+<dt class="author">Author</dt>
+<dd class="author"><p>me</p></dd>
+</dl>
+<p>Some stuff</p>
+</div>\\n''',
+ 'html_head': '''...<title>Title</title>
+<meta name="author" content="me" />\\n''',
+ 'html_title': '''<h1 class="title">Title</h1>\\n''',
+ 'meta': '''<meta name="author" content="me" />\\n''',
+ 'title': '''Title'''}
+"""]
+])
+
+totest['No title promotion'] = ({'doctitle_xform' : 0,
+ 'stylesheet_path': '',
+ 'embed_stylesheet': 0}, [
+["""\
+Simple String
+""",
+"""\
+{'fragment': '''<p>Simple String</p>\\n''',
+ 'html_body': '''<div class="document">
+<p>Simple String</p>
+</div>\\n''',
+ 'html_head': '''...<title><string></title>\\n'''}
+"""],
+["""\
+Simple String with *markup*
+""",
+"""\
+{'fragment': '''<p>Simple String with <em>markup</em></p>\\n''',
+ 'html_body': '''<div class="document">
+<p>Simple String with <em>markup</em></p>
+</div>\\n''',
+ 'html_head': '''...<title><string></title>\\n'''}
+"""],
+["""\
+Simple String with an even simpler ``inline literal``
+""",
+"""\
+{'fragment': '''<p>Simple String with an even simpler <span class="docutils literal">inline literal</span></p>\\n''',
+ 'html_body': '''<div class="document">
+<p>Simple String with an even simpler <span class="docutils literal">inline literal</span></p>
+</div>\\n''',
+ 'html_head': '''...<title><string></title>\\n'''}
+"""],
+["""\
+A simple `anonymous reference`__
+
+__ http://www.test.com/test_url
+""",
+"""\
+{'fragment': '''<p>A simple <a class="reference external" href="http://www.test.com/test_url">anonymous reference</a></p>\\n''',
+ 'html_body': '''<div class="document">
+<p>A simple <a class="reference external" href="http://www.test.com/test_url">anonymous reference</a></p>
+</div>\\n''',
+ 'html_head': '''...<title><string></title>\\n'''}
+"""],
+["""\
+A simple `named reference`_ with stuff in between the
+reference and the target.
+
+.. _`named reference`: http://www.test.com/test_url
+""",
+"""\
+{'fragment': '''<p>A simple <a class="reference external" href="http://www.test.com/test_url">named reference</a> with stuff in between the
+reference and the target.</p>\\n''',
+ 'html_body': '''<div class="document">
+<p>A simple <a class="reference external" href="http://www.test.com/test_url">named reference</a> with stuff in between the
+reference and the target.</p>
+</div>\\n''',
+ 'html_head': '''...<title><string></title>\\n'''}
+"""],
+["""\
++++++
+Title
++++++
+
+Not A Subtitle
+==============
+
+Some stuff
+
+Section
+-------
+
+Some more stuff
+
+Another Section
+...............
+
+And even more stuff
+""",
+"""\
+{'fragment': '''<div class="section" id="title">
+<h1>Title</h1>
+<div class="section" id="not-a-subtitle">
+<h2>Not A Subtitle</h2>
+<p>Some stuff</p>
+<div class="section" id="section">
+<h3>Section</h3>
+<p>Some more stuff</p>
+<div class="section" id="another-section">
+<h4>Another Section</h4>
+<p>And even more stuff</p>
+</div>
+</div>
+</div>
+</div>\\n''',
+ 'html_body': '''<div class="document">
+<div class="section" id="title">
+<h1>Title</h1>
+<div class="section" id="not-a-subtitle">
+<h2>Not A Subtitle</h2>
+<p>Some stuff</p>
+<div class="section" id="section">
+<h3>Section</h3>
+<p>Some more stuff</p>
+<div class="section" id="another-section">
+<h4>Another Section</h4>
+<p>And even more stuff</p>
+</div>
+</div>
+</div>
+</div>
+</div>\\n''',
+ 'html_head': '''...<title><string></title>\\n'''}
+"""],
+["""\
+* bullet
+* list
+""",
+"""\
+{'fragment': '''<ul class="simple">
+<li><p>bullet</p></li>
+<li><p>list</p></li>
+</ul>\\n''',
+ 'html_body': '''<div class="document">
+<ul class="simple">
+<li><p>bullet</p></li>
+<li><p>list</p></li>
+</ul>
+</div>\\n''',
+ 'html_head': '''...<title><string></title>\\n'''}
+"""],
+["""\
+.. table::
+ :align: right
+
+ +-----+-----+
+ | 1 | 2 |
+ +-----+-----+
+ | 3 | 4 |
+ +-----+-----+
+""",
+"""\
+{'fragment': '''<table class="align-right">
+<colgroup>
+<col style="width: 50%%" />
+<col style="width: 50%%" />
+</colgroup>
+<tbody>
+<tr><td><p>1</p></td>
+<td><p>2</p></td>
+</tr>
+<tr><td><p>3</p></td>
+<td><p>4</p></td>
+</tr>
+</tbody>
+</table>\\n''',
+ 'html_body': '''<div class="document">
+<table class="align-right">
+<colgroup>
+<col style="width: 50%%" />
+<col style="width: 50%%" />
+</colgroup>
+<tbody>
+<tr><td><p>1</p></td>
+<td><p>2</p></td>
+</tr>
+<tr><td><p>3</p></td>
+<td><p>4</p></td>
+</tr>
+</tbody>
+</table>
+</div>\\n''',
+ 'html_head': '''...<title><string></title>\\n'''}
+"""],
+["""\
+Not a docinfo.
+
+:This: .. _target:
+
+ is
+:a:
+:simple:
+:field: list
+""",
+"""\
+{'fragment': '''<p>Not a docinfo.</p>
+<dl class="field-list simple">
+<dt>This</dt>
+<dd><p id="target">is</p>
+</dd>
+<dt>a</dt>
+<dd><p></p></dd>
+<dt>simple</dt>
+<dd><p></p></dd>
+<dt>field</dt>
+<dd><p>list</p>
+</dd>
+</dl>\\n''',
+ 'html_body': '''<div class="document">
+<p>Not a docinfo.</p>
+<dl class="field-list simple">
+<dt>This</dt>
+<dd><p id="target">is</p>
+</dd>
+<dt>a</dt>
+<dd><p></p></dd>
+<dt>simple</dt>
+<dd><p></p></dd>
+<dt>field</dt>
+<dd><p>list</p>
+</dd>
+</dl>
+</div>\\n''',
+ 'html_head': '''...<title><string></title>\\n'''}
+"""],
+["""\
+Not a docinfo.
+
+:This is: a
+:simple field list with loooong field: names
+""",
+"""\
+{'fragment': '''<p>Not a docinfo.</p>
+<dl class="field-list simple">
+<dt>This is</dt>
+<dd><p>a</p>
+</dd>
+<dt>simple field list with loooong field</dt>
+<dd><p>names</p>
+</dd>
+</dl>\\n''',
+ 'html_body': '''<div class="document">
+<p>Not a docinfo.</p>
+<dl class="field-list simple">
+<dt>This is</dt>
+<dd><p>a</p>
+</dd>
+<dt>simple field list with loooong field</dt>
+<dd><p>names</p>
+</dd>
+</dl>
+</div>\\n''',
+ 'html_head': '''...<title><string></title>\\n'''}
+"""],
+])
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
Property changes on: trunk/docutils/test/test_writers/test_html5_polyglot_parts.py
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2018-06-05 13:38:26
|
Revision: 8218
http://sourceforge.net/p/docutils/code/8218
Author: milde
Date: 2018-06-05 13:38:25 +0000 (Tue, 05 Jun 2018)
Log Message:
-----------
latex writer: fix fallback definition of \DUroles macro.
Modified Paths:
--------------
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/test/functional/expected/latex_literal_block.tex
trunk/docutils/test/functional/expected/latex_literal_block_fancyvrb.tex
trunk/docutils/test/functional/expected/latex_literal_block_listings.tex
trunk/docutils/test/functional/expected/latex_literal_block_verbatim.tex
trunk/docutils/test/functional/expected/latex_literal_block_verbatimtab.tex
trunk/docutils/test/functional/expected/standalone_rst_latex.tex
trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
trunk/docutils/test/test_writers/test_latex2e.py
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2018-06-05 13:38:08 UTC (rev 8217)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2018-06-05 13:38:25 UTC (rev 8218)
@@ -565,11 +565,15 @@
% inline markup (custom roles)
% \DUrole{#1}{#2} tries \DUrole#1{#2}
\providecommand*{\DUrole}[2]{%
- % backwards compatibility: try \docutilsrole#1{#2}
- \ifcsname docutilsrole#1\endcsname%
- \csname docutilsrole#1\endcsname{#2}%
+ \ifcsname DUrole#1\endcsname%
+ \csname DUrole#1\endcsname{#2}%
\else
- \csname DUrole#1\endcsname{#2}%
+ % backwards compatibility: try \docutilsrole#1{#2}
+ \ifcsname docutilsrole#1\endcsname%
+ \csname docutilsrole#1\endcsname{#2}%
+ \else%
+ #2%
+ \fi%
\fi%
}"""
Modified: trunk/docutils/test/functional/expected/latex_literal_block.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_literal_block.tex 2018-06-05 13:38:08 UTC (rev 8217)
+++ trunk/docutils/test/functional/expected/latex_literal_block.tex 2018-06-05 13:38:25 UTC (rev 8218)
@@ -47,11 +47,15 @@
% inline markup (custom roles)
% \DUrole{#1}{#2} tries \DUrole#1{#2}
\providecommand*{\DUrole}[2]{%
- % backwards compatibility: try \docutilsrole#1{#2}
- \ifcsname docutilsrole#1\endcsname%
- \csname docutilsrole#1\endcsname{#2}%
+ \ifcsname DUrole#1\endcsname%
+ \csname DUrole#1\endcsname{#2}%
\else
- \csname DUrole#1\endcsname{#2}%
+ % backwards compatibility: try \docutilsrole#1{#2}
+ \ifcsname docutilsrole#1\endcsname%
+ \csname docutilsrole#1\endcsname{#2}%
+ \else%
+ #2%
+ \fi%
\fi%
}
Modified: trunk/docutils/test/functional/expected/latex_literal_block_fancyvrb.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_literal_block_fancyvrb.tex 2018-06-05 13:38:08 UTC (rev 8217)
+++ trunk/docutils/test/functional/expected/latex_literal_block_fancyvrb.tex 2018-06-05 13:38:25 UTC (rev 8218)
@@ -47,11 +47,15 @@
% inline markup (custom roles)
% \DUrole{#1}{#2} tries \DUrole#1{#2}
\providecommand*{\DUrole}[2]{%
- % backwards compatibility: try \docutilsrole#1{#2}
- \ifcsname docutilsrole#1\endcsname%
- \csname docutilsrole#1\endcsname{#2}%
+ \ifcsname DUrole#1\endcsname%
+ \csname DUrole#1\endcsname{#2}%
\else
- \csname DUrole#1\endcsname{#2}%
+ % backwards compatibility: try \docutilsrole#1{#2}
+ \ifcsname docutilsrole#1\endcsname%
+ \csname docutilsrole#1\endcsname{#2}%
+ \else%
+ #2%
+ \fi%
\fi%
}
Modified: trunk/docutils/test/functional/expected/latex_literal_block_listings.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_literal_block_listings.tex 2018-06-05 13:38:08 UTC (rev 8217)
+++ trunk/docutils/test/functional/expected/latex_literal_block_listings.tex 2018-06-05 13:38:25 UTC (rev 8218)
@@ -53,11 +53,15 @@
% inline markup (custom roles)
% \DUrole{#1}{#2} tries \DUrole#1{#2}
\providecommand*{\DUrole}[2]{%
- % backwards compatibility: try \docutilsrole#1{#2}
- \ifcsname docutilsrole#1\endcsname%
- \csname docutilsrole#1\endcsname{#2}%
+ \ifcsname DUrole#1\endcsname%
+ \csname DUrole#1\endcsname{#2}%
\else
- \csname DUrole#1\endcsname{#2}%
+ % backwards compatibility: try \docutilsrole#1{#2}
+ \ifcsname docutilsrole#1\endcsname%
+ \csname docutilsrole#1\endcsname{#2}%
+ \else%
+ #2%
+ \fi%
\fi%
}
Modified: trunk/docutils/test/functional/expected/latex_literal_block_verbatim.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_literal_block_verbatim.tex 2018-06-05 13:38:08 UTC (rev 8217)
+++ trunk/docutils/test/functional/expected/latex_literal_block_verbatim.tex 2018-06-05 13:38:25 UTC (rev 8218)
@@ -46,11 +46,15 @@
% inline markup (custom roles)
% \DUrole{#1}{#2} tries \DUrole#1{#2}
\providecommand*{\DUrole}[2]{%
- % backwards compatibility: try \docutilsrole#1{#2}
- \ifcsname docutilsrole#1\endcsname%
- \csname docutilsrole#1\endcsname{#2}%
+ \ifcsname DUrole#1\endcsname%
+ \csname DUrole#1\endcsname{#2}%
\else
- \csname DUrole#1\endcsname{#2}%
+ % backwards compatibility: try \docutilsrole#1{#2}
+ \ifcsname docutilsrole#1\endcsname%
+ \csname docutilsrole#1\endcsname{#2}%
+ \else%
+ #2%
+ \fi%
\fi%
}
Modified: trunk/docutils/test/functional/expected/latex_literal_block_verbatimtab.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_literal_block_verbatimtab.tex 2018-06-05 13:38:08 UTC (rev 8217)
+++ trunk/docutils/test/functional/expected/latex_literal_block_verbatimtab.tex 2018-06-05 13:38:25 UTC (rev 8218)
@@ -47,11 +47,15 @@
% inline markup (custom roles)
% \DUrole{#1}{#2} tries \DUrole#1{#2}
\providecommand*{\DUrole}[2]{%
- % backwards compatibility: try \docutilsrole#1{#2}
- \ifcsname docutilsrole#1\endcsname%
- \csname docutilsrole#1\endcsname{#2}%
+ \ifcsname DUrole#1\endcsname%
+ \csname DUrole#1\endcsname{#2}%
\else
- \csname DUrole#1\endcsname{#2}%
+ % backwards compatibility: try \docutilsrole#1{#2}
+ \ifcsname docutilsrole#1\endcsname%
+ \csname docutilsrole#1\endcsname{#2}%
+ \else%
+ #2%
+ \fi%
\fi%
}
Modified: trunk/docutils/test/functional/expected/standalone_rst_latex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2018-06-05 13:38:08 UTC (rev 8217)
+++ trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2018-06-05 13:38:25 UTC (rev 8218)
@@ -104,11 +104,15 @@
% inline markup (custom roles)
% \DUrole{#1}{#2} tries \DUrole#1{#2}
\providecommand*{\DUrole}[2]{%
- % backwards compatibility: try \docutilsrole#1{#2}
- \ifcsname docutilsrole#1\endcsname%
- \csname docutilsrole#1\endcsname{#2}%
+ \ifcsname DUrole#1\endcsname%
+ \csname DUrole#1\endcsname{#2}%
\else
- \csname DUrole#1\endcsname{#2}%
+ % backwards compatibility: try \docutilsrole#1{#2}
+ \ifcsname docutilsrole#1\endcsname%
+ \csname docutilsrole#1\endcsname{#2}%
+ \else%
+ #2%
+ \fi%
\fi%
}
Modified: trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2018-06-05 13:38:08 UTC (rev 8217)
+++ trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2018-06-05 13:38:25 UTC (rev 8218)
@@ -103,11 +103,15 @@
% inline markup (custom roles)
% \DUrole{#1}{#2} tries \DUrole#1{#2}
\providecommand*{\DUrole}[2]{%
- % backwards compatibility: try \docutilsrole#1{#2}
- \ifcsname docutilsrole#1\endcsname%
- \csname docutilsrole#1\endcsname{#2}%
+ \ifcsname DUrole#1\endcsname%
+ \csname DUrole#1\endcsname{#2}%
\else
- \csname DUrole#1\endcsname{#2}%
+ % backwards compatibility: try \docutilsrole#1{#2}
+ \ifcsname docutilsrole#1\endcsname%
+ \csname docutilsrole#1\endcsname{#2}%
+ \else%
+ #2%
+ \fi%
\fi%
}
Modified: trunk/docutils/test/test_writers/test_latex2e.py
===================================================================
--- trunk/docutils/test/test_writers/test_latex2e.py 2018-06-05 13:38:08 UTC (rev 8217)
+++ trunk/docutils/test/test_writers/test_latex2e.py 2018-06-05 13:38:25 UTC (rev 8218)
@@ -76,11 +76,15 @@
% inline markup (custom roles)
% \DUrole{#1}{#2} tries \DUrole#1{#2}
\providecommand*{\DUrole}[2]{%
- % backwards compatibility: try \docutilsrole#1{#2}
- \ifcsname docutilsrole#1\endcsname%
- \csname docutilsrole#1\endcsname{#2}%
+ \ifcsname DUrole#1\endcsname%
+ \csname DUrole#1\endcsname{#2}%
\else
- \csname DUrole#1\endcsname{#2}%
+ % backwards compatibility: try \docutilsrole#1{#2}
+ \ifcsname docutilsrole#1\endcsname%
+ \csname docutilsrole#1\endcsname{#2}%
+ \else%
+ #2%
+ \fi%
\fi%
}
""",
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gr...@us...> - 2018-07-12 10:17:18
|
Revision: 8224
http://sourceforge.net/p/docutils/code/8224
Author: grubert
Date: 2018-07-12 10:17:15 +0000 (Thu, 12 Jul 2018)
Log Message:
-----------
Fix: definition list term classifier starting with a reference crash.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/parsers/rst/states.py
trunk/docutils/test/test_parsers/test_rst/test_definition_lists.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2018-07-11 12:12:34 UTC (rev 8223)
+++ trunk/docutils/HISTORY.txt 2018-07-12 10:17:15 UTC (rev 8224)
@@ -36,6 +36,7 @@
- Allow embedded colons in field list field names.
- Add `rawsource` attribute for text of inline elements and definition
list terms.
+ - Fix: definition list term classifier starting with a reference crash.
* docutils/parsers/rst/directives/html.py:
Modified: trunk/docutils/docutils/parsers/rst/states.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/states.py 2018-07-11 12:12:34 UTC (rev 8223)
+++ trunk/docutils/docutils/parsers/rst/states.py 2018-07-12 10:17:15 UTC (rev 8224)
@@ -2866,7 +2866,11 @@
for part in parts[1:]:
classifier_node = nodes.classifier(part,
utils.unescape_rawsource(part))
- classifier_node[0].rawsource = part
+ try:
+ classifier_node[0].rawsource = part
+ except IndexError:
+ # might be a reference or similar in the next node
+ pass
node_list.append(classifier_node)
else:
node_list[-1] += node
Modified: trunk/docutils/test/test_parsers/test_rst/test_definition_lists.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_definition_lists.py 2018-07-11 12:12:34 UTC (rev 8223)
+++ trunk/docutils/test/test_parsers/test_rst/test_definition_lists.py 2018-07-12 10:17:15 UTC (rev 8224)
@@ -369,6 +369,44 @@
Inline strong start-string without end-string.
"""],
["""\
+Term : `reference`_
+ classifier starting with a reference crashes from release 8197 to ...
+""",
+"""\
+<document source="test data">
+ <definition_list>
+ <definition_list_item>
+ <term>
+ Term
+ <classifier>
+ <reference name="reference" refname="reference">
+ reference
+ <definition>
+ <paragraph>
+ classifier starting with a reference crashes from release 8197 to ...
+"""],
+["""\
+Term : a `reference`_ in text : second
+ classifier with reference crashes from release 8197 to ...
+""",
+"""\
+<document source="test data">
+ <definition_list>
+ <definition_list_item>
+ <term>
+ Term
+ <classifier>
+ a \n\
+ <reference name="reference" refname="reference">
+ reference
+ in text
+ <classifier>
+ second
+ <definition>
+ <paragraph>
+ classifier with reference crashes from release 8197 to ...
+"""],
+["""\
Term : classifier one : classifier two
Definition
""",
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gr...@us...> - 2018-09-09 18:57:03
|
Revision: 8228
http://sourceforge.net/p/docutils/code/8228
Author: grubert
Date: 2018-09-09 18:57:00 +0000 (Sun, 09 Sep 2018)
Log Message:
-----------
Fix [ 348 ] Since Python 3.4, the 'U' universal newlines mode has been deprecated (thanks to hugovk).
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/io.py
trunk/docutils/test/test_io.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2018-07-21 12:52:10 UTC (rev 8227)
+++ trunk/docutils/HISTORY.txt 2018-09-09 18:57:00 UTC (rev 8228)
@@ -26,6 +26,11 @@
- Document rST syntax change: Tokens like ``:this:example:`` are now valid
field list names (instead of ordinary text).
+* docutils/io.py
+
+ - Fix [ 348 ] Since Python 3.4, the 'U' universal newlines mode has been
+ deprecated (thanks to hugovk).
+
* docutils/nodes.py
- Fix [ 251 ] system_message.copy() TypeError.
Modified: trunk/docutils/docutils/io.py
===================================================================
--- trunk/docutils/docutils/io.py 2018-07-21 12:52:10 UTC (rev 8227)
+++ trunk/docutils/docutils/io.py 2018-09-09 18:57:00 UTC (rev 8228)
@@ -203,7 +203,8 @@
"""
def __init__(self, source=None, source_path=None,
encoding=None, error_handler='strict',
- autoclose=True, mode='rU', **kwargs):
+ autoclose=True,
+ mode='r' if sys.version_info >= (3, 4) else 'rU', **kwargs):
"""
:Parameters:
- `source`: either a file-like object (which is read directly), or
@@ -215,7 +216,7 @@
`sys.stdin` is the source).
- `mode`: how the file is to be opened (see standard function
`open`). The default 'rU' provides universal newline support
- for text files.
+ for text files on Python < 3.4.
"""
Input.__init__(self, source, source_path, encoding, error_handler)
self.autoclose = autoclose
Modified: trunk/docutils/test/test_io.py
===================================================================
--- trunk/docutils/test/test_io.py 2018-07-21 12:52:10 UTC (rev 8227)
+++ trunk/docutils/test/test_io.py 2018-09-09 18:57:00 UTC (rev 8228)
@@ -133,7 +133,22 @@
# raise AssertionError if data is not an unicode string
self.assertRaises(AssertionError, uniinput.decode, b'ja')
+ def test_deprecation_warning(self):
+ # Arrange
+ import warnings
+ with warnings.catch_warnings(record=True) as w:
+ # Cause all warnings to always be triggered
+ warnings.simplefilter("always", DeprecationWarning)
+ # Act
+ # Trigger a warning?
+ io.FileInput(source_path='data/include.txt')
+
+ # Assert
+ self.assertEqual(len(w), 0, "Expected no warnings, got %s" %
+ list(v.category for v in w))
+
+
class OutputTests(unittest.TestCase):
bdata = b'\xfc'
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2018-11-20 17:47:22
|
Revision: 8230
http://sourceforge.net/p/docutils/code/8230
Author: milde
Date: 2018-11-20 17:47:21 +0000 (Tue, 20 Nov 2018)
Log Message:
-----------
Fix tab-with in `include` directive with `code` option.
Don't convert tabs to spaces, if `tab_width` is negative.
Add a fallback for LaTeX.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/parsers/rst/directives/misc.py
trunk/docutils/docutils/writers/latex2e/__init__.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2018-11-20 17:47:12 UTC (rev 8229)
+++ trunk/docutils/HISTORY.txt 2018-11-20 17:47:21 UTC (rev 8230)
@@ -47,6 +47,11 @@
- Fix bug #281: Remove escaping backslashes in meta directive content.
+* docutils/parsers/rst/directives/misc.py:
+
+ - Don't convert tabs to spaces, if `tab_width` is negative in
+ `include` directive with `code` option.
+
* docutils/parsers/rst/directives/tables.py:
- Apply patch #121: Add "width" option for the table directives.
Modified: trunk/docutils/docutils/parsers/rst/directives/misc.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/misc.py 2018-11-20 17:47:12 UTC (rev 8229)
+++ trunk/docutils/docutils/parsers/rst/directives/misc.py 2018-11-20 17:47:21 UTC (rev 8230)
@@ -114,7 +114,7 @@
include_lines = statemachine.string2lines(rawtext, tab_width,
convert_whitespace=True)
if 'literal' in self.options:
- # Convert tabs to spaces, if `tab_width` is positive.
+ # Don't convert tabs to spaces, if `tab_width` is positive.
if tab_width >= 0:
text = rawtext.expandtabs(tab_width)
else:
@@ -144,6 +144,9 @@
return [literal_block]
if 'code' in self.options:
self.options['source'] = path
+ # Don't convert tabs to spaces, if `tab_width` is negative:
+ if tab_width < 0:
+ include_lines = rawtext.splitlines()
codeblock = CodeBlock(self.name,
[self.options.pop('code')], # arguments
self.options,
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2018-11-20 17:47:12 UTC (rev 8229)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2018-11-20 17:47:21 UTC (rev 8230)
@@ -1516,6 +1516,10 @@
table[ord('>')] = ur'\textgreater{}'
if self.insert_non_breaking_blanks:
table[ord(' ')] = ur'~'
+ # tab chars may occur in included files (literal or code)
+ # quick-and-dirty replacement with spaces
+ # (for better results use `--literal-block-env=lstlisting`)
+ table[ord('\t')] = u'~' * self.settings.tab_width
# Unicode replacements for 8-bit tex engines (not required with XeTeX/LuaTeX):
if not self.is_xetex:
if not self.latex_encoding.startswith('utf8'):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2018-11-20 23:55:16
|
Revision: 8231
http://sourceforge.net/p/docutils/code/8231
Author: milde
Date: 2018-11-20 23:55:14 +0000 (Tue, 20 Nov 2018)
Log Message:
-----------
DocInfo transform must not use "rawsource" attribute for escaping.
Remove implementation of escaping author-separators in bibliographic fields
that relies on the "rawsource" attribute.
This is not safe (rawsource is only for information and debugging purposes).
A proper fix can be done with null-escaped text in the doctree.
C.f. https://sourceforge.net/p/docutils/bugs/_discuss/thread/c8f86be6/74ed/attachment/null-escape-in-doctree2.patch
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/RELEASE-NOTES.txt
trunk/docutils/docutils/parsers/rst/directives/misc.py
trunk/docutils/docutils/parsers/rst/states.py
trunk/docutils/docutils/transforms/frontmatter.py
trunk/docutils/docutils/utils/__init__.py
trunk/docutils/test/test_transforms/test_docinfo.py
trunk/docutils/test/test_utils.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2018-11-20 17:47:21 UTC (rev 8230)
+++ trunk/docutils/HISTORY.txt 2018-11-20 23:55:14 UTC (rev 8231)
@@ -59,8 +59,6 @@
* docutils/transforms/frontmatter.py:
- Add field name as class argument to generic docinfo fields unconditionally.
- - Ignore backslash-escaped separators when extracting authors from a
- paragraph.
* docutils/transforms/references.py:
@@ -85,7 +83,6 @@
* docutils/utils/__init__.py:
- Deprecate `unique_combinations` (obsoleted by `itertools.combinations`).
- - New function `unescape_rawsource`.
Release 0.14 (2017-08-03)
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2018-11-20 17:47:21 UTC (rev 8230)
+++ trunk/docutils/RELEASE-NOTES.txt 2018-11-20 23:55:14 UTC (rev 8231)
@@ -39,7 +39,11 @@
.. _rst2html.py: docs/user/tools.html#rst2html-py
+* Allow escaping of author-separators in `bibliographic fields`__.
+ __ docs/ref/rst/restructuredtext.html#bibliographic-fields
+
+
Release 0.15b.dev
=================
@@ -58,11 +62,7 @@
- Fixed a bug with the "trim" options of the "unicode" directive.
- - Allow escaping of author-separators in `bibliographic fields`__.
-
- __ docs/ref/rst/restructuredtext.html#bibliographic-fields
-
Release 0.14 (2017-08-03)
=========================
Modified: trunk/docutils/docutils/parsers/rst/directives/misc.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/misc.py 2018-11-20 17:47:21 UTC (rev 8230)
+++ trunk/docutils/docutils/parsers/rst/directives/misc.py 2018-11-20 23:55:14 UTC (rev 8231)
@@ -323,7 +323,7 @@
except ValueError, error:
raise self.error(u'Invalid character code: %s\n%s'
% (code, ErrorString(error)))
- element += nodes.Text(utils.unescape_rawsource(decoded), decoded)
+ element += nodes.Text(utils.unescape(decoded), decoded)
return element.children
Modified: trunk/docutils/docutils/parsers/rst/states.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/states.py 2018-11-20 17:47:21 UTC (rev 8230)
+++ trunk/docutils/docutils/parsers/rst/states.py 2018-11-20 23:55:14 UTC (rev 8231)
@@ -2859,17 +2859,12 @@
if len(parts) == 1:
node_list[-1] += node
else:
- rawtext = parts[0].rstrip()
- textnode = nodes.Text(utils.unescape_rawsource(rawtext))
- textnode.rawsource = rawtext
+ text = parts[0].rstrip()
+ textnode = nodes.Text(utils.unescape(text, True))
node_list[-1] += textnode
for part in parts[1:]:
- classifier_node = nodes.classifier(part,
- utils.unescape_rawsource(part))
- # might be a reference or similar in the next node
- # then classifier_node is empty
- if len(classifier_node) > 0:
- classifier_node[0].rawsource = part
+ classifier_node = nodes.classifier(
+ unescape(part, True), part)
node_list.append(classifier_node)
else:
node_list[-1] += node
Modified: trunk/docutils/docutils/transforms/frontmatter.py
===================================================================
--- trunk/docutils/docutils/transforms/frontmatter.py 2018-11-20 17:47:21 UTC (rev 8230)
+++ trunk/docutils/docutils/transforms/frontmatter.py 2018-11-20 23:55:14 UTC (rev 8231)
@@ -506,21 +506,19 @@
def authors_from_one_paragraph(self, field):
"""Return list of Text nodes for ";"- or ","-separated authornames."""
# @@ keep original formatting? (e.g. ``:authors: A. Test, *et-al*``)
- rawnames = (node.rawsource or node.astext
- for node in field[1].traverse(nodes.Text))
- text = ''.join(rawnames)
+ text = ''.join(unicode(node)
+ for node in field[1].traverse(nodes.Text))
if not text:
raise TransformError
for authorsep in self.language.author_separators:
# don't split at escaped `authorsep`:
- pattern = r'(?<=\\\\)%s|(?<!\\)%s' % (authorsep, authorsep)
+ pattern = '(?<!\x00)%s' % authorsep
authornames = re.split(pattern, text)
if len(authornames) > 1:
break
- authornames = ((utils.unescape_rawsource(rawname).strip(),
- rawname.strip()) for rawname in authornames)
- authors = [[nodes.Text(author, rawname)]
- for (author, rawname) in authornames if author]
+ authornames = (name.strip() for name in authornames)
+ authors = [[nodes.Text(name, utils.unescape(name, True))]
+ for name in authornames if name]
return authors
def authors_from_bullet_list(self, field):
Modified: trunk/docutils/docutils/utils/__init__.py
===================================================================
--- trunk/docutils/docutils/utils/__init__.py 2018-11-20 17:47:21 UTC (rev 8230)
+++ trunk/docutils/docutils/utils/__init__.py 2018-11-20 23:55:14 UTC (rev 8231)
@@ -581,6 +581,7 @@
Return a string with nulls removed or restored to backslashes.
Backslash-escaped spaces are also removed.
"""
+ # `respect_whitespace` is ignored (since introduction 2016-12-16)
if restore_backslashes:
return text.replace('\x00', '\\')
else:
@@ -588,13 +589,6 @@
text = ''.join(text.split(sep))
return text
-def unescape_rawsource(text):
- """Remove escape-backslashes and escaped whitespace."""
- # remove escaped whitespace or backslash at end of text
- text = re.sub(r'(?<!\\)\\([ \n]|$)', r'', text)
- # remove backslash-escapes
- return re.sub(r'\\(.)', r'\1', text)
-
def split_escaped_whitespace(text):
"""
Split `text` on escaped whitespace (null+space or null+newline).
Modified: trunk/docutils/test/test_transforms/test_docinfo.py
===================================================================
--- trunk/docutils/test/test_transforms/test_docinfo.py 2018-11-20 17:47:21 UTC (rev 8230)
+++ trunk/docutils/test/test_transforms/test_docinfo.py 2018-11-20 23:55:14 UTC (rev 8231)
@@ -230,54 +230,54 @@
<author>
One, Only
"""],
-[r""":Authors: Me\, Myself; **I**
-:Authors: Pac\;Man\\; Ms. Pac\Man; Pac\ Man, Jr.
-:Authors:
- Here
-
- The\re
-
- *Every\ where*
-:Authors: - First\\
- - Se\ cond
- - Thir\d
-""",
-"""\
-<document source="test data">
- <docinfo>
- <authors>
- <author>
- Me, Myself
- <author>
- I
- <authors>
- <author>
- Pac;Man\\
- <author>
- Ms. PacMan
- <author>
- PacMan, Jr.
- <authors>
- <author>
- Here
- <author>
- There
- <author>
- <emphasis>
- Everywhere
- <authors>
- <author>
- First\\
- <author>
- Second
- <author>
- Third
-"""],
+# [r""":Authors: Me\, Myself; **I**
+# :Authors: Pac\;Man\\; Ms. Pac\Man; Pac\ Man, Jr.
+# :Authors:
+# Here
+#
+# The\re
+#
+# *Every\ where*
+# :Authors: - First\\
+# - Se\ cond
+# - Thir\d
+# """,
+# """\
+# <document source="test data">
+# <docinfo>
+# <authors>
+# <author>
+# Me, Myself
+# <author>
+# I
+# <authors>
+# <author>
+# Pac;Man\\
+# <author>
+# Ms. PacMan
+# <author>
+# PacMan, Jr.
+# <authors>
+# <author>
+# Here
+# <author>
+# There
+# <author>
+# <emphasis>
+# Everywhere
+# <authors>
+# <author>
+# First\\
+# <author>
+# Second
+# <author>
+# Third
+# """],
["""\
:Authors:
-:Authors: 1. One
- 2. Two
+:Authors: A. Einstein
+ B. Shaw
:Authors:
-
@@ -307,13 +307,13 @@
<field_name>
Authors
<field_body>
- <enumerated_list enumtype="arabic" prefix="" suffix=".">
+ <enumerated_list enumtype="upperalpha" prefix="" suffix=".">
<list_item>
<paragraph>
- One
+ Einstein
<list_item>
<paragraph>
- Two
+ Shaw
<system_message level="2" line="3" source="test data" type="WARNING">
<paragraph>
Bibliographic field "Authors" incompatible with extraction: it must contain either a single paragraph (with authors separated by one of ";,"), multiple paragraphs (one per author), or a bullet list with one paragraph (one author) per item.
Modified: trunk/docutils/test/test_utils.py
===================================================================
--- trunk/docutils/test/test_utils.py 2018-11-20 17:47:21 UTC (rev 8230)
+++ trunk/docutils/test/test_utils.py 2018-11-20 23:55:14 UTC (rev 8231)
@@ -337,9 +337,5 @@
restored = utils.unescape(self.nulled, restore_backslashes=True)
self.assertEqual(restored, self.escaped)
- def test_unescape_rawsource(self):
- unescaped = utils.unescape_rawsource(self.escaped)
- self.assertEqual(unescaped, self.unescaped)
-
if __name__ == '__main__':
unittest.main()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2018-11-20 23:55:41
|
Revision: 8234
http://sourceforge.net/p/docutils/code/8234
Author: milde
Date: 2018-11-20 23:55:40 +0000 (Tue, 20 Nov 2018)
Log Message:
-----------
smartquotes: Use single backslashes for escaping.
Let the smartquote transform take advantage of the
representation of escaping backslashes in the doctree
as null characters.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docs/user/smartquotes.txt
trunk/docutils/docutils/transforms/universal.py
trunk/docutils/test/test_transforms/test_smartquotes.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2018-11-20 23:55:23 UTC (rev 8233)
+++ trunk/docutils/HISTORY.txt 2018-11-20 23:55:40 UTC (rev 8234)
@@ -67,6 +67,7 @@
* docutils/utils/smartquotes.py:
- Fix bug #332: use open quote after whitespace, ZWSP, and ZWNJ.
+ - Use single backslashes for escaping.
* docutils/writers/html5_polyglot/
Modified: trunk/docutils/docs/user/smartquotes.txt
===================================================================
--- trunk/docutils/docs/user/smartquotes.txt 2018-11-20 23:55:23 UTC (rev 8233)
+++ trunk/docutils/docs/user/smartquotes.txt 2018-11-20 23:55:40 UTC (rev 8234)
@@ -5,8 +5,8 @@
:Author: Günter Milde,
based on SmartyPants by John Gruber, Brad Choate, and Chad Miller
:Contact: doc...@li...
-:Revision: $Revision$
-:Date: $Date$
+:Revision: $Revision: 8112 $
+:Date: $Date: 2017-06-14 16:20:20 +0200 (Mi, 14. Jun 2017) $
:License: Released under the terms of the `2-Clause BSD license`_
:Abstract: This document describes the Docutils `smartquotes` module.
@@ -25,7 +25,7 @@
- three consecutive dots (``...`` or ``. . .``) into an ellipsis entity.
This means you can write, edit, and save your documents using plain old
-ASCII---straight quotes, plain dashes, and plain dots---while Docutils
+ASCII -- straight quotes, plain dashes, and plain dots -- while Docutils
generates documents with typographical quotes, dashes, and ellipses.
Advantages:
@@ -32,12 +32,12 @@
* typing speed (especially when blind-typing),
* the possibility to change the quoting style of the
- complete document with just one configuration option, and
-* restriction to 7-bit characters in the source.
+ complete document with just one configuration option,
+* restriction to 7-bit ASCII characters in the source.
However, there are `algorithmic shortcomings`_ for 2 reasons:
-* Dual use of the "ASCII-apostrophe" (') as single quote and apostrophe,
+* dual use of the "ASCII-apostrophe" (') as single quote and apostrophe,
* languages that do not use whitespace around words.
So, please consider also
@@ -54,24 +54,27 @@
such as source code, maths, or literal blocks.
If you need literal straight quotes (or plain hyphens and periods) in normal
-text, you can backslash escape the characters to preserve
-ASCII-punctuation. You need two backslashes as one backslash is removed by
-the reStructuredText `escaping mechanism`_.
+text, you can `backslash escape`_ the characters to preserve
+ASCII-punctuation.
-======== ========= ======== =========
-Escape Character Escape Character
-======== ========= ======== =========
-``\\`` \\ ``\\.`` \\.
-``\\"`` \\" ``\\-`` \\-
-``\\'`` \\' ``\\``` \\`
-======== ========= ======== =========
+.. class:: booktabs
+========= ========= == ======== ==========
+Input Output Input Output
+========= ========= == ======== ==========
+``\\`` \\ ``\...`` \...
+``\"`` \" ``\--`` \--
+``\'`` \' ``\``` \`
+========= ========= == ======== ==========
+
This is useful, for example, when you want to use straight quotes as
-foot and inch marks: 6\\'2\\" tall; a 17\\" iMac.
+foot and inch marks:
-.. _escaping mechanism: ../ref/rst/restructuredtext.html#escaping-mechanism
+ 6\'2\" tall; a 17\" monitor.
+.. _backslash escape: ../ref/rst/restructuredtext.html#escaping-mechanism
+
Localisation
============
@@ -82,7 +85,7 @@
`SmartQuotes` inserts quotation marks depending on the language of the
current block element and the value of the `"smart_quotes" setting`_.\
-[#x-altquot]_
+[#x-altquot]_
There is built-in support for the following languages:\ [#smartquotes-locales]_
:af: .. class:: language-af
Modified: trunk/docutils/docutils/transforms/universal.py
===================================================================
--- trunk/docutils/docutils/transforms/universal.py 2018-11-20 23:55:23 UTC (rev 8233)
+++ trunk/docutils/docutils/transforms/universal.py 2018-11-20 23:55:40 UTC (rev 8234)
@@ -222,9 +222,10 @@
nodes_to_skip = (nodes.FixedTextElement, nodes.Special)
"""Do not apply "smartquotes" to instances of these block-level nodes."""
- literal_nodes = (nodes.image, nodes.literal, nodes.math,
+ literal_nodes = (nodes.FixedTextElement, nodes.Special,
+ nodes.image, nodes.literal, nodes.math,
nodes.raw, nodes.problematic)
- """Do not change quotes in instances of these inline nodes."""
+ """Do apply smartquotes to instances of these inline nodes."""
smartquotes_action = 'qDe'
"""Setting to select smartquote transformations.
@@ -240,15 +241,15 @@
def get_tokens(self, txtnodes):
# A generator that yields ``(texttype, nodetext)`` tuples for a list
# of "Text" nodes (interface to ``smartquotes.educate_tokens()``).
+ for node in txtnodes:
+ if (isinstance(node.parent, self.literal_nodes)
+ or isinstance(node.parent.parent, self.literal_nodes)):
+ yield ('literal', unicode(node))
+ else:
+ # SmartQuotes uses backslash escapes instead of null-escapes
+ txt = re.sub('(?<=\x00)([-\\\'".`])', r'\\\1', unicode(node))
+ yield ('plain', txt)
- texttype = {True: 'literal', # "literal" text is not changed:
- False: 'plain'}
- for txtnode in txtnodes:
- nodetype = texttype[isinstance(txtnode.parent,
- self.literal_nodes)]
- yield (nodetype, txtnode.astext())
-
-
def apply(self):
smart_quotes = self.document.settings.smart_quotes
if not smart_quotes:
Modified: trunk/docutils/test/test_transforms/test_smartquotes.py
===================================================================
--- trunk/docutils/test/test_transforms/test_smartquotes.py 2018-11-20 23:55:23 UTC (rev 8233)
+++ trunk/docutils/test/test_transforms/test_smartquotes.py 2018-11-20 23:55:40 UTC (rev 8234)
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# $Id$
+# $Id: test_smartquotes.py 8190 2017-10-25 13:57:27Z milde $
#
# :Copyright: © 2011 Günter Milde.
# :Maintainer: doc...@li...
@@ -24,7 +24,8 @@
def suite():
parser = Parser()
- settings = {'smart_quotes': True}
+ settings = {'smart_quotes': True,
+ 'trim_footnote_ref_space': True}
s = DocutilsTestSupport.TransformTestSuite(
parser, suite_settings=settings)
s.generateTests(totest)
@@ -43,7 +44,7 @@
totest_de_alt = {}
totest_locales = {}
-totest['transitions'] = ((SmartQuotes,), [
+totest['smartquotes'] = ((SmartQuotes,), [
["""\
Test "smart quotes", 'secondary smart quotes',
"'nested' smart" quotes
@@ -56,7 +57,7 @@
“‘nested’ smart” quotes
– and —also long— dashes.
"""],
-[r"""Escaped \\"ASCII quotes\\" and \\'secondary ASCII quotes\\'.
+[r"""Escaped \"ASCII quotes\" and \'secondary ASCII quotes\'.
""",
u"""\
<document source="test data">
@@ -113,6 +114,7 @@
NBSP "a" 'a',
ZWSP\u200B"a" and\u200B'a',
ZWNJ\u200C"a" and\u200C'a',
+escaped space\ "a" and\ 'a',
—"a",—'a'
en dash–"a"–'a',
@@ -131,6 +133,7 @@
NBSP “a” ‘a’,
ZWSP\u200B“a” and\u200B‘a’,
ZWNJ\u200C“a” and\u200C‘a’,
+ escaped space“a” and‘a’,
<paragraph>
—“a”,—‘a’
en dash–“a”–‘a’,
@@ -196,7 +199,7 @@
and links to "targets_".
Inside *"emphasized"* or other `inline "roles"`:
- (``"string"``), (``'string'``), *\\"betont\\"*, \\"*betont*".
+ (``"string"``), (``'string'``), *\"betont\"*, \"*betont*".
Do not drop characters from intra-word inline markup like
*re*\ ``Structured``\ *Text*.
@@ -252,6 +255,104 @@
Text
.
"""],
+[r"""
+Docutils escape mechanism uses the backslash:
+
+\Remove \non-escaped \backslashes\:
+\item \newline \tab \" \' \*.
+
+\ Remove-\ escaped-\ white\ space-\
+including-\ newlines.
+
+\\Keep\\escaped\\backslashes\\
+(but\\only\\one).
+
+\\ Keep \\ space\\ around \\ backslashes.
+
+Keep backslashes ``\in\ literal``, :math:`in \mathrm{math}`,
+and :code:`in\ code`.
+
+Test around inline elements:\ [*]_
+
+*emphasized*, H\ :sub:`2`\ O and :math:`x^2`
+
+*emphasized*, H\ :sub:`2`\ O and :math:`x^2`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. [*] and footnotes
+""",
+u"""\
+<document source="test data">
+ <paragraph>
+ Docutils escape mechanism uses the backslash:
+ <paragraph>
+ Remove non-escaped backslashes:
+ item newline tab " \' *.
+ <paragraph>
+ Remove-escaped-whitespace-including-newlines.
+ <paragraph>
+ \\Keep\\escaped\\backslashes\\
+ (but\\only\\one).
+ <paragraph>
+ \\ Keep \\ space\\ around \\ backslashes.
+ <paragraph>
+ Keep backslashes \n\
+ <literal>
+ \\in\\ literal
+ , \n\
+ <math>
+ in \\mathrm{math}
+ ,
+ and \n\
+ <literal classes="code">
+ in\\ code
+ .
+ <paragraph>
+ Test around inline elements:
+ <footnote_reference auto="*" ids="id1">
+ <paragraph>
+ <emphasis>
+ emphasized
+ , H
+ <subscript>
+ 2
+ O and \n\
+ <math>
+ x^2
+ <section ids="emphasized-h2o-and-x-2" names="emphasized,\\ h2o\\ and\\ x^2">
+ <title>
+ <emphasis>
+ emphasized
+ , H
+ <subscript>
+ 2
+ O and \n\
+ <math>
+ x^2
+ <footnote auto="*" ids="id2">
+ <paragraph>
+ and footnotes
+"""],
+[r"""
+Character-level m\ *a*\ **r**\ ``k``\ `u`:title:\p
+with backslash-escaped whitespace, including new\
+lines.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Character-level m
+ <emphasis>
+ a
+ <strong>
+ r
+ <literal>
+ k
+ <title_reference>
+ u
+ p
+ with backslash-escaped whitespace, including newlines.
+"""],
["""\
.. class:: language-de
@@ -287,7 +388,7 @@
"""],
])
-totest_de['transitions'] = ((SmartQuotes,), [
+totest_de['smartquotes'] = ((SmartQuotes,), [
["""\
German "smart quotes" and 'secondary smart quotes'.
@@ -304,7 +405,7 @@
"""],
])
-totest_de_alt['transitions'] = ((SmartQuotes,), [
+totest_de_alt['smartquotes'] = ((SmartQuotes,), [
["""\
Alternative German "smart quotes" and 'secondary smart quotes'.
@@ -333,7 +434,7 @@
"""],
])
-totest_locales['transitions'] = ((SmartQuotes,), [
+totest_locales['smartquotes'] = ((SmartQuotes,), [
["""\
German "smart quotes" and 'secondary smart quotes'.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2018-11-21 13:58:53
|
Revision: 8235
http://sourceforge.net/p/docutils/code/8235
Author: milde
Date: 2018-11-21 13:58:51 +0000 (Wed, 21 Nov 2018)
Log Message:
-----------
Revert the fix for backslash escaping in transforms.
Still waiting for review.
Reverts last three commits from a local "feature branch"
unintentionally applied to trunk with `git svn`.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docs/user/smartquotes.txt
trunk/docutils/docutils/parsers/rst/roles.py
trunk/docutils/docutils/parsers/rst/states.py
trunk/docutils/docutils/transforms/universal.py
trunk/docutils/test/test_transforms/test_smartquotes.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2018-11-20 23:55:40 UTC (rev 8234)
+++ trunk/docutils/HISTORY.txt 2018-11-21 13:58:51 UTC (rev 8235)
@@ -67,7 +67,6 @@
* docutils/utils/smartquotes.py:
- Fix bug #332: use open quote after whitespace, ZWSP, and ZWNJ.
- - Use single backslashes for escaping.
* docutils/writers/html5_polyglot/
Modified: trunk/docutils/docs/user/smartquotes.txt
===================================================================
--- trunk/docutils/docs/user/smartquotes.txt 2018-11-20 23:55:40 UTC (rev 8234)
+++ trunk/docutils/docs/user/smartquotes.txt 2018-11-21 13:58:51 UTC (rev 8235)
@@ -5,8 +5,8 @@
:Author: Günter Milde,
based on SmartyPants by John Gruber, Brad Choate, and Chad Miller
:Contact: doc...@li...
-:Revision: $Revision: 8112 $
-:Date: $Date: 2017-06-14 16:20:20 +0200 (Mi, 14. Jun 2017) $
+:Revision: $Revision$
+:Date: $Date$
:License: Released under the terms of the `2-Clause BSD license`_
:Abstract: This document describes the Docutils `smartquotes` module.
@@ -25,7 +25,7 @@
- three consecutive dots (``...`` or ``. . .``) into an ellipsis entity.
This means you can write, edit, and save your documents using plain old
-ASCII -- straight quotes, plain dashes, and plain dots -- while Docutils
+ASCII---straight quotes, plain dashes, and plain dots---while Docutils
generates documents with typographical quotes, dashes, and ellipses.
Advantages:
@@ -32,12 +32,12 @@
* typing speed (especially when blind-typing),
* the possibility to change the quoting style of the
- complete document with just one configuration option,
-* restriction to 7-bit ASCII characters in the source.
+ complete document with just one configuration option, and
+* restriction to 7-bit characters in the source.
However, there are `algorithmic shortcomings`_ for 2 reasons:
-* dual use of the "ASCII-apostrophe" (') as single quote and apostrophe,
+* Dual use of the "ASCII-apostrophe" (') as single quote and apostrophe,
* languages that do not use whitespace around words.
So, please consider also
@@ -54,27 +54,24 @@
such as source code, maths, or literal blocks.
If you need literal straight quotes (or plain hyphens and periods) in normal
-text, you can `backslash escape`_ the characters to preserve
-ASCII-punctuation.
+text, you can backslash escape the characters to preserve
+ASCII-punctuation. You need two backslashes as one backslash is removed by
+the reStructuredText `escaping mechanism`_.
-.. class:: booktabs
+======== ========= ======== =========
+Escape Character Escape Character
+======== ========= ======== =========
+``\\`` \\ ``\\.`` \\.
+``\\"`` \\" ``\\-`` \\-
+``\\'`` \\' ``\\``` \\`
+======== ========= ======== =========
-========= ========= == ======== ==========
-Input Output Input Output
-========= ========= == ======== ==========
-``\\`` \\ ``\...`` \...
-``\"`` \" ``\--`` \--
-``\'`` \' ``\``` \`
-========= ========= == ======== ==========
-
This is useful, for example, when you want to use straight quotes as
-foot and inch marks:
+foot and inch marks: 6\\'2\\" tall; a 17\\" iMac.
- 6\'2\" tall; a 17\" monitor.
+.. _escaping mechanism: ../ref/rst/restructuredtext.html#escaping-mechanism
-.. _backslash escape: ../ref/rst/restructuredtext.html#escaping-mechanism
-
Localisation
============
@@ -85,7 +82,7 @@
`SmartQuotes` inserts quotation marks depending on the language of the
current block element and the value of the `"smart_quotes" setting`_.\
-[#x-altquot]_
+[#x-altquot]_
There is built-in support for the following languages:\ [#smartquotes-locales]_
:af: .. class:: language-af
Modified: trunk/docutils/docutils/parsers/rst/roles.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/roles.py 2018-11-20 23:55:40 UTC (rev 8234)
+++ trunk/docutils/docutils/parsers/rst/roles.py 2018-11-21 13:58:51 UTC (rev 8235)
@@ -195,7 +195,7 @@
def __call__(self, role, rawtext, text, lineno, inliner,
options={}, content=[]):
set_classes(options)
- return [self.node_class(rawtext, text, **options)], []
+ return [self.node_class(rawtext, utils.unescape(text), **options)], []
class CustomRole:
@@ -234,7 +234,7 @@
# Once nested inline markup is implemented, this and other methods should
# recursively call inliner.nested_parse().
set_classes(options)
- return [nodes.inline(rawtext, text, **options)], []
+ return [nodes.inline(rawtext, utils.unescape(text), **options)], []
generic_custom_role.options = {'class': directives.class_option}
@@ -255,7 +255,7 @@
def pep_reference_role(role, rawtext, text, lineno, inliner,
options={}, content=[]):
try:
- pepnum = int(utils.unescape(text))
+ pepnum = int(text)
if pepnum < 0 or pepnum > 9999:
raise ValueError
except ValueError:
@@ -268,7 +268,7 @@
ref = (inliner.document.settings.pep_base_url
+ inliner.document.settings.pep_file_url_template % pepnum)
set_classes(options)
- return [nodes.reference(rawtext, 'PEP ' + text, refuri=ref,
+ return [nodes.reference(rawtext, 'PEP ' + utils.unescape(text), refuri=ref,
**options)], []
register_canonical_role('pep-reference', pep_reference_role)
@@ -276,7 +276,7 @@
def rfc_reference_role(role, rawtext, text, lineno, inliner,
options={}, content=[]):
try:
- rfcnum = int(utils.unescape(text))
+ rfcnum = int(text)
if rfcnum <= 0:
raise ValueError
except ValueError:
@@ -288,7 +288,7 @@
# Base URL mainly used by inliner.rfc_reference, so this is correct:
ref = inliner.document.settings.rfc_base_url + inliner.rfc_url % rfcnum
set_classes(options)
- node = nodes.reference(rawtext, 'RFC ' + text, refuri=ref,
+ node = nodes.reference(rawtext, 'RFC ' + utils.unescape(text), refuri=ref,
**options)
return [node], []
Modified: trunk/docutils/docutils/parsers/rst/states.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/states.py 2018-11-20 23:55:40 UTC (rev 8234)
+++ trunk/docutils/docutils/parsers/rst/states.py 2018-11-21 13:58:51 UTC (rev 8235)
@@ -713,13 +713,12 @@
return (string[:matchend], [], string[matchend:], [], '')
endmatch = end_pattern.search(string[matchend:])
if endmatch and endmatch.start(1): # 1 or more chars
- text = endmatch.string[:endmatch.start(1)]
- if restore_backslashes:
- text = unescape(text, True)
+ _text = endmatch.string[:endmatch.start(1)]
+ text = unescape(_text, restore_backslashes)
textend = matchend + endmatch.end(1)
rawsource = unescape(string[matchstart:textend], True)
node = nodeclass(rawsource, text)
- node[0].rawsource = unescape(text, True)
+ node[0].rawsource = unescape(_text, True)
return (string[:matchstart], [node],
string[textend:], [], endmatch.group(1))
msg = self.reporter.warning(
@@ -726,7 +725,8 @@
'Inline %s start-string without end-string.'
% nodeclass.__name__, line=lineno)
text = unescape(string[matchstart:matchend], True)
- prb = self.problematic(text, text, msg)
+ rawsource = unescape(string[matchstart:matchend], True)
+ prb = self.problematic(text, rawsource, msg)
return string[:matchstart], [prb], string[matchend:], [msg], ''
def problematic(self, text, rawsource, message):
@@ -784,7 +784,7 @@
prb = self.problematic(text, text, msg)
return string[:rolestart], [prb], string[textend:], [msg]
return self.phrase_ref(string[:matchstart], string[textend:],
- rawsource, escaped)
+ rawsource, escaped, unescape(escaped))
else:
rawsource = unescape(string[rolestart:textend], True)
nodelist, messages = self.interpreted(rawsource, escaped, role,
@@ -798,30 +798,26 @@
prb = self.problematic(text, text, msg)
return string[:matchstart], [prb], string[matchend:], [msg]
- def phrase_ref(self, before, after, rawsource, escaped, text=None):
- # `text` is ignored (since 0.15dev)
+ def phrase_ref(self, before, after, rawsource, escaped, text):
match = self.patterns.embedded_link.search(escaped)
if match: # embedded <URI> or <alias_>
- text = escaped[:match.start(0)]
- unescaped = unescape(text)
- rawtext = unescape(text, True)
- aliastext = match.group(2)
- rawaliastext = unescape(aliastext, True)
+ text = unescape(escaped[:match.start(0)])
+ rawtext = unescape(escaped[:match.start(0)], True)
+ aliastext = unescape(match.group(2))
+ rawaliastext = unescape(match.group(2), True)
underscore_escaped = rawaliastext.endswith(r'\_')
if aliastext.endswith('_') and not (underscore_escaped
or self.patterns.uri.match(aliastext)):
aliastype = 'name'
- alias = normalize_name(unescape(aliastext[:-1]))
+ alias = normalize_name(aliastext[:-1])
target = nodes.target(match.group(1), refname=alias)
- target.indirect_reference_name = whitespace_normalize_name(
- unescape(aliastext[:-1]))
+ target.indirect_reference_name = aliastext[:-1]
else:
aliastype = 'uri'
- # remove unescaped whitespace
alias_parts = split_escaped_whitespace(match.group(2))
- alias = ' '.join(''.join(part.split())
+ alias = ' '.join(''.join(unescape(part).split())
for part in alias_parts)
- alias = self.adjust_uri(unescape(alias))
+ alias = self.adjust_uri(alias)
if alias.endswith(r'\_'):
alias = alias[:-2] + '_'
target = nodes.target(match.group(1), refuri=alias)
@@ -831,17 +827,14 @@
% aliastext)
if not text:
text = alias
- unescaped = unescape(text)
rawtext = rawaliastext
else:
- text = escaped
- unescaped = unescape(text)
target = None
rawtext = unescape(escaped, True)
- refname = normalize_name(unescaped)
+ refname = normalize_name(text)
reference = nodes.reference(rawsource, text,
- name=whitespace_normalize_name(unescaped))
+ name=whitespace_normalize_name(text))
reference[0].rawsource = rawtext
node_list = [reference]
@@ -998,9 +991,11 @@
else:
addscheme = ''
text = match.group('whole')
- refuri = addscheme + unescape(text)
- reference = nodes.reference(unescape(text, True), text,
- refuri=refuri)
+ unescaped = unescape(text)
+ rawsource = unescape(text, True)
+ reference = nodes.reference(rawsource, unescaped,
+ refuri=addscheme + unescaped)
+ reference[0].rawsource = rawsource
return [reference]
else: # not a valid scheme
raise MarkupMismatch
@@ -1008,14 +1003,15 @@
def pep_reference(self, match, lineno):
text = match.group(0)
if text.startswith('pep-'):
- pepnum = int(unescape(match.group('pepnum1')))
+ pepnum = int(match.group('pepnum1'))
elif text.startswith('PEP'):
- pepnum = int(unescape(match.group('pepnum2')))
+ pepnum = int(match.group('pepnum2'))
else:
raise MarkupMismatch
ref = (self.document.settings.pep_base_url
+ self.document.settings.pep_file_url_template % pepnum)
- return [nodes.reference(unescape(text, True), text, refuri=ref)]
+ unescaped = unescape(text)
+ return [nodes.reference(unescape(text, True), unescaped, refuri=ref)]
rfc_url = 'rfc%d.html'
@@ -1022,11 +1018,12 @@
def rfc_reference(self, match, lineno):
text = match.group(0)
if text.startswith('RFC'):
- rfcnum = int(unescape(match.group('rfcnum')))
+ rfcnum = int(match.group('rfcnum'))
ref = self.document.settings.rfc_base_url + self.rfc_url % rfcnum
else:
raise MarkupMismatch
- return [nodes.reference(unescape(text, True), text, refuri=ref)]
+ unescaped = unescape(text)
+ return [nodes.reference(unescape(text, True), unescaped, refuri=ref)]
def implicit_inline(self, text, lineno):
"""
@@ -1048,7 +1045,7 @@
self.implicit_inline(text[match.end():], lineno))
except MarkupMismatch:
pass
- return [nodes.Text(text, unescape(text, True))]
+ return [nodes.Text(unescape(text), rawsource=unescape(text, True))]
dispatch = {'*': emphasis,
'**': strong,
@@ -2845,7 +2842,6 @@
self.nested_parse(indented, input_offset=line_offset, node=definition)
return itemnode, blank_finish
- #@ TODO ignore null-escaped delimiter
classifier_delimiter = re.compile(' +: +')
def term(self, lines, lineno):
@@ -2859,12 +2855,12 @@
for i in range(len(text_nodes)):
node = text_nodes[i]
if isinstance(node, nodes.Text):
- parts = self.classifier_delimiter.split(node)
+ parts = self.classifier_delimiter.split(node.rawsource)
if len(parts) == 1:
node_list[-1] += node
else:
text = parts[0].rstrip()
- textnode = nodes.Text(text, unescape(text, True))
+ textnode = nodes.Text(utils.unescape(text, True))
node_list[-1] += textnode
for part in parts[1:]:
classifier_node = nodes.classifier(
Modified: trunk/docutils/docutils/transforms/universal.py
===================================================================
--- trunk/docutils/docutils/transforms/universal.py 2018-11-20 23:55:40 UTC (rev 8234)
+++ trunk/docutils/docutils/transforms/universal.py 2018-11-21 13:58:51 UTC (rev 8235)
@@ -222,10 +222,9 @@
nodes_to_skip = (nodes.FixedTextElement, nodes.Special)
"""Do not apply "smartquotes" to instances of these block-level nodes."""
- literal_nodes = (nodes.FixedTextElement, nodes.Special,
- nodes.image, nodes.literal, nodes.math,
+ literal_nodes = (nodes.image, nodes.literal, nodes.math,
nodes.raw, nodes.problematic)
- """Do apply smartquotes to instances of these inline nodes."""
+ """Do not change quotes in instances of these inline nodes."""
smartquotes_action = 'qDe'
"""Setting to select smartquote transformations.
@@ -241,15 +240,15 @@
def get_tokens(self, txtnodes):
# A generator that yields ``(texttype, nodetext)`` tuples for a list
# of "Text" nodes (interface to ``smartquotes.educate_tokens()``).
- for node in txtnodes:
- if (isinstance(node.parent, self.literal_nodes)
- or isinstance(node.parent.parent, self.literal_nodes)):
- yield ('literal', unicode(node))
- else:
- # SmartQuotes uses backslash escapes instead of null-escapes
- txt = re.sub('(?<=\x00)([-\\\'".`])', r'\\\1', unicode(node))
- yield ('plain', txt)
+ texttype = {True: 'literal', # "literal" text is not changed:
+ False: 'plain'}
+ for txtnode in txtnodes:
+ nodetype = texttype[isinstance(txtnode.parent,
+ self.literal_nodes)]
+ yield (nodetype, txtnode.astext())
+
+
def apply(self):
smart_quotes = self.document.settings.smart_quotes
if not smart_quotes:
Modified: trunk/docutils/test/test_transforms/test_smartquotes.py
===================================================================
--- trunk/docutils/test/test_transforms/test_smartquotes.py 2018-11-20 23:55:40 UTC (rev 8234)
+++ trunk/docutils/test/test_transforms/test_smartquotes.py 2018-11-21 13:58:51 UTC (rev 8235)
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# $Id: test_smartquotes.py 8190 2017-10-25 13:57:27Z milde $
+# $Id$
#
# :Copyright: © 2011 Günter Milde.
# :Maintainer: doc...@li...
@@ -24,8 +24,7 @@
def suite():
parser = Parser()
- settings = {'smart_quotes': True,
- 'trim_footnote_ref_space': True}
+ settings = {'smart_quotes': True}
s = DocutilsTestSupport.TransformTestSuite(
parser, suite_settings=settings)
s.generateTests(totest)
@@ -44,7 +43,7 @@
totest_de_alt = {}
totest_locales = {}
-totest['smartquotes'] = ((SmartQuotes,), [
+totest['transitions'] = ((SmartQuotes,), [
["""\
Test "smart quotes", 'secondary smart quotes',
"'nested' smart" quotes
@@ -57,7 +56,7 @@
“‘nested’ smart” quotes
– and —also long— dashes.
"""],
-[r"""Escaped \"ASCII quotes\" and \'secondary ASCII quotes\'.
+[r"""Escaped \\"ASCII quotes\\" and \\'secondary ASCII quotes\\'.
""",
u"""\
<document source="test data">
@@ -114,7 +113,6 @@
NBSP "a" 'a',
ZWSP\u200B"a" and\u200B'a',
ZWNJ\u200C"a" and\u200C'a',
-escaped space\ "a" and\ 'a',
—"a",—'a'
en dash–"a"–'a',
@@ -133,7 +131,6 @@
NBSP “a” ‘a’,
ZWSP\u200B“a” and\u200B‘a’,
ZWNJ\u200C“a” and\u200C‘a’,
- escaped space“a” and‘a’,
<paragraph>
—“a”,—‘a’
en dash–“a”–‘a’,
@@ -199,7 +196,7 @@
and links to "targets_".
Inside *"emphasized"* or other `inline "roles"`:
- (``"string"``), (``'string'``), *\"betont\"*, \"*betont*".
+ (``"string"``), (``'string'``), *\\"betont\\"*, \\"*betont*".
Do not drop characters from intra-word inline markup like
*re*\ ``Structured``\ *Text*.
@@ -255,104 +252,6 @@
Text
.
"""],
-[r"""
-Docutils escape mechanism uses the backslash:
-
-\Remove \non-escaped \backslashes\:
-\item \newline \tab \" \' \*.
-
-\ Remove-\ escaped-\ white\ space-\
-including-\ newlines.
-
-\\Keep\\escaped\\backslashes\\
-(but\\only\\one).
-
-\\ Keep \\ space\\ around \\ backslashes.
-
-Keep backslashes ``\in\ literal``, :math:`in \mathrm{math}`,
-and :code:`in\ code`.
-
-Test around inline elements:\ [*]_
-
-*emphasized*, H\ :sub:`2`\ O and :math:`x^2`
-
-*emphasized*, H\ :sub:`2`\ O and :math:`x^2`
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-.. [*] and footnotes
-""",
-u"""\
-<document source="test data">
- <paragraph>
- Docutils escape mechanism uses the backslash:
- <paragraph>
- Remove non-escaped backslashes:
- item newline tab " \' *.
- <paragraph>
- Remove-escaped-whitespace-including-newlines.
- <paragraph>
- \\Keep\\escaped\\backslashes\\
- (but\\only\\one).
- <paragraph>
- \\ Keep \\ space\\ around \\ backslashes.
- <paragraph>
- Keep backslashes \n\
- <literal>
- \\in\\ literal
- , \n\
- <math>
- in \\mathrm{math}
- ,
- and \n\
- <literal classes="code">
- in\\ code
- .
- <paragraph>
- Test around inline elements:
- <footnote_reference auto="*" ids="id1">
- <paragraph>
- <emphasis>
- emphasized
- , H
- <subscript>
- 2
- O and \n\
- <math>
- x^2
- <section ids="emphasized-h2o-and-x-2" names="emphasized,\\ h2o\\ and\\ x^2">
- <title>
- <emphasis>
- emphasized
- , H
- <subscript>
- 2
- O and \n\
- <math>
- x^2
- <footnote auto="*" ids="id2">
- <paragraph>
- and footnotes
-"""],
-[r"""
-Character-level m\ *a*\ **r**\ ``k``\ `u`:title:\p
-with backslash-escaped whitespace, including new\
-lines.
-""",
-"""\
-<document source="test data">
- <paragraph>
- Character-level m
- <emphasis>
- a
- <strong>
- r
- <literal>
- k
- <title_reference>
- u
- p
- with backslash-escaped whitespace, including newlines.
-"""],
["""\
.. class:: language-de
@@ -388,7 +287,7 @@
"""],
])
-totest_de['smartquotes'] = ((SmartQuotes,), [
+totest_de['transitions'] = ((SmartQuotes,), [
["""\
German "smart quotes" and 'secondary smart quotes'.
@@ -405,7 +304,7 @@
"""],
])
-totest_de_alt['smartquotes'] = ((SmartQuotes,), [
+totest_de_alt['transitions'] = ((SmartQuotes,), [
["""\
Alternative German "smart quotes" and 'secondary smart quotes'.
@@ -434,7 +333,7 @@
"""],
])
-totest_locales['smartquotes'] = ((SmartQuotes,), [
+totest_locales['transitions'] = ((SmartQuotes,), [
["""\
German "smart quotes" and 'secondary smart quotes'.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2018-11-21 13:58:59
|
Revision: 8236
http://sourceforge.net/p/docutils/code/8236
Author: milde
Date: 2018-11-21 13:58:57 +0000 (Wed, 21 Nov 2018)
Log Message:
-----------
Definition list terms must not use "rawsource" attribute for escaping.
Remove implementation of escaping the classifier delimiter in
definition list terms that relies on the "rawsource" attribute.
This is not safe (rawsource is only for information and debugging purposes).
A proper fix can be done with null-escaped text in Text nodes.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/parsers/rst/states.py
trunk/docutils/test/test_parsers/test_rst/test_definition_lists.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2018-11-21 13:58:51 UTC (rev 8235)
+++ trunk/docutils/HISTORY.txt 2018-11-21 13:58:57 UTC (rev 8236)
@@ -28,7 +28,7 @@
* docutils/io.py
- - Fix [ 348 ] Since Python 3.4, the 'U' universal newlines mode has been
+ - Fix [ 348 ] Since Python 3.4, the 'U' universal newlines mode has been
deprecated (thanks to hugovk).
* docutils/nodes.py
@@ -39,9 +39,7 @@
* docutils/parsers/rst/states.py:
- Allow embedded colons in field list field names.
- - Add `rawsource` attribute for text of inline elements and definition
- list terms.
- - Fix: definition list term classifier starting with a reference crash.
+ - Add `rawsource` attribute for text of inline elements.
* docutils/parsers/rst/directives/html.py:
Modified: trunk/docutils/docutils/parsers/rst/states.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/states.py 2018-11-21 13:58:51 UTC (rev 8235)
+++ trunk/docutils/docutils/parsers/rst/states.py 2018-11-21 13:58:57 UTC (rev 8236)
@@ -2855,7 +2855,7 @@
for i in range(len(text_nodes)):
node = text_nodes[i]
if isinstance(node, nodes.Text):
- parts = self.classifier_delimiter.split(node.rawsource)
+ parts = self.classifier_delimiter.split(node)
if len(parts) == 1:
node_list[-1] += node
else:
@@ -2863,9 +2863,8 @@
textnode = nodes.Text(utils.unescape(text, True))
node_list[-1] += textnode
for part in parts[1:]:
- classifier_node = nodes.classifier(
- unescape(part, True), part)
- node_list.append(classifier_node)
+ node_list.append(
+ nodes.classifier(unescape(part, True), part))
else:
node_list[-1] += node
return node_list, messages
Modified: trunk/docutils/test/test_parsers/test_rst/test_definition_lists.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_definition_lists.py 2018-11-21 13:58:51 UTC (rev 8235)
+++ trunk/docutils/test/test_parsers/test_rst/test_definition_lists.py 2018-11-21 13:58:57 UTC (rev 8236)
@@ -246,8 +246,6 @@
Because there's no space before the colon.
Term :not a classifier
Because there's no space after the colon.
-Term \: not a classifier
- Because the colon is escaped.
""",
"""\
<document source="test data">
@@ -264,12 +262,6 @@
<definition>
<paragraph>
Because there's no space after the colon.
- <definition_list_item>
- <term>
- Term : not a classifier
- <definition>
- <paragraph>
- Because the colon is escaped.
"""],
["""\
``Term : not a classifier``
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2018-11-26 21:50:16
|
Revision: 8241
http://sourceforge.net/p/docutils/code/8241
Author: milde
Date: 2018-11-26 21:50:13 +0000 (Mon, 26 Nov 2018)
Log Message:
-----------
Specify Python version requirements in setup.py.
Also drop a version check for no-longer supported versions 3.1 and 3.2.
Patch [ 145 ] by Hugo. Thanks.
Modified Paths:
--------------
trunk/docutils/setup.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py
Modified: trunk/docutils/setup.py
===================================================================
--- trunk/docutils/setup.py 2018-11-21 21:46:06 UTC (rev 8240)
+++ trunk/docutils/setup.py 2018-11-26 21:50:13 UTC (rev 8241)
@@ -122,6 +122,7 @@
'maintainer_email': 'doc...@li...',
'license': 'public domain, Python, 2-Clause BSD, GPL 3 (see COPYING.txt)',
'platforms': 'OS-independent',
+ 'python_requires': '>=2.6, !=3.0.*, !=3.1.*, !=3.2.*',
'package_dir': {'docutils': 'docutils',
'docutils.tools': 'tools'},
'packages': ['docutils',
@@ -194,9 +195,13 @@
'License :: OSI Approved :: BSD License',
'License :: OSI Approved :: GNU General Public License (GPL)',
'Operating System :: OS Independent',
+ 'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
+ 'Programming Language :: Python :: 3.4',
+ 'Programming Language :: Python :: 3.5',
+ 'Programming Language :: Python :: 3.6',
'Topic :: Documentation',
'Topic :: Software Development :: Documentation',
'Topic :: Text Processing',
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py 2018-11-21 21:46:06 UTC (rev 8240)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py 2018-11-26 21:50:13 UTC (rev 8241)
@@ -37,8 +37,7 @@
# CPython has backported to 2.7.4, PyPy has not
# platform.python_implementation is new in 2.6
csv_eod_error_str = 'unexpected end of data'
-if ((3,) < sys.version_info < (3,2,4) or sys.version_info < (2,7,4)
- or platform.python_implementation() == 'PyPy'):
+if sys.version_info < (2,7,4) or platform.python_implementation() == 'PyPy':
csv_eod_error_str = 'newline inside string'
# pypy adds a line number
if sys.version_info > (2, 6) and platform.python_implementation() == 'PyPy':
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2019-02-12 17:41:23
|
Revision: 8244
http://sourceforge.net/p/docutils/code/8244
Author: milde
Date: 2019-02-12 17:41:20 +0000 (Tue, 12 Feb 2019)
Log Message:
-----------
Fix bug #358: Non-breaking space removed from fixed-width literal.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/writers/_html_base.py
trunk/docutils/test/test_writers/test_html4css1_parts.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2018-11-29 08:21:05 UTC (rev 8243)
+++ trunk/docutils/HISTORY.txt 2019-02-12 17:41:20 UTC (rev 8244)
@@ -62,6 +62,10 @@
- Fix bug #331: fixed the "trim" options of the "unicode" directive.
+* docutils/utils/__init__.py:
+
+ - Deprecate `unique_combinations` (obsoleted by `itertools.combinations`).
+
* docutils/utils/smartquotes.py:
- Fix bug #332: use open quote after whitespace, ZWSP, and ZWNJ.
@@ -71,6 +75,10 @@
- automatically add HTML5-compatible meta tags for docinfo items
"authors", "date", and "copyright".
+* docutils/writers/_html_base.py
+
+ - Fix bug #358: Non-breaking space removed from fixed-width literal.
+
* docutils/writers/latex2e/__init__.py:
- Fix bug #323: spurious ``\phantomsection`` and whitespace in
@@ -78,11 +86,7 @@
- Fix bug #324: Invalid LaTeX for table with empty multicolumn cell.
- Fixes to literal block handling.
-* docutils/utils/__init__.py:
- - Deprecate `unique_combinations` (obsoleted by `itertools.combinations`).
-
-
Release 0.14 (2017-08-03)
=========================
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2018-11-29 08:21:05 UTC (rev 8243)
+++ trunk/docutils/docutils/writers/_html_base.py 2019-02-12 17:41:20 UTC (rev 8244)
@@ -183,7 +183,7 @@
stylesheet_link = '<link rel="stylesheet" href="%s" type="text/css" />\n'
embedded_stylesheet = '<style type="text/css">\n\n%s\n</style>\n'
- words_and_spaces = re.compile(r'\S+| +|\n')
+ words_and_spaces = re.compile(r'[^ \n]+| +|\n')
# wrap point inside word:
in_word_wrap_point = re.compile(r'.+\W\W.+|[-?].+', re.U)
lang_attribute = 'lang' # name changes to 'xml:lang' in XHTML 1.1
Modified: trunk/docutils/test/test_writers/test_html4css1_parts.py
===================================================================
--- trunk/docutils/test/test_writers/test_html4css1_parts.py 2018-11-29 08:21:05 UTC (rev 8243)
+++ trunk/docutils/test/test_writers/test_html4css1_parts.py 2019-02-12 17:41:20 UTC (rev 8244)
@@ -56,6 +56,16 @@
'html_head': '''...<title><string></title>\\n'''}
"""],
["""\
+Simple ``inline\xA0literal`` with NBSP
+""",
+"""\
+{'fragment': '''<p>Simple <tt class="docutils literal">inline literal</tt> with NBSP</p>\\n''',
+ 'html_body': '''<div class="document">
+<p>Simple <tt class="docutils literal">inline literal</tt> with NBSP</p>
+</div>\\n''',
+ 'html_head': '''...<title><string></title>\\n'''}
+"""],
+["""\
A simple `anonymous reference`__
__ http://www.test.com/test_url
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2019-02-12 18:16:18
|
Revision: 8247
http://sourceforge.net/p/docutils/code/8247
Author: milde
Date: 2019-02-12 18:16:13 +0000 (Tue, 12 Feb 2019)
Log Message:
-----------
Fix spelling errors (patch #149).
Originally submitted by You-Sheng Yang in Debian.
Modified Paths:
--------------
trunk/docutils/docs/user/config.txt
trunk/docutils/docutils/writers/latex2e/__init__.py
Modified: trunk/docutils/docs/user/config.txt
===================================================================
--- trunk/docutils/docs/user/config.txt 2019-02-12 17:56:51 UTC (rev 8246)
+++ trunk/docutils/docs/user/config.txt 2019-02-12 18:16:13 UTC (rev 8247)
@@ -1581,7 +1581,7 @@
literal_block_env
~~~~~~~~~~~~~~~~~
-When possibile\ [#]_, use the specified environment for `literal blocks`_.
+When possible\ [#]_, use the specified environment for `literal blocks`_.
Default: "" (quoting of whitespace and special chars).
Option: ``--literal-block-env``.
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2019-02-12 17:56:51 UTC (rev 8246)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2019-02-12 18:16:13 UTC (rev 8247)
@@ -170,11 +170,11 @@
'for compound enumerated lists. Default is "-".',
['--section-enumerator-separator'],
{'default': '-', 'metavar': '<char>'}),
- ('When possibile, use the specified environment for literal-blocks. '
+ ('When possible, use the specified environment for literal-blocks. '
'Default is quoting of whitespace and special chars.',
['--literal-block-env'],
{'default': ''}),
- ('When possibile, use verbatim for literal-blocks. '
+ ('When possible, use verbatim for literal-blocks. '
'Compatibility alias for "--literal-block-env=verbatim".',
['--use-verbatim-when-possible'],
{'default': 0, 'action': 'store_true',
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dku...@us...> - 2019-02-12 22:22:22
|
Revision: 8248
http://sourceforge.net/p/docutils/code/8248
Author: dkuhlman
Date: 2019-02-12 22:22:18 +0000 (Tue, 12 Feb 2019)
Log Message:
-----------
Converted odf_odt for compatibility with both Python 2 and Python3
Modified Paths:
--------------
trunk/docutils/docutils/writers/odf_odt/__init__.py
trunk/docutils/test/test_writers/test_odt.py
Modified: trunk/docutils/docutils/writers/odf_odt/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/odf_odt/__init__.py 2019-02-12 18:16:13 UTC (rev 8247)
+++ trunk/docutils/docutils/writers/odf_odt/__init__.py 2019-02-12 22:22:18 UTC (rev 8248)
@@ -1,5 +1,5 @@
# $Id$
-# Author: Dave Kuhlman <dku...@re...>
+# Author: Dave Kuhlman <dku...@da...>
# Copyright: This module has been placed in the public domain.
"""
@@ -20,9 +20,14 @@
from xml.dom import minidom
import time
import re
-import StringIO
+if sys.version_info.major >= 3:
+ from io import StringIO
+ from urllib.request import urlopen
+ from urllib.error import HTTPError
+else:
+ from StringIO import StringIO
+ from urllib2 import urlopen, HTTPError
import copy
-import urllib2
import itertools
import docutils
try:
@@ -41,18 +46,18 @@
#from lxml import etree
#WhichElementTree = 'lxml'
raise ImportError('Ignoring lxml')
-except ImportError, e:
+except ImportError as e:
try:
# 2. Try to use ElementTree from the Python standard library.
from xml.etree import ElementTree as etree
WhichElementTree = 'elementtree'
- except ImportError, e:
+ except ImportError as e:
try:
# 3. Try to use a version of ElementTree installed as a separate
# product.
from elementtree import ElementTree as etree
WhichElementTree = 'elementtree'
- except ImportError, e:
+ except ImportError as e:
s1 = 'Must install either a version of Python containing ' \
'ElementTree (Python version >=2.5) or install ElementTree.'
raise ImportError(s1)
@@ -62,9 +67,13 @@
try:
import pygments
import pygments.lexers
- from pygmentsformatter import OdtPygmentsProgFormatter, \
- OdtPygmentsLaTeXFormatter
-except (ImportError, SyntaxError), exp:
+ if sys.version_info.major >= 3:
+ from .pygmentsformatter import OdtPygmentsProgFormatter, \
+ OdtPygmentsLaTeXFormatter
+ else:
+ from pygmentsformatter import OdtPygmentsProgFormatter, \
+ OdtPygmentsLaTeXFormatter
+except (ImportError, SyntaxError) as exp:
pygments = None
# check for the Python Imaging Library
@@ -299,7 +308,7 @@
def fix_ns(tag, attrib, nsdict):
nstag = add_ns(tag, nsdict)
nsattrib = {}
- for key, val in attrib.iteritems():
+ for key, val in list(attrib.items()):
nskey = add_ns(key, nsdict)
nsattrib[nskey] = val
return nstag, nsattrib
@@ -309,12 +318,12 @@
nstag, name = tag.split(':')
ns = nsdict.get(nstag)
if ns is None:
- raise RuntimeError, 'Invalid namespace prefix: %s' % nstag
+ raise RuntimeError('Invalid namespace prefix: %s' % nstag)
tag = '{%s}%s' % (ns, name,)
return tag
def ToString(et):
- outstream = StringIO.StringIO()
+ outstream = StringIO()
if sys.version_info >= (3, 2):
et.write(outstream, encoding="unicode")
else:
@@ -683,7 +692,7 @@
localtime = time.localtime(time.time())
zinfo = zipfile.ZipInfo(name, localtime)
# Add some standard UNIX file access permissions (-rw-r--r--).
- zinfo.external_attr = (0x81a4 & 0xFFFF) << 16L
+ zinfo.external_attr = (0x81a4 & 0xFFFF) << 16
zinfo.compress_type = compress_type
zfile.writestr(zinfo, bytes)
@@ -694,7 +703,7 @@
continue
try:
zfile.write(source, destination)
- except OSError, e:
+ except OSError as e:
self.document.reporter.warning(
"Can't open file %s." % (source, ))
@@ -895,7 +904,7 @@
document.reporter)
self.format_map = {}
if self.settings.odf_config_file:
- from ConfigParser import ConfigParser
+ from configparser import ConfigParser
parser = ConfigParser()
parser.read(self.settings.odf_config_file)
@@ -995,7 +1004,7 @@
s2 = zfile.read('content.xml')
zfile.close()
else:
- raise RuntimeError, 'stylesheet path (%s) must be %s or .xml file' %(stylespath, extension)
+ raise RuntimeError('stylesheet path (%s) must be %s or .xml file' %(stylespath, extension))
self.str_stylesheet = s1
self.str_stylesheetcontent = s2
self.dom_stylesheet = etree.fromstring(self.str_stylesheet)
@@ -1118,13 +1127,13 @@
def setup_paper(self, root_el):
try:
fin = os.popen("paperconf -s 2> /dev/null")
- w, h = map(float, fin.read().split())
+ w, h = list(map(float, fin.read().split()))
fin.close()
except:
w, h = 612, 792 # default to Letter
def walk(el):
if el.tag == "{%s}page-layout-properties" % SNSD["style"] and \
- not el.attrib.has_key("{%s}page-width" % SNSD["fo"]):
+ "{%s}page-width" % SNSD["fo"] not in el.attrib:
el.attrib["{%s}page-width" % SNSD["fo"]] = "%.3fpt" % w
el.attrib["{%s}page-height" % SNSD["fo"]] = "%.3fpt" % h
el.attrib["{%s}margin-left" % SNSD["fo"]] = \
@@ -1187,7 +1196,7 @@
elcustom = self.create_custom_headfoot(el2,
self.settings.custom_footer, 'footer', automatic_styles)
- code_none, code_field, code_text = range(3)
+ code_none, code_field, code_text = list(range(3))
field_pat = re.compile(r'%(..?)%')
def create_custom_headfoot(self, parent, text, style_name, automatic_styles):
@@ -1203,12 +1212,12 @@
'd1', 'd2', 'd3', 'd4', 'd5',
's', 't', 'a'):
msg = 'bad field spec: %%%s%%' % (item[1], )
- raise RuntimeError, msg
+ raise RuntimeError(msg)
el1 = self.make_field_element(parent,
item[1], style_name, automatic_styles)
if el1 is None:
msg = 'bad field spec: %%%s%%' % (item[1], )
- raise RuntimeError, msg
+ raise RuntimeError(msg)
else:
current_element = el1
else:
@@ -1581,7 +1590,7 @@
return el
def encode(self, text):
- text = text.replace(u'\u00a0', " ")
+ text = text.replace('\n', " ")
return text
#
@@ -1735,7 +1744,7 @@
if self.settings.generate_oowriter_toc:
pass
else:
- if node.has_key('classes') and \
+ if 'classes' in node and \
'auto-toc' in node.attributes['classes']:
el = SubElement(self.current_element, 'text:list', attrib={
'text:style-name': self.rststyle('tocenumlist'),
@@ -2184,7 +2193,7 @@
destination = 'Pictures/1%08x%s' % (self.image_count, filename, )
if source.startswith('http:') or source.startswith('https:'):
try:
- imgfile = urllib2.urlopen(source)
+ imgfile = urlopen(source)
content = imgfile.read()
imgfile.close()
imgfile2 = tempfile.NamedTemporaryFile('wb', delete=False)
@@ -2192,7 +2201,7 @@
imgfile2.close()
imgfilename = imgfile2.name
source = imgfilename
- except urllib2.HTTPError, e:
+ except HTTPError as e:
self.document.reporter.warning(
"Can't open image url %s." % (source, ))
spec = (source, destination,)
@@ -2239,7 +2248,7 @@
unit = '%'
else:
size, unit = self.convert_to_cm(size)
- except ValueError, exp:
+ except ValueError as exp:
self.document.reporter.warning(
'Invalid %s for image: "%s". '
'Error: "%s".' % (
@@ -2358,7 +2367,7 @@
page_width, _ = self.convert_to_cm(page_width)
margin_left, _ = self.convert_to_cm(margin_left)
margin_right, _ = self.convert_to_cm(margin_right)
- except ValueError, exp:
+ except ValueError as exp:
self.document.reporter.warning(
'Stylesheet file contains invalid page width '
'or margin size.')
@@ -2408,7 +2417,7 @@
el2 = SubElement(el1, 'style:text-properties',
attrib=attrib, nsdict=SNSD)
style_name = 'rstframestyle%d' % self.image_style_count
- draw_name = 'graphics%d' % IMAGE_NAME_COUNTER.next()
+ draw_name = 'graphics%d' % next(IMAGE_NAME_COUNTER)
# Add the styles
attrib = {
'style:name': style_name,
@@ -2513,7 +2522,7 @@
attrib['style:wrap'] = 'none'
el2 = SubElement(el1,
'style:graphic-properties', attrib=attrib, nsdict=SNSD)
- draw_name = 'graphics%d' % IMAGE_NAME_COUNTER.next()
+ draw_name = 'graphics%d' % next(IMAGE_NAME_COUNTER)
# Add the content.
#el = SubElement(current_element, 'text:p',
# attrib={'text:style-name': self.rststyle('textbody')})
@@ -2906,7 +2915,7 @@
if 'odt' in formatlist:
rawstr = node.astext()
attrstr = ' '.join(['%s="%s"' % (k, v, )
- for k,v in CONTENT_NAMESPACE_ATTRIB.items()])
+ for k,v in list(CONTENT_NAMESPACE_ATTRIB.items())])
contentstr = '<stuff %s>%s</stuff>' % (attrstr, rawstr, )
if WhichElementTree != "lxml":
contentstr = contentstr.encode("utf-8")
@@ -2933,7 +2942,7 @@
def visit_reference(self, node):
text = node.astext()
if self.settings.create_links:
- if node.has_key('refuri'):
+ if 'refuri' in node:
href = node['refuri']
if ( self.settings.cloak_email_addresses
and href.startswith('mailto:')):
@@ -2943,7 +2952,7 @@
'xlink:type': 'simple',
})
self.set_current_element(el)
- elif node.has_key('refid'):
+ elif 'refid' in node:
if self.settings.create_links:
href = node['refid']
el = self.append_child('text:reference-ref', attrib={
@@ -2960,7 +2969,7 @@
def depart_reference(self, node):
if self.settings.create_links:
- if node.has_key('refuri'):
+ if 'refuri' in node:
self.set_to_parent()
def visit_rubric(self, node):
@@ -3208,8 +3217,8 @@
#
# I don't know how to implement targets in ODF.
# How do we create a target in oowriter? A cross-reference?
- if not (node.has_key('refuri') or node.has_key('refid')
- or node.has_key('refname')):
+ if not ('refuri' in node or 'refid' in node
+ or 'refname' in node):
pass
else:
pass
@@ -3452,7 +3461,7 @@
def generate_admonition(self, node, label, title=None):
if hasattr(self.language, 'labels'):
- translated_label = self.language.labels[label]
+ translated_label = self.language.labels.get(label, label)
else:
translated_label = label
el1 = SubElement(self.current_element, 'text:p', attrib={
Modified: trunk/docutils/test/test_writers/test_odt.py
===================================================================
--- trunk/docutils/test/test_writers/test_odt.py 2019-02-12 18:16:13 UTC (rev 8247)
+++ trunk/docutils/test/test_writers/test_odt.py 2019-02-12 22:22:18 UTC (rev 8248)
@@ -32,7 +32,6 @@
import sys
import os
-import StringIO
import zipfile
from xml.dom import minidom
import tempfile
@@ -60,18 +59,18 @@
#from lxml import etree
#WhichElementTree = 'lxml'
raise ImportError('Ignoring lxml')
- except ImportError, e:
+ except ImportError as e:
try:
# 2. Try to use ElementTree from the Python standard library.
from xml.etree import ElementTree as etree
WhichElementTree = 'elementtree'
- except ImportError, e:
+ except ImportError as e:
try:
# 3. Try to use a version of ElementTree installed as a separate
# product.
from elementtree import ElementTree as etree
WhichElementTree = 'elementtree'
- except ImportError, e:
+ except ImportError as e:
s1 = '\nSkipped test of odf_odt writer. ' \
'In order to test odf_odt writer ' \
'must install either a version of Python containing ' \
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2019-04-15 10:01:12
|
Revision: 8253
http://sourceforge.net/p/docutils/code/8253
Author: milde
Date: 2019-04-15 10:01:10 +0000 (Mon, 15 Apr 2019)
Log Message:
-----------
Apply [ 153 ] Korean mappings by Thomas Sungjin Kang.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/RELEASE-NOTES.txt
trunk/docutils/docutils/utils/smartquotes.py
Added Paths:
-----------
trunk/docutils/docutils/languages/ko.py
trunk/docutils/docutils/parsers/rst/languages/ko.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2019-03-12 17:03:15 UTC (rev 8252)
+++ trunk/docutils/HISTORY.txt 2019-04-15 10:01:10 UTC (rev 8253)
@@ -31,6 +31,11 @@
- Fix [ 348 ] Since Python 3.4, the 'U' universal newlines mode has been
deprecated (thanks to hugovk).
+* docutils/languages/la.py
+ docutils/parsers/rst/languages/la.py:
+
+ - Apply [ 153 ] Korean mappings by Thomas Sungjin Kang.
+
* docutils/nodes.py
- Fix [ 251 ] system_message.copy() TypeError.
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2019-03-12 17:03:15 UTC (rev 8252)
+++ trunk/docutils/RELEASE-NOTES.txt 2019-04-15 10:01:10 UTC (rev 8253)
@@ -81,6 +81,7 @@
- Fixed a bug with the "trim" options of the "unicode" directive.
+* languages: Added Korean (ko) mappings.
Release 0.14 (2017-08-03)
=========================
Added: trunk/docutils/docutils/languages/ko.py
===================================================================
--- trunk/docutils/docutils/languages/ko.py (rev 0)
+++ trunk/docutils/docutils/languages/ko.py 2019-04-15 10:01:10 UTC (rev 8253)
@@ -0,0 +1,61 @@
+# -*- coding: utf-8 -*-
+# $Id$
+# Author: Thomas SJ Kang <tho...@uj...>
+# Copyright: This module has been placed in the public domain.
+
+# New language mappings are welcome. Before doing a new translation, please
+# read <http://docutils.sf.net/docs/howto/i18n.html>. Two files must be
+# translated for each language: one in docutils/languages, the other in
+# docutils/parsers/rst/languages.
+
+"""
+Korean-language mappings for language-dependent features of Docutils.
+"""
+
+__docformat__ = 'reStructuredText'
+
+labels = {
+ # fixed: language-dependent
+ 'author': u'저자',
+ 'authors': u'저자들',
+ 'organization': u'조직',
+ 'address': u'주소',
+ 'contact': u'연락처',
+ 'version': 'Version',
+ 'revision': 'Revision',
+ 'status': u'상태',
+ 'date': u'날짜',
+ 'copyright': u'저작권',
+ 'dedication': u'헌정',
+ 'abstract': u'요약',
+ 'attention': u'집중!',
+ 'caution': u'주의!',
+ 'danger': u'!위험!',
+ 'error': u'오류',
+ 'hint': u'실마리',
+ 'important': u'중요한',
+ 'note': u'비고',
+ 'tip': u'팁',
+ 'warning': u'경고',
+ 'contents': u'목차'}
+"""Mapping of node class name to label text."""
+
+bibliographic_fields = {
+ # language-dependent: fixed
+ u'저자': 'author',
+ u'저자들': 'authors',
+ u'조직': 'organization',
+ u'주소': 'address',
+ u'연락처': 'contact',
+ u'version': 'version',
+ u'revision': 'revision',
+ u'상태': 'status',
+ u'날짜': 'date',
+ u'저작권': 'copyright',
+ u'헌정': 'dedication',
+ u'요약': 'abstract'}
+"""Korean to canonical name mapping for bibliographic fields."""
+
+author_separators = [';', ',']
+"""List of separator strings for the 'Authors' bibliographic field. Tried in
+order."""
Property changes on: trunk/docutils/docutils/languages/ko.py
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Added: trunk/docutils/docutils/parsers/rst/languages/ko.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/languages/ko.py (rev 0)
+++ trunk/docutils/docutils/parsers/rst/languages/ko.py 2019-04-15 10:01:10 UTC (rev 8253)
@@ -0,0 +1,111 @@
+# -*- coding: utf-8 -*-
+# $Id$
+# Author: Thomas SJ Kang <tho...@uj...>
+# Copyright: This module has been placed in the public domain.
+
+# New language mappings are welcome. Before doing a new translation, please
+# read <http://docutils.sf.net/docs/howto/i18n.html>. Two files must be
+# translated for each language: one in docutils/languages, the other in
+# docutils/parsers/rst/languages.
+
+"""
+Korean-language mappings for language-dependent features of
+reStructuredText.
+"""
+
+__docformat__ = 'reStructuredText'
+
+
+directives = {
+ # language-dependent: fixed
+ u'집중': 'attention',
+ u'주의': 'caution',
+ u'코드': 'code',
+ u'코드-블록': 'code',
+ u'소스코드': 'code',
+ u'위험': 'danger',
+ u'오류': 'error',
+ u'실마리': 'hint',
+ u'중요한': 'important',
+ u'비고': 'note',
+ u'팁': 'tip',
+ u'경고': 'warning',
+ u'권고': 'admonition',
+ u'사이드바': 'sidebar',
+ u'주제': 'topic',
+ u'라인-블록': 'line-block',
+ u'파싱된-리터럴': 'parsed-literal',
+ u'지시문': 'rubric',
+ u'제명': 'epigraph',
+ u'하이라이': 'highlights',
+ u'발췌문': 'pull-quote',
+ u'합성어': 'compound',
+ u'컨테이너': 'container',
+ #u'질문': 'questions',
+ u'표': 'table',
+ u'csv-표': 'csv-table',
+ u'list-표': 'list-table',
+ #u'qa': 'questions',
+ #u'faq': 'questions',
+ u'메타': 'meta',
+ u'수학': 'math',
+ #u'이미지맵': 'imagemap',
+ u'이미지': 'image',
+ u'도표': 'figure',
+ u'포함': 'include',
+ 'raw': 'raw',
+ u'대신하다': 'replace',
+ 'unicode': 'unicode',
+ u'날짜': 'date',
+ 'class': 'class',
+ u'역할': 'role',
+ u'기본-역할': 'default-role',
+ u'제목': 'title',
+ u'내용': 'contents',
+ 'sectnum': 'sectnum',
+ u'섹션-번호-매기기': 'sectnum',
+ u'머리말': 'header',
+ u'꼬리말': 'footer',
+ #u'긱주': 'footnotes',
+ #u'인용구': 'citations',
+ u'목표-노트': 'target-notes',
+ u'restructuredtext 테스트 지시어': 'restructuredtext-test-directive'}
+"""Korean name to registered (in directives/__init__.py) directive name
+mapping."""
+
+roles = {
+ # language-dependent: fixed
+ u'약어': 'abbreviation',
+ u'ab': 'abbreviation',
+ u'두음문자': 'acronym',
+ u'ac': 'acronym',
+ u'코드': 'code',
+ u'색인': 'index',
+ u'i': 'index',
+ u'다리-글자': 'subscript',
+ u'sub': 'subscript',
+ u'어깨-글자': 'superscript',
+ u'sup': 'superscript',
+ u'제목-참조': 'title-reference',
+ u'제목': 'title-reference',
+ u't': 'title-reference',
+ u'pep-참조': 'pep-reference',
+ u'pep': 'pep-reference',
+ u'rfc-참조': 'rfc-reference',
+ u'rfc': 'rfc-reference',
+ u'강조': 'emphasis',
+ u'굵게': 'strong',
+ u'기울기': 'literal',
+ u'수학': 'math',
+ u'명명된-참조': 'named-reference',
+ u'익명-참조': 'anonymous-reference',
+ u'각주-참조': 'footnote-reference',
+ u'인용-참조': 'citation-reference',
+ u'대리-참조': 'substitution-reference',
+ u'대상': 'target',
+ u'uri-참조': 'uri-reference',
+ u'uri': 'uri-reference',
+ u'url': 'uri-reference',
+ 'raw': 'raw',}
+"""Mapping of Korean role names to canonical role names for interpreted text.
+"""
Property changes on: trunk/docutils/docutils/parsers/rst/languages/ko.py
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Modified: trunk/docutils/docutils/utils/smartquotes.py
===================================================================
--- trunk/docutils/docutils/utils/smartquotes.py 2019-03-12 17:03:15 UTC (rev 8252)
+++ trunk/docutils/docutils/utils/smartquotes.py 2019-04-15 10:01:10 UTC (rev 8253)
@@ -448,6 +448,7 @@
'it-x-altquot': u'“”‘’',
# 'it-x-altquot2': u'“„‘‚', # [7] in headlines
'ja': u'「」『』',
+ 'ko': u'《》〈〉',
'lt': u'„“‚‘',
'lv': u'„“‚‘',
'mk': u'„“‚‘', # Macedonian, https://mk.wikipedia.org/wiki/Правопис_и_правоговор_на_македонскиот_јазик
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2019-04-15 10:23:36
|
Revision: 8254
http://sourceforge.net/p/docutils/code/8254
Author: milde
Date: 2019-04-15 10:23:34 +0000 (Mon, 15 Apr 2019)
Log Message:
-----------
Apply feature request 63 (support anchors in rfc role).
Modified Paths:
--------------
trunk/docutils/docs/ref/rst/roles.txt
trunk/docutils/docutils/parsers/rst/roles.py
trunk/docutils/test/test_parsers/test_rst/test_interpreted.py
Modified: trunk/docutils/docs/ref/rst/roles.txt
===================================================================
--- trunk/docutils/docs/ref/rst/roles.txt 2019-04-15 10:01:10 UTC (rev 8253)
+++ trunk/docutils/docs/ref/rst/roles.txt 2019-04-15 10:23:34 UTC (rev 8254)
@@ -209,7 +209,10 @@
__ http://www.faqs.org/rfcs/rfc2822.html
+You can link to a specific section by saying :rfc:`number#anchor` (new in
+Docutils 0.15).
+
``:strong:``
============
Modified: trunk/docutils/docutils/parsers/rst/roles.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/roles.py 2019-04-15 10:01:10 UTC (rev 8253)
+++ trunk/docutils/docutils/parsers/rst/roles.py 2019-04-15 10:23:34 UTC (rev 8254)
@@ -276,7 +276,11 @@
def rfc_reference_role(role, rawtext, text, lineno, inliner,
options={}, content=[]):
try:
- rfcnum = int(text)
+ if "#" in text:
+ rfcnum, section = text.split("#", 1)
+ else:
+ rfcnum, section = text, None
+ rfcnum = int(rfcnum)
if rfcnum <= 0:
raise ValueError
except ValueError:
@@ -287,8 +291,10 @@
return [prb], [msg]
# Base URL mainly used by inliner.rfc_reference, so this is correct:
ref = inliner.document.settings.rfc_base_url + inliner.rfc_url % rfcnum
+ if section is not None:
+ ref += "#"+section
set_classes(options)
- node = nodes.reference(rawtext, 'RFC ' + utils.unescape(text), refuri=ref,
+ node = nodes.reference(rawtext, 'RFC ' + utils.unescape(str(rfcnum)), refuri=ref,
**options)
return [node], []
Modified: trunk/docutils/test/test_parsers/test_rst/test_interpreted.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_interpreted.py 2019-04-15 10:01:10 UTC (rev 8253)
+++ trunk/docutils/test/test_parsers/test_rst/test_interpreted.py 2019-04-15 10:23:34 UTC (rev 8254)
@@ -334,6 +334,15 @@
<paragraph>
RFC number must be a number greater than or equal to 1; "0" is invalid.
"""],
+["""\
+:RFC:`2822#section1`
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <reference refuri="http://tools.ietf.org/html/rfc2822.html#section1">
+ RFC 2822
+"""],
]
totest['unknown_roles'] = [
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2019-06-24 17:11:29
|
Revision: 8257
http://sourceforge.net/p/docutils/code/8257
Author: milde
Date: 2019-06-24 17:11:29 +0000 (Mon, 24 Jun 2019)
Log Message:
-----------
Apply [ 152 ] reset `default role` at end of document.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/parsers/rst/__init__.py
trunk/docutils/docutils/parsers/rst/directives/misc.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2019-05-13 07:39:07 UTC (rev 8256)
+++ trunk/docutils/HISTORY.txt 2019-06-24 17:11:29 UTC (rev 8257)
@@ -41,6 +41,10 @@
- Fix [ 251 ] system_message.copy() TypeError.
- Element.copy() also copies `document`, `line`, and `source` attributes.
+* docutils/parsers/rst/__init__.py:
+
+ - Apply [ 152 ] reset `default role` at end of document.
+
* docutils/parsers/rst/states.py:
- Allow embedded colons in field list field names.
Modified: trunk/docutils/docutils/parsers/rst/__init__.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/__init__.py 2019-05-13 07:39:07 UTC (rev 8256)
+++ trunk/docutils/docutils/parsers/rst/__init__.py 2019-06-24 17:11:29 UTC (rev 8257)
@@ -189,6 +189,9 @@
inputstring, tab_width=document.settings.tab_width,
convert_whitespace=True)
self.statemachine.run(inputlines, document, inliner=self.inliner)
+ # restore the "default" default role after parsing a document
+ if '' in roles._roles:
+ del roles._roles['']
self.finish_parse()
Modified: trunk/docutils/docutils/parsers/rst/directives/misc.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/misc.py 2019-05-13 07:39:07 UTC (rev 8256)
+++ trunk/docutils/docutils/parsers/rst/directives/misc.py 2019-06-24 17:11:29 UTC (rev 8257)
@@ -449,7 +449,6 @@
line=self.lineno)
return messages + [error]
roles._roles[''] = role
- # @@@ should this be local to the document, not the parser?
return messages
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gr...@us...> - 2019-07-21 09:34:19
|
Revision: 8274
http://sourceforge.net/p/docutils/code/8274
Author: grubert
Date: 2019-07-21 09:34:17 +0000 (Sun, 21 Jul 2019)
Log Message:
-----------
version to 0.16b.dev
Modified Paths:
--------------
trunk/docutils/README.txt
trunk/docutils/docutils/__init__.py
trunk/docutils/setup.py
trunk/docutils/test/functional/expected/compact_lists.html
trunk/docutils/test/functional/expected/dangerous.html
trunk/docutils/test/functional/expected/field_name_limit.html
trunk/docutils/test/functional/expected/footnotes_html5.html
trunk/docutils/test/functional/expected/math_output_html.html
trunk/docutils/test/functional/expected/math_output_latex.html
trunk/docutils/test/functional/expected/math_output_mathjax.html
trunk/docutils/test/functional/expected/math_output_mathml.xhtml
trunk/docutils/test/functional/expected/misc_rst_html4css1.html
trunk/docutils/test/functional/expected/pep_html.html
trunk/docutils/test/functional/expected/standalone_rst_docutils_xml.xml
trunk/docutils/test/functional/expected/standalone_rst_html4css1.html
trunk/docutils/test/functional/expected/standalone_rst_html5.html
trunk/docutils/test/functional/expected/standalone_rst_s5_html_1.html
trunk/docutils/test/functional/expected/standalone_rst_s5_html_2.html
Modified: trunk/docutils/README.txt
===================================================================
--- trunk/docutils/README.txt 2019-07-21 08:57:36 UTC (rev 8273)
+++ trunk/docutils/README.txt 2019-07-21 09:34:17 UTC (rev 8274)
@@ -1,6 +1,6 @@
-=======================
- README: Docutils 0.15
-=======================
+============================
+ README: Docutils 0.16b.dev
+============================
:Author: David Goodger
:Contact: go...@py...
Modified: trunk/docutils/docutils/__init__.py
===================================================================
--- trunk/docutils/docutils/__init__.py 2019-07-21 08:57:36 UTC (rev 8273)
+++ trunk/docutils/docutils/__init__.py 2019-07-21 09:34:17 UTC (rev 8274)
@@ -56,7 +56,7 @@
__docformat__ = 'reStructuredText'
-__version__ = '0.15'
+__version__ = '0.16b.dev'
"""Docutils version identifier (complies with PEP 440)::
major.minor[.micro][releaselevel[serial]][.dev]
@@ -72,12 +72,12 @@
__version_info__ = VersionInfo(
major=0,
- minor=15,
+ minor=16,
micro=0,
- releaselevel='final', # one of 'alpha', 'beta', 'candidate', 'final'
+ releaselevel='beta', # one of 'alpha', 'beta', 'candidate', 'final'
# pre-release serial number (0 for final releases and active development):
serial=0,
- release=True # True for official releases and pre-releases
+ release=False # True for official releases and pre-releases
)
"""Comprehensive version information tuple. See 'Version Numbering' in
docs/dev/policies.txt."""
Modified: trunk/docutils/setup.py
===================================================================
--- trunk/docutils/setup.py 2019-07-21 08:57:36 UTC (rev 8273)
+++ trunk/docutils/setup.py 2019-07-21 09:34:17 UTC (rev 8274)
@@ -116,7 +116,7 @@
input Docutils supports reStructuredText, an easy-to-read,
what-you-see-is-what-you-get plaintext markup syntax.""", # wrap at col 60
'url': 'http://docutils.sourceforge.net/',
- 'version': '0.15',
+ 'version': '0.16b.dev',
'author': 'David Goodger',
'author_email': 'go...@py...',
'maintainer': 'docutils-develop list',
Modified: trunk/docutils/test/functional/expected/compact_lists.html
===================================================================
--- trunk/docutils/test/functional/expected/compact_lists.html 2019-07-21 08:57:36 UTC (rev 8273)
+++ trunk/docutils/test/functional/expected/compact_lists.html 2019-07-21 09:34:17 UTC (rev 8274)
@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta name="generator" content="Docutils 0.15: http://docutils.sourceforge.net/" />
+<meta name="generator" content="Docutils 0.16b.dev: http://docutils.sourceforge.net/" />
<title>compact_lists.txt</title>
<link rel="stylesheet" href="../input/data/html4css1.css" type="text/css" />
</head>
Modified: trunk/docutils/test/functional/expected/dangerous.html
===================================================================
--- trunk/docutils/test/functional/expected/dangerous.html 2019-07-21 08:57:36 UTC (rev 8273)
+++ trunk/docutils/test/functional/expected/dangerous.html 2019-07-21 09:34:17 UTC (rev 8274)
@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta name="generator" content="Docutils 0.15: http://docutils.sourceforge.net/" />
+<meta name="generator" content="Docutils 0.16b.dev: http://docutils.sourceforge.net/" />
<title>dangerous.txt</title>
<link rel="stylesheet" href="../input/data/html4css1.css" type="text/css" />
</head>
Modified: trunk/docutils/test/functional/expected/field_name_limit.html
===================================================================
--- trunk/docutils/test/functional/expected/field_name_limit.html 2019-07-21 08:57:36 UTC (rev 8273)
+++ trunk/docutils/test/functional/expected/field_name_limit.html 2019-07-21 09:34:17 UTC (rev 8274)
@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta name="generator" content="Docutils 0.15: http://docutils.sourceforge.net/" />
+<meta name="generator" content="Docutils 0.16b.dev: http://docutils.sourceforge.net/" />
<title>field_list.txt</title>
<link rel="stylesheet" href="../input/data/html4css1.css" type="text/css" />
</head>
Modified: trunk/docutils/test/functional/expected/footnotes_html5.html
===================================================================
--- trunk/docutils/test/functional/expected/footnotes_html5.html 2019-07-21 08:57:36 UTC (rev 8273)
+++ trunk/docutils/test/functional/expected/footnotes_html5.html 2019-07-21 09:34:17 UTC (rev 8274)
@@ -2,7 +2,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="utf-8"/>
-<meta name="generator" content="Docutils 0.15: http://docutils.sourceforge.net/" />
+<meta name="generator" content="Docutils 0.16b.dev: http://docutils.sourceforge.net/" />
<title>Test footnote and citation rendering</title>
<link rel="stylesheet" href="../input/data/minimal.css" type="text/css" />
<link rel="stylesheet" href="../input/data/plain.css" type="text/css" />
Modified: trunk/docutils/test/functional/expected/math_output_html.html
===================================================================
--- trunk/docutils/test/functional/expected/math_output_html.html 2019-07-21 08:57:36 UTC (rev 8273)
+++ trunk/docutils/test/functional/expected/math_output_html.html 2019-07-21 09:34:17 UTC (rev 8274)
@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta name="generator" content="Docutils 0.15: http://docutils.sourceforge.net/" />
+<meta name="generator" content="Docutils 0.16b.dev: http://docutils.sourceforge.net/" />
<title>Mathematics</title>
<link rel="stylesheet" href="../input/data/html4css1.css" type="text/css" />
<link rel="stylesheet" href="../input/data/math.css" type="text/css" />
Modified: trunk/docutils/test/functional/expected/math_output_latex.html
===================================================================
--- trunk/docutils/test/functional/expected/math_output_latex.html 2019-07-21 08:57:36 UTC (rev 8273)
+++ trunk/docutils/test/functional/expected/math_output_latex.html 2019-07-21 09:34:17 UTC (rev 8274)
@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta name="generator" content="Docutils 0.15: http://docutils.sourceforge.net/" />
+<meta name="generator" content="Docutils 0.16b.dev: http://docutils.sourceforge.net/" />
<title>Mathematics</title>
<link rel="stylesheet" href="../input/data/html4css1.css" type="text/css" />
</head>
Modified: trunk/docutils/test/functional/expected/math_output_mathjax.html
===================================================================
--- trunk/docutils/test/functional/expected/math_output_mathjax.html 2019-07-21 08:57:36 UTC (rev 8273)
+++ trunk/docutils/test/functional/expected/math_output_mathjax.html 2019-07-21 09:34:17 UTC (rev 8274)
@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta name="generator" content="Docutils 0.15: http://docutils.sourceforge.net/" />
+<meta name="generator" content="Docutils 0.16b.dev: http://docutils.sourceforge.net/" />
<title>Mathematics</title>
<script type="text/javascript" src="/usr/share/javascript/mathjax/MathJax.js?config=TeX-AMS_CHTML"></script>
<link rel="stylesheet" href="../input/data/html4css1.css" type="text/css" />
Modified: trunk/docutils/test/functional/expected/math_output_mathml.xhtml
===================================================================
--- trunk/docutils/test/functional/expected/math_output_mathml.xhtml 2019-07-21 08:57:36 UTC (rev 8273)
+++ trunk/docutils/test/functional/expected/math_output_mathml.xhtml 2019-07-21 09:34:17 UTC (rev 8274)
@@ -2,7 +2,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="utf-8"/>
-<meta name="generator" content="Docutils 0.15: http://docutils.sourceforge.net/" />
+<meta name="generator" content="Docutils 0.16b.dev: http://docutils.sourceforge.net/" />
<title>Mathematics</title>
<link rel="stylesheet" href="../input/data/minimal.css" type="text/css" />
<link rel="stylesheet" href="../input/data/plain.css" type="text/css" />
Modified: trunk/docutils/test/functional/expected/misc_rst_html4css1.html
===================================================================
--- trunk/docutils/test/functional/expected/misc_rst_html4css1.html 2019-07-21 08:57:36 UTC (rev 8273)
+++ trunk/docutils/test/functional/expected/misc_rst_html4css1.html 2019-07-21 09:34:17 UTC (rev 8274)
@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta name="generator" content="Docutils 0.15: http://docutils.sourceforge.net/" />
+<meta name="generator" content="Docutils 0.16b.dev: http://docutils.sourceforge.net/" />
<title>link_in_substitution.txt</title>
<link rel="stylesheet" href="foo&bar.css" type="text/css" />
</head>
Modified: trunk/docutils/test/functional/expected/pep_html.html
===================================================================
--- trunk/docutils/test/functional/expected/pep_html.html 2019-07-21 08:57:36 UTC (rev 8273)
+++ trunk/docutils/test/functional/expected/pep_html.html 2019-07-21 09:34:17 UTC (rev 8274)
@@ -8,7 +8,7 @@
-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta name="generator" content="Docutils 0.15: http://docutils.sourceforge.net/" />
+ <meta name="generator" content="Docutils 0.16b.dev: http://docutils.sourceforge.net/" />
<title>PEP 100 -- Test PEP</title>
<link rel="stylesheet" href="../input/data/html4css1.css" type="text/css" />
</head>
Modified: trunk/docutils/test/functional/expected/standalone_rst_docutils_xml.xml
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_docutils_xml.xml 2019-07-21 08:57:36 UTC (rev 8273)
+++ trunk/docutils/test/functional/expected/standalone_rst_docutils_xml.xml 2019-07-21 09:34:17 UTC (rev 8274)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE document PUBLIC "+//IDN docutils.sourceforge.net//DTD Docutils Generic//EN//XML" "http://docutils.sourceforge.net/docs/ref/docutils.dtd">
-<!-- Generated by Docutils 0.15 -->
+<!-- Generated by Docutils 0.16b.dev -->
<document ids="restructuredtext-test-document doctitle" names="restructuredtext\ test\ document doctitle" source="functional/input/standalone_rst_docutils_xml.txt" title="reStructuredText Test Document">
<title>reStructuredText Test Document</title>
<subtitle ids="examples-of-syntax-constructs subtitle" names="examples\ of\ syntax\ constructs subtitle">Examples of Syntax Constructs</subtitle>
Modified: trunk/docutils/test/functional/expected/standalone_rst_html4css1.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html4css1.html 2019-07-21 08:57:36 UTC (rev 8273)
+++ trunk/docutils/test/functional/expected/standalone_rst_html4css1.html 2019-07-21 09:34:17 UTC (rev 8274)
@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta name="generator" content="Docutils 0.15: http://docutils.sourceforge.net/" />
+<meta name="generator" content="Docutils 0.16b.dev: http://docutils.sourceforge.net/" />
<title>reStructuredText Test Document</title>
<meta name="author" content="David Goodger" />
<meta name="authors" content="Me Myself I" />
Modified: trunk/docutils/test/functional/expected/standalone_rst_html5.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html5.html 2019-07-21 08:57:36 UTC (rev 8273)
+++ trunk/docutils/test/functional/expected/standalone_rst_html5.html 2019-07-21 09:34:17 UTC (rev 8274)
@@ -2,7 +2,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="utf-8"/>
-<meta name="generator" content="Docutils 0.15: http://docutils.sourceforge.net/" />
+<meta name="generator" content="Docutils 0.16b.dev: http://docutils.sourceforge.net/" />
<title>reStructuredText Test Document</title>
<meta name="author" content="David Goodger" />
<meta name="author" content="Me" />
Modified: trunk/docutils/test/functional/expected/standalone_rst_s5_html_1.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_s5_html_1.html 2019-07-21 08:57:36 UTC (rev 8273)
+++ trunk/docutils/test/functional/expected/standalone_rst_s5_html_1.html 2019-07-21 09:34:17 UTC (rev 8274)
@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta name="generator" content="Docutils 0.15: http://docutils.sourceforge.net/" />
+<meta name="generator" content="Docutils 0.16b.dev: http://docutils.sourceforge.net/" />
<meta name="version" content="S5 1.1" />
<title>Slide Shows</title>
<meta name="author" content="David Goodger" />
Modified: trunk/docutils/test/functional/expected/standalone_rst_s5_html_2.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_s5_html_2.html 2019-07-21 08:57:36 UTC (rev 8273)
+++ trunk/docutils/test/functional/expected/standalone_rst_s5_html_2.html 2019-07-21 09:34:17 UTC (rev 8274)
@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta name="generator" content="Docutils 0.15: http://docutils.sourceforge.net/" />
+<meta name="generator" content="Docutils 0.16b.dev: http://docutils.sourceforge.net/" />
<meta name="version" content="S5 1.1" />
<title>Slide Shows</title>
<meta name="author" content="David Goodger" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gr...@us...> - 2019-07-22 12:36:08
|
Revision: 8282
http://sourceforge.net/p/docutils/code/8282
Author: grubert
Date: 2019-07-22 12:36:07 +0000 (Mon, 22 Jul 2019)
Log Message:
-----------
Apply patch #157: In test/test_io.py method test_deprecation_warning ...
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/test/test_io.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2019-07-22 10:37:31 UTC (rev 8281)
+++ trunk/docutils/HISTORY.txt 2019-07-22 12:36:07 UTC (rev 8282)
@@ -18,6 +18,10 @@
* Drop Python 2.6 support (gradually).
+* Apply patch #157: In test/test_io.py method test_deprecation_warning,
+ close FileInput to avoid test failure because of a ResourceWarning when
+ PYTHONWARNINGS=default is set.
+
Release 0.15 (2019-07-20)
=========================
Modified: trunk/docutils/test/test_io.py
===================================================================
--- trunk/docutils/test/test_io.py 2019-07-22 10:37:31 UTC (rev 8281)
+++ trunk/docutils/test/test_io.py 2019-07-22 12:36:07 UTC (rev 8282)
@@ -142,7 +142,7 @@
# Act
# Trigger a warning?
- io.FileInput(source_path='data/include.txt')
+ io.FileInput(source_path='data/include.txt').close()
# Assert
self.assertEqual(len(w), 0, "Expected no warnings, got %s" %
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2019-07-22 19:51:27
|
Revision: 8284
http://sourceforge.net/p/docutils/code/8284
Author: milde
Date: 2019-07-22 19:51:25 +0000 (Mon, 22 Jul 2019)
Log Message:
-----------
Unescape null-escaped content in nodes.Text.astext().
Store the null-escaped text in the doctree nodes and unescape in
nodes.Text.astext(). Enables functions and transforms processing Text nodes
to respect backslash escapes.
Provides backslash-escaping of the `author separator` in the "authors"
docinfo field and the `classifier delimiter` in definition list terms.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/RELEASE-NOTES.txt
trunk/docutils/docutils/parsers/rst/roles.py
trunk/docutils/docutils/parsers/rst/states.py
trunk/docutils/test/test_parsers/test_rst/test_definition_lists.py
trunk/docutils/test/test_transforms/test_docinfo.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2019-07-22 13:06:55 UTC (rev 8283)
+++ trunk/docutils/HISTORY.txt 2019-07-22 19:51:25 UTC (rev 8284)
@@ -16,12 +16,24 @@
Changes Since 0.15
==================
-* Drop Python 2.6 support (gradually).
+* General
-* Apply patch #157: In test/test_io.py method test_deprecation_warning,
- close FileInput to avoid test failure because of a ResourceWarning when
- PYTHONWARNINGS=default is set.
+ - Dropped support for Python 2.6 (work in progress).
+ - Keep `backslash escapes`__ in the document tree. Backslash characters in
+ text are be represented by NULL characters in the ``text`` attribute of
+ Doctree nodes and removed in the writing stage by the node's
+ ``astext()`` method.
+ __ http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#escaping-mechanism
+
+
+* test/test_io.py:
+
+ - Apply patch #157: In method test_deprecation_warning, close
+ ``FileInput`` to avoid test failure because of a ``ResourceWarning``
+ when ``PYTHONWARNINGS=default`` is set.
+
+
Release 0.15 (2019-07-20)
=========================
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2019-07-22 13:06:55 UTC (rev 8283)
+++ trunk/docutils/RELEASE-NOTES.txt 2019-07-22 19:51:25 UTC (rev 8284)
@@ -22,9 +22,6 @@
Future changes
==============
-* Drop support for Python 2.6, 3.3, and 3.4 immediately after the 0.15
- release.
-
* The "latex" writer will handle admonitions like other block-level elements
and wrap them in a "DUclass" environment. The current implementation fails
with some content, see docs/user/latex.txt and
@@ -37,15 +34,6 @@
* Remove `utils.unique_combinations` (obsoleted by `itertools.combinations`).
-* Currently, the rST `escape mechanism`__ cannot be used in transforms.
- In Docutils > 0.15, backslash characters in text will be represented by
- NULL characters in the "text" attribute of Doctree nodes and be removed
- in the writing stage by the node's ``astext()`` method.
- Allows fixing bugs #353__, #342, and #332.
-
- __ http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#escaping-mechanism
- __ https://sourceforge.net/p/docutils/bugs/353/
-
* The default HTML writer "html" with frontend ``rst2html.py`` may change
from "html4css1" to "html5".
@@ -63,6 +51,21 @@
__ docs/ref/rst/restructuredtext.html#bibliographic-fields
+Release 0.16
+============
+
+.. Note::
+
+ Docutils 0.15.x is the last version supporting Python 2.6, 3.3, and 3.4.
+
+ Docutils 0.16 is compatible with Python versions 2.7 and 3.5 to 3.7.
+ (cf. `Python 3 compatibility`_).
+
+* Keep `backslash escapes`__ in the document tree.
+
+ __ http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#escaping-mechanism
+
+
Release 0.15
============
@@ -81,11 +84,9 @@
- Fixed a bug with the "trim" options of the "unicode" directive.
-* languages: Added Korean (ko) mappings and latin.
+* languages: Added Korean localisation (ko).
-* Several fixes to keep mor information on source in parsed elements,
- isolate documents roles from other documents parsed, smartquotes,
- table gets width and latex table multicolumn cells, ...
+* Bugfixes (see HISTORY.txt).
Release 0.14 (2017-08-03)
Modified: trunk/docutils/docutils/parsers/rst/roles.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/roles.py 2019-07-22 13:06:55 UTC (rev 8283)
+++ trunk/docutils/docutils/parsers/rst/roles.py 2019-07-22 19:51:25 UTC (rev 8284)
@@ -195,7 +195,7 @@
def __call__(self, role, rawtext, text, lineno, inliner,
options={}, content=[]):
set_classes(options)
- return [self.node_class(rawtext, utils.unescape(text), **options)], []
+ return [self.node_class(rawtext, text, **options)], []
class CustomRole:
@@ -234,7 +234,7 @@
# Once nested inline markup is implemented, this and other methods should
# recursively call inliner.nested_parse().
set_classes(options)
- return [nodes.inline(rawtext, utils.unescape(text), **options)], []
+ return [nodes.inline(rawtext, text, **options)], []
generic_custom_role.options = {'class': directives.class_option}
@@ -255,7 +255,7 @@
def pep_reference_role(role, rawtext, text, lineno, inliner,
options={}, content=[]):
try:
- pepnum = int(text)
+ pepnum = int(utils.unescape(text))
if pepnum < 0 or pepnum > 9999:
raise ValueError
except ValueError:
@@ -268,7 +268,7 @@
ref = (inliner.document.settings.pep_base_url
+ inliner.document.settings.pep_file_url_template % pepnum)
set_classes(options)
- return [nodes.reference(rawtext, 'PEP ' + utils.unescape(text), refuri=ref,
+ return [nodes.reference(rawtext, 'PEP ' + text, refuri=ref,
**options)], []
register_canonical_role('pep-reference', pep_reference_role)
Modified: trunk/docutils/docutils/parsers/rst/states.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/states.py 2019-07-22 13:06:55 UTC (rev 8283)
+++ trunk/docutils/docutils/parsers/rst/states.py 2019-07-22 19:51:25 UTC (rev 8284)
@@ -713,12 +713,13 @@
return (string[:matchend], [], string[matchend:], [], '')
endmatch = end_pattern.search(string[matchend:])
if endmatch and endmatch.start(1): # 1 or more chars
- _text = endmatch.string[:endmatch.start(1)]
- text = unescape(_text, restore_backslashes)
+ text = endmatch.string[:endmatch.start(1)]
+ if restore_backslashes:
+ text = unescape(text, True)
textend = matchend + endmatch.end(1)
rawsource = unescape(string[matchstart:textend], True)
node = nodeclass(rawsource, text)
- node[0].rawsource = unescape(_text, True)
+ node[0].rawsource = unescape(text, True)
return (string[:matchstart], [node],
string[textend:], [], endmatch.group(1))
msg = self.reporter.warning(
@@ -725,8 +726,7 @@
'Inline %s start-string without end-string.'
% nodeclass.__name__, line=lineno)
text = unescape(string[matchstart:matchend], True)
- rawsource = unescape(string[matchstart:matchend], True)
- prb = self.problematic(text, rawsource, msg)
+ prb = self.problematic(text, text, msg)
return string[:matchstart], [prb], string[matchend:], [msg], ''
def problematic(self, text, rawsource, message):
@@ -784,7 +784,7 @@
prb = self.problematic(text, text, msg)
return string[:rolestart], [prb], string[textend:], [msg]
return self.phrase_ref(string[:matchstart], string[textend:],
- rawsource, escaped, unescape(escaped))
+ rawsource, escaped)
else:
rawsource = unescape(string[rolestart:textend], True)
nodelist, messages = self.interpreted(rawsource, escaped, role,
@@ -798,26 +798,30 @@
prb = self.problematic(text, text, msg)
return string[:matchstart], [prb], string[matchend:], [msg]
- def phrase_ref(self, before, after, rawsource, escaped, text):
+ def phrase_ref(self, before, after, rawsource, escaped, text=None):
+ # `text` is ignored (since 0.16)
match = self.patterns.embedded_link.search(escaped)
if match: # embedded <URI> or <alias_>
- text = unescape(escaped[:match.start(0)])
- rawtext = unescape(escaped[:match.start(0)], True)
- aliastext = unescape(match.group(2))
- rawaliastext = unescape(match.group(2), True)
+ text = escaped[:match.start(0)]
+ unescaped = unescape(text)
+ rawtext = unescape(text, True)
+ aliastext = match.group(2)
+ rawaliastext = unescape(aliastext, True)
underscore_escaped = rawaliastext.endswith(r'\_')
if aliastext.endswith('_') and not (underscore_escaped
or self.patterns.uri.match(aliastext)):
aliastype = 'name'
- alias = normalize_name(aliastext[:-1])
+ alias = normalize_name(unescape(aliastext[:-1]))
target = nodes.target(match.group(1), refname=alias)
- target.indirect_reference_name = aliastext[:-1]
+ target.indirect_reference_name = whitespace_normalize_name(
+ unescape(aliastext[:-1]))
else:
aliastype = 'uri'
+ # remove unescaped whitespace
alias_parts = split_escaped_whitespace(match.group(2))
- alias = ' '.join(''.join(unescape(part).split())
+ alias = ' '.join(''.join(part.split())
for part in alias_parts)
- alias = self.adjust_uri(alias)
+ alias = self.adjust_uri(unescape(alias))
if alias.endswith(r'\_'):
alias = alias[:-2] + '_'
target = nodes.target(match.group(1), refuri=alias)
@@ -827,14 +831,17 @@
% aliastext)
if not text:
text = alias
+ unescaped = unescape(text)
rawtext = rawaliastext
else:
+ text = escaped
+ unescaped = unescape(text)
target = None
rawtext = unescape(escaped, True)
- refname = normalize_name(text)
+ refname = normalize_name(unescaped)
reference = nodes.reference(rawsource, text,
- name=whitespace_normalize_name(text))
+ name=whitespace_normalize_name(unescaped))
reference[0].rawsource = rawtext
node_list = [reference]
@@ -991,11 +998,9 @@
else:
addscheme = ''
text = match.group('whole')
- unescaped = unescape(text)
- rawsource = unescape(text, True)
- reference = nodes.reference(rawsource, unescaped,
- refuri=addscheme + unescaped)
- reference[0].rawsource = rawsource
+ refuri = addscheme + unescape(text)
+ reference = nodes.reference(unescape(text, True), text,
+ refuri=refuri)
return [reference]
else: # not a valid scheme
raise MarkupMismatch
@@ -1003,15 +1008,14 @@
def pep_reference(self, match, lineno):
text = match.group(0)
if text.startswith('pep-'):
- pepnum = int(match.group('pepnum1'))
+ pepnum = int(unescape(match.group('pepnum1')))
elif text.startswith('PEP'):
- pepnum = int(match.group('pepnum2'))
+ pepnum = int(unescape(match.group('pepnum2')))
else:
raise MarkupMismatch
ref = (self.document.settings.pep_base_url
+ self.document.settings.pep_file_url_template % pepnum)
- unescaped = unescape(text)
- return [nodes.reference(unescape(text, True), unescaped, refuri=ref)]
+ return [nodes.reference(unescape(text, True), text, refuri=ref)]
rfc_url = 'rfc%d.html'
@@ -1018,12 +1022,11 @@
def rfc_reference(self, match, lineno):
text = match.group(0)
if text.startswith('RFC'):
- rfcnum = int(match.group('rfcnum'))
+ rfcnum = int(unescape(match.group('rfcnum')))
ref = self.document.settings.rfc_base_url + self.rfc_url % rfcnum
else:
raise MarkupMismatch
- unescaped = unescape(text)
- return [nodes.reference(unescape(text, True), unescaped, refuri=ref)]
+ return [nodes.reference(unescape(text, True), text, refuri=ref)]
def implicit_inline(self, text, lineno):
"""
@@ -1045,7 +1048,7 @@
self.implicit_inline(text[match.end():], lineno))
except MarkupMismatch:
pass
- return [nodes.Text(unescape(text), rawsource=unescape(text, True))]
+ return [nodes.Text(text, unescape(text, True))]
dispatch = {'*': emphasis,
'**': strong,
@@ -2860,7 +2863,7 @@
node_list[-1] += node
else:
text = parts[0].rstrip()
- textnode = nodes.Text(utils.unescape(text, True))
+ textnode = nodes.Text(text, unescape(text, True))
node_list[-1] += textnode
for part in parts[1:]:
node_list.append(
Modified: trunk/docutils/test/test_parsers/test_rst/test_definition_lists.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_definition_lists.py 2019-07-22 13:06:55 UTC (rev 8283)
+++ trunk/docutils/test/test_parsers/test_rst/test_definition_lists.py 2019-07-22 19:51:25 UTC (rev 8284)
@@ -246,6 +246,8 @@
Because there's no space before the colon.
Term :not a classifier
Because there's no space after the colon.
+Term \: not a classifier
+ Because the colon is escaped.
""",
"""\
<document source="test data">
@@ -262,6 +264,12 @@
<definition>
<paragraph>
Because there's no space after the colon.
+ <definition_list_item>
+ <term>
+ Term : not a classifier
+ <definition>
+ <paragraph>
+ Because the colon is escaped.
"""],
["""\
``Term : not a classifier``
Modified: trunk/docutils/test/test_transforms/test_docinfo.py
===================================================================
--- trunk/docutils/test/test_transforms/test_docinfo.py 2019-07-22 13:06:55 UTC (rev 8283)
+++ trunk/docutils/test/test_transforms/test_docinfo.py 2019-07-22 19:51:25 UTC (rev 8284)
@@ -230,49 +230,49 @@
<author>
One, Only
"""],
-# [r""":Authors: Me\, Myself; **I**
-# :Authors: Pac\;Man\\; Ms. Pac\Man; Pac\ Man, Jr.
-# :Authors:
-# Here
-#
-# The\re
-#
-# *Every\ where*
-# :Authors: - First\\
-# - Se\ cond
-# - Thir\d
-# """,
-# """\
-# <document source="test data">
-# <docinfo>
-# <authors>
-# <author>
-# Me, Myself
-# <author>
-# I
-# <authors>
-# <author>
-# Pac;Man\\
-# <author>
-# Ms. PacMan
-# <author>
-# PacMan, Jr.
-# <authors>
-# <author>
-# Here
-# <author>
-# There
-# <author>
-# <emphasis>
-# Everywhere
-# <authors>
-# <author>
-# First\\
-# <author>
-# Second
-# <author>
-# Third
-# """],
+[r""":Authors: Me\, Myself; **I**
+:Authors: Pac\;Man\\; Ms. Pac\Man; Pac\ Man, Jr.
+:Authors:
+ Here
+
+ The\re
+
+ *Every\ where*
+:Authors: - First\\
+ - Se\ cond
+ - Thir\d
+""",
+"""\
+<document source="test data">
+ <docinfo>
+ <authors>
+ <author>
+ Me, Myself
+ <author>
+ I
+ <authors>
+ <author>
+ Pac;Man\\
+ <author>
+ Ms. PacMan
+ <author>
+ PacMan, Jr.
+ <authors>
+ <author>
+ Here
+ <author>
+ There
+ <author>
+ <emphasis>
+ Everywhere
+ <authors>
+ <author>
+ First\\
+ <author>
+ Second
+ <author>
+ Third
+"""],
["""\
:Authors:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2019-07-23 19:56:42
|
Revision: 8294
http://sourceforge.net/p/docutils/code/8294
Author: milde
Date: 2019-07-23 19:56:40 +0000 (Tue, 23 Jul 2019)
Log Message:
-----------
Fix [ 366 ] - move unescape() definition to `nodes`
to avoid circular import dependency.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/nodes.py
trunk/docutils/docutils/utils/__init__.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2019-07-23 10:20:37 UTC (rev 8293)
+++ trunk/docutils/HISTORY.txt 2019-07-23 19:56:40 UTC (rev 8294)
@@ -28,7 +28,11 @@
__ http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#escaping-mechanism
+* docutils/utils/__init__.py
+ - unescape() definition moved to `nodes` to avoid circular import
+ dependency. Fixes [ 366 ].
+
* test/test_io.py:
- Apply patch #157: In method test_deprecation_warning, close
Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py 2019-07-23 10:20:37 UTC (rev 8293)
+++ trunk/docutils/docutils/nodes.py 2019-07-23 19:56:40 UTC (rev 8294)
@@ -29,8 +29,6 @@
import types
import unicodedata
-import docutils.utils
-
# ==============================
# Functional Node Base Classes
# ==============================
@@ -322,7 +320,21 @@
return s.encode('ascii', 'backslashreplace')
return s
+# definition moved here from `utils` to avoid circular import dependency
+def unescape(text, restore_backslashes=False, respect_whitespace=False):
+ """
+ Return a string with nulls removed or restored to backslashes.
+ Backslash-escaped spaces are also removed.
+ """
+ # `respect_whitespace` is ignored (since introduction 2016-12-16)
+ if restore_backslashes:
+ return text.replace('\x00', '\\')
+ else:
+ for sep in ['\x00 ', '\x00\n', '\x00']:
+ text = ''.join(text.split(sep))
+ return text
+
class Text(Node, reprunicode):
"""
@@ -364,7 +376,7 @@
return domroot.createTextNode(unicode(self))
def astext(self):
- return reprunicode(docutils.utils.unescape(self))
+ return reprunicode(unescape(self))
# Note about __unicode__: The implementation of __unicode__ here,
# and the one raising NotImplemented in the superclass Node had
Modified: trunk/docutils/docutils/utils/__init__.py
===================================================================
--- trunk/docutils/docutils/utils/__init__.py 2019-07-23 10:20:37 UTC (rev 8293)
+++ trunk/docutils/docutils/utils/__init__.py 2019-07-23 19:56:40 UTC (rev 8294)
@@ -18,6 +18,7 @@
import unicodedata
from docutils import ApplicationError, DataError, __version_info__
from docutils import nodes
+from docutils.nodes import unescape
import docutils.io
from docutils.utils.error_reporting import ErrorOutput, SafeString
@@ -576,18 +577,7 @@
parts.append('\x00' + text[found+1:found+2])
start = found + 2 # skip character after escape
-def unescape(text, restore_backslashes=False, respect_whitespace=False):
- """
- Return a string with nulls removed or restored to backslashes.
- Backslash-escaped spaces are also removed.
- """
- # `respect_whitespace` is ignored (since introduction 2016-12-16)
- if restore_backslashes:
- return text.replace('\x00', '\\')
- else:
- for sep in ['\x00 ', '\x00\n', '\x00']:
- text = ''.join(text.split(sep))
- return text
+# `unescape` definition moved to `nodes` to avoid circular import dependency.
def split_escaped_whitespace(text):
"""
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2019-07-24 10:52:25
|
Revision: 8301
http://sourceforge.net/p/docutils/code/8301
Author: milde
Date: 2019-07-24 10:52:23 +0000 (Wed, 24 Jul 2019)
Log Message:
-----------
Fix #332 and #342 (smartquotes problems).
Standard backslash escape for smartquotes.
No escape in roles descending from `inline literal`.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docs/user/smartquotes.txt
trunk/docutils/docutils/transforms/universal.py
trunk/docutils/docutils/utils/smartquotes.py
trunk/docutils/test/test_transforms/test_smartquotes.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2019-07-24 10:35:57 UTC (rev 8300)
+++ trunk/docutils/HISTORY.txt 2019-07-24 10:52:23 UTC (rev 8301)
@@ -33,11 +33,14 @@
- unescape() definition moved to `nodes` to avoid circular import
dependency. Fixes [ 366 ].
+* docutils/transforms/universal.py
+
+ - Fix [ 332 ]: Standard backslash escape for smartquotes.
+ Fix [ 342 ]: No escape in roles descending from `inline literal`.
+
* test/test_io.py:
- - Apply patch #157: In method test_deprecation_warning, close
- ``FileInput`` to avoid test failure because of a ``ResourceWarning``
- when ``PYTHONWARNINGS=default`` is set.
+ - Apply patch #157: avoid test failure because of a ``ResourceWarning``.
Release 0.15.1 (2019-07-24)
===========================
Modified: trunk/docutils/docs/user/smartquotes.txt
===================================================================
--- trunk/docutils/docs/user/smartquotes.txt 2019-07-24 10:35:57 UTC (rev 8300)
+++ trunk/docutils/docs/user/smartquotes.txt 2019-07-24 10:52:23 UTC (rev 8301)
@@ -5,8 +5,8 @@
:Author: Günter Milde,
based on SmartyPants by John Gruber, Brad Choate, and Chad Miller
:Contact: doc...@li...
-:Revision: $Revision$
-:Date: $Date$
+:Revision: $Revision: 8112 $
+:Date: $Date: 2017-06-14 16:20:20 +0200 (Mi, 14. Jun 2017) $
:License: Released under the terms of the `2-Clause BSD license`_
:Abstract: This document describes the Docutils `smartquotes` module.
@@ -25,20 +25,20 @@
- three consecutive dots (``...`` or ``. . .``) into an ellipsis entity.
This means you can write, edit, and save your documents using plain old
-ASCII---straight quotes, plain dashes, and plain dots---while Docutils
+ASCII -- straight quotes, plain dashes, and plain dots -- while Docutils
generates documents with typographical quotes, dashes, and ellipses.
Advantages:
-* typing speed (especially when blind-typing),
-* the possibility to change the quoting style of the
- complete document with just one configuration option, and
-* restriction to 7-bit characters in the source.
+* Typing speed (especially when blind-typing).
+* The possibility to change the quoting style of the
+ complete document with just one configuration option.
+* Typographical quotes with just 7-bit ASCII characters in the source.
However, there are `algorithmic shortcomings`_ for 2 reasons:
-* Dual use of the "ASCII-apostrophe" (') as single quote and apostrophe,
-* languages that do not use whitespace around words.
+* Dual use of the "ASCII-apostrophe" (') as single quote and apostrophe.
+* Languages that do not use whitespace around words.
So, please consider also
`Why You Might Not Want to Use "Smart" Quotes in Your Documents`_.
@@ -54,24 +54,27 @@
such as source code, maths, or literal blocks.
If you need literal straight quotes (or plain hyphens and periods) in normal
-text, you can backslash escape the characters to preserve
-ASCII-punctuation. You need two backslashes as one backslash is removed by
-the reStructuredText `escaping mechanism`_.
+text, you can `backslash escape`_ the characters to preserve
+ASCII-punctuation.
-======== ========= ======== =========
-Escape Character Escape Character
-======== ========= ======== =========
-``\\`` \\ ``\\.`` \\.
-``\\"`` \\" ``\\-`` \\-
-``\\'`` \\' ``\\``` \\`
-======== ========= ======== =========
+.. class:: booktabs
+========= ========= == ======== ==========
+Input Output Input Output
+========= ========= == ======== ==========
+``\\`` \\ ``\...`` \...
+``\"`` \" ``\--`` \--
+``\'`` \' ``\``` \`
+========= ========= == ======== ==========
+
This is useful, for example, when you want to use straight quotes as
-foot and inch marks: 6\\'2\\" tall; a 17\\" iMac.
+foot and inch marks:
-.. _escaping mechanism: ../ref/rst/restructuredtext.html#escaping-mechanism
+ 6\'2\" tall; a 17\" monitor.
+.. _backslash escape: ../ref/rst/restructuredtext.html#escaping-mechanism
+
Localisation
============
@@ -82,7 +85,7 @@
`SmartQuotes` inserts quotation marks depending on the language of the
current block element and the value of the `"smart_quotes" setting`_.\
-[#x-altquot]_
+[#x-altquot]_
There is built-in support for the following languages:\ [#smartquotes-locales]_
:af: .. class:: language-af
Modified: trunk/docutils/docutils/transforms/universal.py
===================================================================
--- trunk/docutils/docutils/transforms/universal.py 2019-07-24 10:35:57 UTC (rev 8300)
+++ trunk/docutils/docutils/transforms/universal.py 2019-07-24 10:52:23 UTC (rev 8301)
@@ -222,9 +222,10 @@
nodes_to_skip = (nodes.FixedTextElement, nodes.Special)
"""Do not apply "smartquotes" to instances of these block-level nodes."""
- literal_nodes = (nodes.image, nodes.literal, nodes.math,
+ literal_nodes = (nodes.FixedTextElement, nodes.Special,
+ nodes.image, nodes.literal, nodes.math,
nodes.raw, nodes.problematic)
- """Do not change quotes in instances of these inline nodes."""
+ """Do apply smartquotes to instances of these inline nodes."""
smartquotes_action = 'qDe'
"""Setting to select smartquote transformations.
@@ -240,15 +241,15 @@
def get_tokens(self, txtnodes):
# A generator that yields ``(texttype, nodetext)`` tuples for a list
# of "Text" nodes (interface to ``smartquotes.educate_tokens()``).
+ for node in txtnodes:
+ if (isinstance(node.parent, self.literal_nodes)
+ or isinstance(node.parent.parent, self.literal_nodes)):
+ yield ('literal', unicode(node))
+ else:
+ # SmartQuotes uses backslash escapes instead of null-escapes
+ txt = re.sub('(?<=\x00)([-\\\'".`])', r'\\\1', unicode(node))
+ yield ('plain', txt)
- texttype = {True: 'literal', # "literal" text is not changed:
- False: 'plain'}
- for txtnode in txtnodes:
- nodetype = texttype[isinstance(txtnode.parent,
- self.literal_nodes)]
- yield (nodetype, txtnode.astext())
-
-
def apply(self):
smart_quotes = self.document.settings.smart_quotes
if not smart_quotes:
Modified: trunk/docutils/docutils/utils/smartquotes.py
===================================================================
--- trunk/docutils/docutils/utils/smartquotes.py 2019-07-24 10:35:57 UTC (rev 8300)
+++ trunk/docutils/docutils/utils/smartquotes.py 2019-07-24 10:52:23 UTC (rev 8301)
@@ -644,8 +644,8 @@
# Special case if the very first character is a quote
# followed by punctuation at a non-word-break.
# Close the quotes by brute force:
- text = re.sub(r"""^'(?=%s\\B)""" % (punct_class,), smart.csquote, text)
- text = re.sub(r"""^"(?=%s\\B)""" % (punct_class,), smart.cpquote, text)
+ text = re.sub(r"^'(?=%s\\B)" % (punct_class,), smart.csquote, text)
+ text = re.sub(r'^"(?=%s\\B)' % (punct_class,), smart.cpquote, text)
# Special case for double sets of quotes, e.g.:
# <p>He said, "'Quoted' words in a larger quote."</p>
@@ -950,7 +950,8 @@
parser.add_argument("-e", "--encoding", default="utf8",
help="text encoding")
parser.add_argument("-l", "--language", default=defaultlanguage,
- help="text language (BCP47 tag), Default: %s"%defaultlanguage)
+ help="text language (BCP47 tag), "
+ "Default: %s"% defaultlanguage)
parser.add_argument("-q", "--alternative-quotes", action="store_true",
help="use alternative quote style")
parser.add_argument("--doc", action="store_true",
Modified: trunk/docutils/test/test_transforms/test_smartquotes.py
===================================================================
--- trunk/docutils/test/test_transforms/test_smartquotes.py 2019-07-24 10:35:57 UTC (rev 8300)
+++ trunk/docutils/test/test_transforms/test_smartquotes.py 2019-07-24 10:52:23 UTC (rev 8301)
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# $Id$
+# $Id: test_smartquotes.py 8190 2017-10-25 13:57:27Z milde $
#
# :Copyright: © 2011 Günter Milde.
# :Maintainer: doc...@li...
@@ -24,7 +24,8 @@
def suite():
parser = Parser()
- settings = {'smart_quotes': True}
+ settings = {'smart_quotes': True,
+ 'trim_footnote_ref_space': True}
s = DocutilsTestSupport.TransformTestSuite(
parser, suite_settings=settings)
s.generateTests(totest)
@@ -43,7 +44,7 @@
totest_de_alt = {}
totest_locales = {}
-totest['transitions'] = ((SmartQuotes,), [
+totest['smartquotes'] = ((SmartQuotes,), [
["""\
Test "smart quotes", 'secondary smart quotes',
"'nested' smart" quotes
@@ -56,7 +57,7 @@
“‘nested’ smart” quotes
– and —also long— dashes.
"""],
-[r"""Escaped \\"ASCII quotes\\" and \\'secondary ASCII quotes\\'.
+[r"""Escaped \"ASCII quotes\" and \'secondary ASCII quotes\'.
""",
u"""\
<document source="test data">
@@ -68,8 +69,11 @@
"literal" blocks.
+.. role:: python(code)
+ :class: python
+
Keep quotes straight in code and math:
-:code:`print "hello"` :math:`1' 12"`.
+:code:`print "hello"` :python:`print("hello")` :math:`1' 12"`.
.. code::
@@ -94,6 +98,9 @@
<literal classes="code">
print "hello"
+ <literal classes="code python">
+ print("hello")
+
<math>
1' 12"
.
@@ -113,6 +120,7 @@
NBSP "a" 'a',
ZWSP\u200B"a" and\u200B'a',
ZWNJ\u200C"a" and\u200C'a',
+escaped space\ "a" and\ 'a',
—"a",—'a'
en dash–"a"–'a',
@@ -131,6 +139,7 @@
NBSP “a” ‘a’,
ZWSP\u200B“a” and\u200B‘a’,
ZWNJ\u200C“a” and\u200C‘a’,
+ escaped space“a” and‘a’,
<paragraph>
—“a”,—‘a’
en dash–“a”–‘a’,
@@ -196,7 +205,7 @@
and links to "targets_".
Inside *"emphasized"* or other `inline "roles"`:
- (``"string"``), (``'string'``), *\\"betont\\"*, \\"*betont*".
+ (``"string"``), (``'string'``), *\"betont\"*, \"*betont*".
Do not drop characters from intra-word inline markup like
*re*\ ``Structured``\ *Text*.
@@ -252,6 +261,104 @@
Text
.
"""],
+[r"""
+Docutils escape mechanism uses the backslash:
+
+\Remove \non-escaped \backslashes\:
+\item \newline \tab \" \' \*.
+
+\ Remove-\ escaped-\ white\ space-\
+including-\ newlines.
+
+\\Keep\\escaped\\backslashes\\
+(but\\only\\one).
+
+\\ Keep \\ space\\ around \\ backslashes.
+
+Keep backslashes ``\in\ literal``, :math:`in \mathrm{math}`,
+and :code:`in\ code`.
+
+Test around inline elements:\ [*]_
+
+*emphasized*, H\ :sub:`2`\ O and :math:`x^2`
+
+*emphasized*, H\ :sub:`2`\ O and :math:`x^2`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. [*] and footnotes
+""",
+u"""\
+<document source="test data">
+ <paragraph>
+ Docutils escape mechanism uses the backslash:
+ <paragraph>
+ Remove non-escaped backslashes:
+ item newline tab " \' *.
+ <paragraph>
+ Remove-escaped-whitespace-including-newlines.
+ <paragraph>
+ \\Keep\\escaped\\backslashes\\
+ (but\\only\\one).
+ <paragraph>
+ \\ Keep \\ space\\ around \\ backslashes.
+ <paragraph>
+ Keep backslashes \n\
+ <literal>
+ \\in\\ literal
+ , \n\
+ <math>
+ in \\mathrm{math}
+ ,
+ and \n\
+ <literal classes="code">
+ in\\ code
+ .
+ <paragraph>
+ Test around inline elements:
+ <footnote_reference auto="*" ids="id1">
+ <paragraph>
+ <emphasis>
+ emphasized
+ , H
+ <subscript>
+ 2
+ O and \n\
+ <math>
+ x^2
+ <section ids="emphasized-h2o-and-x-2" names="emphasized,\\ h2o\\ and\\ x^2">
+ <title>
+ <emphasis>
+ emphasized
+ , H
+ <subscript>
+ 2
+ O and \n\
+ <math>
+ x^2
+ <footnote auto="*" ids="id2">
+ <paragraph>
+ and footnotes
+"""],
+[r"""
+Character-level m\ *a*\ **r**\ ``k``\ `u`:title:\p
+with backslash-escaped whitespace, including new\
+lines.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Character-level m
+ <emphasis>
+ a
+ <strong>
+ r
+ <literal>
+ k
+ <title_reference>
+ u
+ p
+ with backslash-escaped whitespace, including newlines.
+"""],
["""\
.. class:: language-de
@@ -287,7 +394,7 @@
"""],
])
-totest_de['transitions'] = ((SmartQuotes,), [
+totest_de['smartquotes'] = ((SmartQuotes,), [
["""\
German "smart quotes" and 'secondary smart quotes'.
@@ -304,7 +411,7 @@
"""],
])
-totest_de_alt['transitions'] = ((SmartQuotes,), [
+totest_de_alt['smartquotes'] = ((SmartQuotes,), [
["""\
Alternative German "smart quotes" and 'secondary smart quotes'.
@@ -333,7 +440,7 @@
"""],
])
-totest_locales['transitions'] = ((SmartQuotes,), [
+totest_locales['smartquotes'] = ((SmartQuotes,), [
["""\
German "smart quotes" and 'secondary smart quotes'.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gr...@us...> - 2019-08-06 11:17:13
|
Revision: 8308
http://sourceforge.net/p/docutils/code/8308
Author: grubert
Date: 2019-08-06 11:17:11 +0000 (Tue, 06 Aug 2019)
Log Message:
-----------
Patch+158 Speed up patterns by saving compiled versions
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/statemachine.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2019-08-06 11:14:21 UTC (rev 8307)
+++ trunk/docutils/HISTORY.txt 2019-08-06 11:17:11 UTC (rev 8308)
@@ -38,6 +38,10 @@
- Fix [ 332 ]: Standard backslash escape for smartquotes.
Fix [ 342 ]: No escape in roles descending from `inline literal`.
+* docutils/statemachine.py
+
+ - Patch [ 158 ]: Speed up patterns by saving compiled versions (eric89gxl)
+
* test/test_io.py:
- Apply patch #157: avoid test failure because of a ``ResourceWarning``.
Modified: trunk/docutils/docutils/statemachine.py
===================================================================
--- trunk/docutils/docutils/statemachine.py 2019-08-06 11:14:21 UTC (rev 8307)
+++ trunk/docutils/docutils/statemachine.py 2019-08-06 11:17:11 UTC (rev 8308)
@@ -715,7 +715,7 @@
try:
pattern = self.patterns[name]
if not hasattr(pattern, 'match'):
- pattern = re.compile(pattern)
+ pattern = self.patterns[name] = re.compile(pattern)
except KeyError:
raise TransitionPatternNotFound(
'%s.patterns[%r]' % (self.__class__.__name__, name))
@@ -859,7 +859,7 @@
offset += 1
return indented, offset, blank_finish
- def get_first_known_indented(self, indent, until_blank=False,
+ def get_first_known_indented(self, indent, until_blank=False,
strip_indent=True, strip_top=True):
"""
Return an indented block and info.
@@ -945,8 +945,8 @@
`indent_sm_kwargs`. Override it in subclasses to avoid the default.
"""
- ws_patterns = {'blank': ' *$',
- 'indent': ' +'}
+ ws_patterns = {'blank': re.compile(' *$'),
+ 'indent': re.compile(' +')}
"""Patterns for default whitespace transitions. May be overridden in
subclasses."""
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gr...@us...> - 2019-08-15 17:01:44
|
Revision: 8312
http://sourceforge.net/p/docutils/code/8312
Author: grubert
Date: 2019-08-15 17:01:42 +0000 (Thu, 15 Aug 2019)
Log Message:
-----------
Fix [ 359 ]: Test suite failes on Python 3.8. odt xml sorting. Use ElemtTree instead of minidom.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/test/test_writers/test_odt.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2019-08-11 20:09:26 UTC (rev 8311)
+++ trunk/docutils/HISTORY.txt 2019-08-15 17:01:42 UTC (rev 8312)
@@ -36,7 +36,7 @@
* docutils/transforms/universal.py
- Fix [ 332 ]: Standard backslash escape for smartquotes.
- Fix [ 342 ]: No escape in roles descending from `inline literal`.
+ - Fix [ 342 ]: No escape in roles descending from `inline literal`.
* docutils/statemachine.py
@@ -46,6 +46,11 @@
- Apply patch #157: avoid test failure because of a ``ResourceWarning``.
+* test/test_writers/test_odt.py:
+
+ - Fix [ 359 ]: Test suite failes on Python 3.8. odt xml sorting.
+ Use ElemtTree instead of minidom.
+
Release 0.15.1 (2019-07-24)
===========================
Modified: trunk/docutils/test/test_writers/test_odt.py
===================================================================
--- trunk/docutils/test/test_writers/test_odt.py 2019-08-11 20:09:26 UTC (rev 8311)
+++ trunk/docutils/test/test_writers/test_odt.py 2019-08-15 17:01:42 UTC (rev 8312)
@@ -33,7 +33,7 @@
import sys
import os
import zipfile
-from xml.dom import minidom
+import xml.etree.ElementTree as ET
import tempfile
from __init__ import DocutilsTestSupport
@@ -116,6 +116,19 @@
len(content2), len(content1), )
self.assertEqual(content1, content2, msg)
+ def reorder_attributes(self, root):
+ """
+ Make attribute order independent of python version.
+ python3.8 is different to previous.
+ """
+ for el in root.iter():
+ attrib = el.attrib
+ if len(attrib) > 1:
+ # adjust attribute order, e.g. by sorting
+ attribs = sorted(attrib.items())
+ attrib.clear()
+ attrib.update(attribs)
+
def extract_file(self, payload, filename):
payloadfile = BytesIO()
payloadfile.write(payload)
@@ -122,9 +135,10 @@
payloadfile.seek(0)
zfile = zipfile.ZipFile(payloadfile, 'r')
content1 = zfile.read(filename)
- doc = minidom.parseString(content1)
+ doc = ET.fromstring(content1)
+ self.reorder_attributes(doc)
#content2 = doc.toprettyxml(indent=' ')
- content2 = doc.toxml()
+ content2 = ET.tostring(doc)
return content2
def assertEqual(self, first, second, msg=None):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|