From 47e55f7ebc927ff6a47343cd5d866ee269508c05 Mon Sep 17 00:00:00 2001 From: smerten Date: Sun, 11 Dec 2011 11:28:05 +0000 Subject: [PATCH] Starting with this version new functionality is mainly implemented in Python. Old functionality is moved to Python step by step. Plain text looking like inline markup to reStructuredText is quoted in output. Docinfo blocks are ended with a blank line. Targets containing colons are quoted correctly. git-svn-id: https://docutils.svn.sourceforge.net/svnroot/docutils/trunk@7249 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- sandbox/xml2rst/README | 49 +- sandbox/xml2rst/global.log | 516 +++++++++++++++++++++ sandbox/xml2rst/rst/markup.py | 119 +++++ sandbox/xml2rst/rst/rst_xslt.py | 132 +++++- sandbox/xml2rst/rst/xml2rst-noexslt.xsl | 27 +- .../xml2rst/rst/{xml2rst.xsl => xml2rst-nopy.xsl} | 31 +- sandbox/xml2rst/rst/xml2rst.xsl | 236 +++------- sandbox/xml2rst/setup.py | 3 +- sandbox/xml2rst/tag.log | 2 +- sandbox/xml2rst/tests.xalan/simple/filterunit.cfg | 5 + sandbox/xml2rst/tests.xsltproc/common.cfg | 2 +- .../xml2rst/tests.xsltproc/options/filterunit.cfg | 2 +- .../xml2rst/tests.xsltproc/simple/filterunit.cfg | 5 + .../xml2rst/tests/options/readable/adornmentX.xml | 2 +- sandbox/xml2rst/tests/options/readable/foldX.xml | 2 +- sandbox/xml2rst/tests/real/input/Machinery.xml | 2 +- sandbox/xml2rst/tests/real/input/MediaWikiFAQ.xml | 2 +- sandbox/xml2rst/tests/real/input/Technik.xml | 2 +- .../xml2rst/tests/real/input/WikiRequirements.xml | 2 +- sandbox/xml2rst/tests/real/readable/Machinery.xml | 2 +- .../xml2rst/tests/real/readable/MediaWikiFAQ.xml | 2 +- sandbox/xml2rst/tests/real/readable/Technik.xml | 2 +- .../tests/real/readable/WikiRequirements.xml | 2 +- .../tests/simple/expected/docinfoHeader.rst | 18 + .../xml2rst/tests/simple/expected/quoteBlock.rst | 30 ++ .../tests/simple/expected/quoteOriginal.rst | 19 + sandbox/xml2rst/tests/simple/expected/targets.rst | 4 + sandbox/xml2rst/tests/simple/filterunit.cfg | 5 + .../xml2rst/tests/simple/input/docinfoHeader.xml | 3 + sandbox/xml2rst/tests/simple/input/header.xml | 2 +- sandbox/xml2rst/tests/simple/input/manyLines.xml | 2 +- sandbox/xml2rst/tests/simple/input/oneLine.xml | 2 +- sandbox/xml2rst/tests/simple/input/quoteBlock.xml | 16 + .../xml2rst/tests/simple/input/quoteOriginal.xml | 9 + sandbox/xml2rst/tests/simple/input/targets.xml | 4 +- sandbox/xml2rst/tests/simple/input/titles.xml | 2 +- .../tests/simple/original/docinfoHeader.rst | 18 + .../xml2rst/tests/simple/original/quoteBlock.rst | 28 ++ .../tests/simple/original/quoteOriginal.rst | 17 + sandbox/xml2rst/tests/simple/original/targets.rst | 4 + .../tests/simple/readable/docinfoHeader.xml | 48 ++ sandbox/xml2rst/tests/simple/readable/header.xml | 2 +- .../xml2rst/tests/simple/readable/manyLines.xml | 2 +- sandbox/xml2rst/tests/simple/readable/oneLine.xml | 2 +- .../xml2rst/tests/simple/readable/quoteBlock.xml | 41 ++ .../tests/simple/readable/quoteOriginal.xml | 25 + sandbox/xml2rst/tests/simple/readable/targets.xml | 10 +- sandbox/xml2rst/tests/simple/readable/titles.xml | 2 +- sandbox/xml2rst/tests/synthetic/expected/class.rst | 1 + .../tests/synthetic/expected/standard_0_3_7.rst | 1 + .../tests/synthetic/expected/standard_r6008.rst | 1 + sandbox/xml2rst/tests/synthetic/input/class.xml | 2 +- .../tests/synthetic/input/standard_0_3_7.xml | 2 +- .../tests/synthetic/input/standard_r6008.xml | 2 +- sandbox/xml2rst/tests/synthetic/readable/class.xml | 2 +- .../tests/synthetic/readable/standard_0_3_7.xml | 2 +- .../tests/synthetic/readable/standard_r6008.xml | 2 +- sandbox/xml2rst/version.py | 2 +- 58 files changed, 1247 insertions(+), 234 deletions(-) create mode 100644 sandbox/xml2rst/rst/markup.py copy sandbox/xml2rst/rst/{xml2rst.xsl => xml2rst-nopy.xsl} (99%) create mode 100644 sandbox/xml2rst/tests/simple/expected/docinfoHeader.rst create mode 100644 sandbox/xml2rst/tests/simple/expected/quoteBlock.rst create mode 100644 sandbox/xml2rst/tests/simple/expected/quoteOriginal.rst create mode 100644 sandbox/xml2rst/tests/simple/input/docinfoHeader.xml create mode 100644 sandbox/xml2rst/tests/simple/input/quoteBlock.xml create mode 100644 sandbox/xml2rst/tests/simple/input/quoteOriginal.xml create mode 100644 sandbox/xml2rst/tests/simple/original/docinfoHeader.rst create mode 100644 sandbox/xml2rst/tests/simple/original/quoteBlock.rst create mode 100644 sandbox/xml2rst/tests/simple/original/quoteOriginal.rst create mode 100644 sandbox/xml2rst/tests/simple/readable/docinfoHeader.xml create mode 100644 sandbox/xml2rst/tests/simple/readable/quoteBlock.xml create mode 100644 sandbox/xml2rst/tests/simple/readable/quoteOriginal.xml diff --git a/sandbox/xml2rst/README b/sandbox/xml2rst/README index 6e2a1007e..e521a8e73 100644 --- a/sandbox/xml2rst/README +++ b/sandbox/xml2rst/README @@ -8,19 +8,23 @@ What is xml2rst? ================ `xml2rst` is a tool to generate reStructuredText_ syntax back from -`Docutils XML`_ input. This way you can an create XML files using +`Docutils XML`_ input. This way you can create an XML files using `Docutils XML`_ from some other format (such as ODF_) and then -transform them to reStructuredText_. +transform the result to reStructuredText_. .. _flavor: -It is currently implemented as an XSLT_ stylesheet coming in three -flavors: +Using xml2rst +============= + +`xml2rst` is currently implemented as an XSLT_ stylesheet usable in +three flavors: 1. ``xml2rst.py`` This script uses ``rst/xml2rst.xsl`` through the XSLT_ engine - available through the lxml_ package [#deb-lxml]_. + available through the lxml_ package [#deb-lxml]_. It also uses + Python callbacks for some advanced functionality. This is the preferred method of using `xml2rst` but depends on the lxml_ package. This is also what is installed normally. @@ -28,33 +32,44 @@ flavors: .. [#deb-lxml] Under Debian based operating systems try ``apt-get install python-lxml``. -2. ``rst/xml2rst.xsl`` + Run ``xml2rst --help`` for information on how to run it. + +2. ``rst/xml2rst-nopy.xsl`` - This is the core XSLT_ script. It uses EXSLT_ and therefore needs - an EXSLT_ capable XSLT_ processors such as xsltproc_ - [#deb-xsltproc]_. + This is the core XSLT_ script without using Python. It uses EXSLT_ + and therefore needs an EXSLT_ capable XSLT_ processors such as + xsltproc_ [#deb-xsltproc]_. - If you can't use ``xml2rst.py`` you may try this flavor. + If you can't use ``xml2rst.py`` because you don't have lxml_ you + may try this flavor. This version is no longer actively maintained, + though. .. [#deb-xsltproc] Under Debian based operating systems try ``apt-get install xsltproc``. + Run ``perldoc rst/xml2rst-nopy.xsl`` for information on how to run + it. + 3. ``rst/xml2rst-noexslt.xsl`` This version can be processed with every XSLT_ processor like Xalan_ [#deb-xalan]_. - This version is no longer actively maintained, though. + If you can use neither ``xml2rst.py`` nor ``xml2rst-nopy.xsl`` you + may try this flavor. This version is no longer actively maintained, + though. .. [#deb-xalan] Under Debian based operating systems try ``apt-get install xalan``. + Run ``perldoc rst/xml2rst-noexslt.xsl`` for information on how to + run it. + Availability ============ `xml2rst` is available through the `Docutils Subversion repository`_ -as part of the Docutils sandbox at -http://svn.berlios.de/viewcvs/docutils/trunk/sandbox/xml2rst +as part of the Docutils sandbox in ``sandbox/xml2rst``. Moreover you can fetch it directly from the current maintainer at http://www.merten-home.de/FreeSoftware/xml2rst/ @@ -65,14 +80,13 @@ Installation After you obtained the package run ``python setup.py install``. Depending on the flavor_ you choose you need to install certain -packages to run `xml2rst`. If using an XSLT_ processor try ``perldoc -xml2rst.xsl`` for instructions how to run it. +packages to run `xml2rst`. Copyright and license ===================== Copyright (C) 2005, 2006 by Stefan Merten and David Priest -Copyright (C) 2009, 2010 by Stefan Merten +Copyright (C) 2009, 2010, 2011 by Stefan Merten License is GPL_ v2 or later. @@ -93,7 +107,8 @@ with ``TODO`` which contain things which should be done. Plans ----- -``xml2rst`` should become a normal reStructuredText writer. +``xml2rst`` should become a normal reStructuredText writer. Starting +with V1.0 functionality is moved to a Python based implementation. .. ############################################################################ diff --git a/sandbox/xml2rst/global.log b/sandbox/xml2rst/global.log index 253a6efa9..c0092d88e 100644 --- a/sandbox/xml2rst/global.log +++ b/sandbox/xml2rst/global.log @@ -1,4 +1,520 @@ ************************************** +Date: Sat Dec 10 21:43:02 CET 2011 +Author: stefan +Tag: xml2rst_1_224 + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/rst +In directory theowa:/home/stefan/free/xml2rst/rst + +Modified Files: + xml2rst.xsl + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/tests/simple/expected +In directory theowa:/home/stefan/free/xml2rst/tests/simple/expected + +Added Files: + docinfoHeader.rst + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/tests/simple/original +In directory theowa:/home/stefan/free/xml2rst/tests/simple/original + +Added Files: + docinfoHeader.rst + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/tests/synthetic/expected +In directory theowa:/home/stefan/free/xml2rst/tests/synthetic/expected + +Modified Files: + class.rst standard_0_3_7.rst standard_r6008.rst + +-------------------------------------- +Log Message: +Docinfo blocks are ended with a blank line. +************************************** +Date: Sat Dec 10 20:41:03 CET 2011 +Author: stefan +Tag: xml2rst_1_223 + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst +In directory theowa:/home/stefan/free/xml2rst + +Modified Files: + Makefile + +-------------------------------------- +Log Message: +Improved Makefile. +************************************** +Date: Sat Dec 10 20:16:30 CET 2011 +Author: stefan +Tag: xml2rst_1_222 + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/rst +In directory theowa:/home/stefan/free/xml2rst/rst + +Modified Files: + xml2rst.xsl + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/tests/simple/expected +In directory theowa:/home/stefan/free/xml2rst/tests/simple/expected + +Modified Files: + targets.rst + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/tests/simple/original +In directory theowa:/home/stefan/free/xml2rst/tests/simple/original + +Modified Files: + targets.rst + +-------------------------------------- +Log Message: +Targets containing colons are quoted correctly. +************************************** +Date: Sat Dec 10 18:08:25 CET 2011 +Author: stefan +Tag: xml2rst_1_221 + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst +In directory theowa:/home/stefan/free/xml2rst + +Modified Files: + setup.py + +-------------------------------------- +Log Message: +Debugged packaging. +************************************** +Date: Sat Dec 10 17:59:00 CET 2011 +Author: stefan +Tag: xml2rst_1_220 + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/tests/simple +In directory theowa:/home/stefan/free/xml2rst/tests/simple + +Modified Files: + filterunit.cfg + +-------------------------------------- +Log Message: +Excluded test for non-implemented feature. +************************************** +Date: Sat Dec 10 17:50:14 CET 2011 +Author: stefan +Tag: xml2rst_1_219 + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst +In directory theowa:/home/stefan/free/xml2rst + +Modified Files: + README + +-------------------------------------- +Log Message: +Improved documentation. +************************************** +Date: Tue Dec 6 22:00:35 CET 2011 +Author: stefan +Tag: xml2rst_1_218 + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/tests.xalan/simple +In directory theowa:/home/stefan/free/xml2rst/tests.xalan/simple + +Modified Files: + filterunit.cfg + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/tests.xsltproc +In directory theowa:/home/stefan/free/xml2rst/tests.xsltproc + +Modified Files: + common.cfg + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/tests.xsltproc/options +In directory theowa:/home/stefan/free/xml2rst/tests.xsltproc/options + +Modified Files: + filterunit.cfg + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/tests.xsltproc/simple +In directory theowa:/home/stefan/free/xml2rst/tests.xsltproc/simple + +Modified Files: + filterunit.cfg + +-------------------------------------- +Log Message: +Adapted tests to not test features implemented by Python. +************************************** +Date: Mon Dec 5 23:37:02 CET 2011 +Author: stefan +Tag: xml2rst_1_217 + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/rst +In directory theowa:/home/stefan/free/xml2rst/rst + +Modified Files: + markup.py rst_xslt.py xml2rst.xsl + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/tests/simple/expected +In directory theowa:/home/stefan/free/xml2rst/tests/simple/expected + +Modified Files: + quoteBlock.rst quoteOriginal.rst + +-------------------------------------- +Log Message: +Literal parts are not quoted. +************************************** +Date: Mon Dec 5 23:01:41 CET 2011 +Author: stefan +Tag: xml2rst_1_216 + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/tests/simple/expected +In directory theowa:/home/stefan/free/xml2rst/tests/simple/expected + +Modified Files: + quoteOriginal.rst + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/tests/simple/original +In directory theowa:/home/stefan/free/xml2rst/tests/simple/original + +Modified Files: + quoteOriginal.rst + +-------------------------------------- +Log Message: +Extended test exposing bugs for literal text. +************************************** +Date: Mon Dec 5 22:52:43 CET 2011 +Author: stefan +Tag: xml2rst_1_215 + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/rst +In directory theowa:/home/stefan/free/xml2rst/rst + +Modified Files: + markup.py + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/tests/simple/expected +In directory theowa:/home/stefan/free/xml2rst/tests/simple/expected + +Modified Files: + quoteOriginal.rst + +-------------------------------------- +Log Message: +Quoting backslashes works. +************************************** +Date: Mon Dec 5 22:10:38 CET 2011 +Author: stefan +Tag: xml2rst_1_214 + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/tests/simple/expected +In directory theowa:/home/stefan/free/xml2rst/tests/simple/expected + +Modified Files: + quoteOriginal.rst +Added Files: + quoteBlock.rst + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/tests/simple/original +In directory theowa:/home/stefan/free/xml2rst/tests/simple/original + +Modified Files: + quoteOriginal.rst +Added Files: + quoteBlock.rst + +-------------------------------------- +Log Message: +Separated tests for inline and block quoting. +************************************** +Date: Mon Dec 5 20:07:21 CET 2011 +Author: stefan +Tag: xml2rst_1_213 + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/rst +In directory theowa:/home/stefan/free/xml2rst/rst + +Modified Files: + markup.py + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/tests/simple/expected +In directory theowa:/home/stefan/free/xml2rst/tests/simple/expected + +Modified Files: + quoteOriginal.rst + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/tests/simple/original +In directory theowa:/home/stefan/free/xml2rst/tests/simple/original + +Modified Files: + quoteOriginal.rst + +-------------------------------------- +Log Message: +Inline markup is output properly. +************************************** +Date: Mon Dec 5 12:35:35 CET 2011 +Author: stefan +Tag: xml2rst_1_212 + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/rst +In directory theowa:/home/stefan/free/xml2rst/rst + +Modified Files: + markup.py + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/tests/simple/expected +In directory theowa:/home/stefan/free/xml2rst/tests/simple/expected + +Modified Files: + quoteOriginal.rst + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/tests/simple/original +In directory theowa:/home/stefan/free/xml2rst/tests/simple/original + +Modified Files: + quoteOriginal.rst + +-------------------------------------- +Log Message: +Most inline constructs work. +************************************** +Date: Mon Dec 5 12:11:13 CET 2011 +Author: stefan +Tag: xml2rst_1_211 + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/rst +In directory theowa:/home/stefan/free/xml2rst/rst + +Modified Files: + markup.py + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/tests/simple/expected +In directory theowa:/home/stefan/free/xml2rst/tests/simple/expected + +Modified Files: + quoteOriginal.rst + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/tests/simple/original +In directory theowa:/home/stefan/free/xml2rst/tests/simple/original + +Modified Files: + quoteOriginal.rst + +-------------------------------------- +Log Message: +Expanded tests. +************************************** +Date: Mon Dec 5 11:43:23 CET 2011 +Author: stefan +Tag: xml2rst_1_210 + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/rst +In directory theowa:/home/stefan/free/xml2rst/rst + +Modified Files: + markup.py + +-------------------------------------- +Log Message: +Some markup recognition works. +************************************** +Date: Mon Dec 5 09:57:40 CET 2011 +Author: stefan +Tag: xml2rst_1_209 + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst +In directory theowa:/home/stefan/free/xml2rst + +Modified Files: + README + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/rst +In directory theowa:/home/stefan/free/xml2rst/rst + +Modified Files: + .cvsignore markup.py rst_xslt.py xml2rst.xsl + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/tests/simple/expected +In directory theowa:/home/stefan/free/xml2rst/tests/simple/expected + +Modified Files: + quoteOriginal.rst + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/tests/simple/original +In directory theowa:/home/stefan/free/xml2rst/tests/simple/original + +Modified Files: + quoteOriginal.rst + +-------------------------------------- +Log Message: +Intermediate version. Does not run. +************************************** +Date: Thu Nov 24 13:13:49 CET 2011 +Author: stefan +Tag: xml2rst_1_208 + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/rst +In directory theowa:/home/stefan/free/xml2rst/rst + +Modified Files: + rst_xslt.py +Added Files: + markup.py + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/tests/simple/expected +In directory theowa:/home/stefan/free/xml2rst/tests/simple/expected + +Modified Files: + quoteOriginal.rst + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/tests/simple/original +In directory theowa:/home/stefan/free/xml2rst/tests/simple/original + +Modified Files: + quoteOriginal.rst + +-------------------------------------- +Log Message: +Refactoring: Changed structure separating Python markup generation +from glue to use in XSLT. +************************************** +Date: Mon Nov 21 21:54:36 CET 2011 +Author: stefan +Tag: xml2rst_1_207 + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/rst +In directory theowa:/home/stefan/free/xml2rst/rst + +Modified Files: + rst_xslt.py xml2rst.xsl + +-------------------------------------- +Log Message: +Plain text is formatted by Python based XPath extension. +************************************** +Date: Mon Nov 21 10:57:26 CET 2011 +Author: stefan +Tag: xml2rst_1_206 + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/rst +In directory theowa:/home/stefan/free/xml2rst/rst + +Modified Files: + rst_xslt.py xml2rst.xsl + +-------------------------------------- +Log Message: +XSLT extension elements don't work since they can not receive +parameters. Implemented as XPath function instead. Works in a first +case. +************************************** +Date: Mon Nov 14 22:27:09 CET 2011 +Author: stefan +Tag: xml2rst_1_205 + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/rst +In directory theowa:/home/stefan/free/xml2rst/rst + +Modified Files: + rst_xslt.py + +-------------------------------------- +Log Message: +Started implementation of XSLT extensions. Not used yet. + +Transformed documentation to reStructuredText. +************************************** +Date: Thu Nov 10 08:59:17 CET 2011 +Author: stefan +Tag: xml2rst_1_204 + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/tests/simple/expected +In directory theowa:/home/stefan/free/xml2rst/tests/simple/expected + +Modified Files: + quoteOriginal.rst + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/tests/simple/original +In directory theowa:/home/stefan/free/xml2rst/tests/simple/original + +Modified Files: + quoteOriginal.rst + +-------------------------------------- +Log Message: +Improved new test. Test fails due to lack of implementation. +************************************** +Date: Thu Nov 10 08:44:11 CET 2011 +Author: stefan +Tag: xml2rst_1_203 + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/tests/simple/expected +In directory theowa:/home/stefan/free/xml2rst/tests/simple/expected + +Added Files: + quoteOriginal.rst + +-------------------------------------- +Update of /home/stefan/vault/sm/xml2rst/tests/simple/original +In directory theowa:/home/stefan/free/xml2rst/tests/simple/original + +Added Files: + quoteOriginal.rst + +-------------------------------------- +Log Message: +Added some tests for missing quoting of original text. +************************************** Date: Mon Nov 7 11:47:43 CET 2011 Author: stefan Tag: xml2rst_1_202 diff --git a/sandbox/xml2rst/rst/markup.py b/sandbox/xml2rst/rst/markup.py new file mode 100644 index 000000000..35593f4f0 --- /dev/null +++ b/sandbox/xml2rst/rst/markup.py @@ -0,0 +1,119 @@ +""" +Python based conversion. +""" + +############################################################################### +############################################################################### +# Import + +import re +import docutils +import docutils.parsers.rst.states + +__docformat__ = 'reStructuredText' + +############################################################################### +############################################################################### +# Classes + +class Inliner(docutils.parsers.rst.states.Inliner): + """ + Recognizer for inline markup. Derive this from the original inline + markup parser for best results. + """ + + def quoteInline(self, text): + """ + `text`: ``str`` + Return `text` with inline markup quoted. + """ + # Method inspired by `docutils.parsers.rst.states.Inliner.parse` + self.document = docutils.utils.new_document("") + self.document.settings.trim_footnote_reference_space = False + self.reporter = self.document.reporter + self.reporter.stream = None + self.language = None + self.parent = self.document + remaining = docutils.utils.escape2null(text) + checked = "" + processed = [] + unprocessed = [] + messages = [] + while remaining: + original = remaining + match = self.patterns.initial.search(remaining) + if match: + groups = match.groupdict() + method = self.dispatch[groups['start'] or groups['backquote'] + or groups['refend'] or groups['fnend']] + ( before, inlines, remaining, sysmessages, + ) = method(self, match, 0) + checked += before + if inlines: + assert len(inlines) == 1, "More than one inline found" + inline = original[len(before) + :len(original) - len(remaining)] + rolePfx = re.search("^:" + self.simplename + ":(?=`)", + inline) + refSfx = re.search("_+$", inline) + if rolePfx: + # Prefixed roles need to be quoted in the middle + checked += (inline[:rolePfx.end()] + "\\" + + inline[rolePfx.end():]) + elif refSfx and not re.search("^`", inline): + # Pure reference markup needs to be quoted at the end + checked += (inline[:refSfx.start()] + "\\" + + inline[refSfx.start():]) + else: + # Quote other inlines by prefixing + checked += "\\" + inline + else: + checked += remaining + break + # Quote all original backslashes + checked = re.sub('\x00', "\\\x00", checked) + return docutils.utils.unescape(checked, 1) + +############################################################################### + +class Text(): + """ + Functions for computing valid reStructuredText plain text. + """ + + inliner = Inliner() + + @staticmethod + def plain(text, indent, literal): + """ + Return a plain text preventing further interpretation by + reStructuredText. Text may contain linefeeds. + + `text`: ``str`` + The string to turn into output text. + + `indent`: ``str`` + The string to use for indent in case of internal linefeeds. + + `literal`: ``bool`` + Output literal instead of quoting. + """ + sep = "\n" + indent + if literal: + quoted = text + else: + quoted = Text.inliner.quoteInline(text) + return sep.join(quoted.split("\n")) + +#print(Text.plain("Some \\ back\slashes", "")) + +# indent +# directive +# field_names +# substitution +# inline markup +# token +# label +# start_delimiter +# end_delimiter +# target_definition diff --git a/sandbox/xml2rst/rst/rst_xslt.py b/sandbox/xml2rst/rst/rst_xslt.py index 26ff199e0..c3a6e8ce0 100644 --- a/sandbox/xml2rst/rst/rst_xslt.py +++ b/sandbox/xml2rst/rst/rst_xslt.py @@ -1,3 +1,7 @@ +""" +Glue code for XSLT and Python based conversion. +""" + ############################################################################### ############################################################################### # Import @@ -10,17 +14,111 @@ try: except ImportError: raise Exception(""" Python package 'lxml' is not available. -You may try to use 'xml2rst.xsl' with a standalone XSLT processor like 'xalan' or 'xsltproc'""") +You may try to use an older version of 'xml2rst.xsl' with a standalone +XSLT processor like 'xalan' or 'xsltproc'""") + +from rst import markup + +__docformat__ = 'reStructuredText' ############################################################################### ############################################################################### # Constants +MainXsltNm = 'xml2rst.xsl' """ -@var MainXsltNm: Name of the main XSLT source file -@type MainXsltNm: str +`MainXsltNm`: ``str`` + Name of the main XSLT source file. """ -MainXsltNm = "xml2rst.xsl" + +############################################################################### +############################################################################### +# Classes + +class XPathExtension(): + """ + Abstract class for XPath extension functions. + """ + + namespace = "http://www.merten-home.de/xml2rst" + """ + `namespace`: ``str`` + Namespace for these XSLT extension functions. + """ + + def _stringParameter(self, string): + """ + Return the normalized string parameter from an XPath + parameter. + + `string`: ``lxml.etree._ElementStringResult`` | ``[ lxml.etree._ElementStringResult, ]`` | ``[ ]`` + Original XPath string parameter. + """ + if isinstance(string, list): + if len(string) == 0: + return "" + else: + assert len(string) == 1, "Encountered an XPath string parameter with more than one element" + return string[0] + else: + return string + + def _boolParameter(self, boolean): + """ + Return the normalized bool parameter from an XPath parameter. + + `boolean`: ``bool`` + Original XPath bool parameter. + """ + return boolean + +############################################################################### + +class RstText(XPathExtension): + """ + XPath extension functions for computing valid reStructuredText + markup for plain text. + """ + + def plain(self, context, string, indent, literal): + """ + Output a plain text preventing further interpretation by + reStructuredText. Text may contain linefeeds. + + `context`: ``lxml.etree._XSLTContext`` + The evaluation context. + + `context.context_node`: ``Element`` + The context node. + + `contect.eval_context`: ``dict`` + A dictionary to store state. + + `string`: + The (smart) string to turn into output text. + + `indent`: + The (smart) string to use for indent in case of internal + linefeeds. + + `literal`: + The (smart) string to use for indent in case of internal + linefeeds. + """ + return markup.Text.plain(self._stringParameter(string), + self._stringParameter(indent), + self._boolParameter(literal)) + + # indent + # directive + # field_names + # substitution + # inline markup + # token + # label + # start_delimiter + # end_delimiter + # target_definition ############################################################################### ############################################################################### @@ -30,17 +128,21 @@ def convert(inNm, outNm, settings): """ Do the conversion. - @param inNm: Filename of input file. - @type inNm: str + `inNm`: ``str`` + Filename of input file. - @param outNm: Filename of output file or None. - @type outNm: str | None + `outNm`: ``str`` | None + Filename of output file or None for stdout. + + `settings`: ``optparse.Values`` + Options from command line. """ try: inF = open(inNm) except IOError, e: raise Exception("Can't open input file %r: %s" % ( inNm, e, )) + # Find XSLT modP = os.path.dirname(__file__) mainXsltNm = os.path.join(modP, MainXsltNm) try: @@ -48,11 +150,20 @@ def convert(inNm, outNm, settings): except IOError, e: raise Exception("Can't open main XSLT file %r: %s" % ( mainXsltNm, e, )) + # Parse and prepare XSLT and extensions xsltParser = etree.XMLParser() - mainXsltDoc = etree.parse(mainXsltF, xsltParser) + try: + mainXsltDoc = etree.parse(mainXsltF, xsltParser) + except Exception, e: + raise Exception("Error parsing main XSLT file %r: %s" + % ( mainXsltNm, e, )) mainXsltF.close() - mainXslt = etree.XSLT(mainXsltDoc) + rstText = RstText() + extensions = etree.Extension(rstText, ns=rstText.namespace) + mainXslt = etree.XSLT(mainXsltDoc, extensions=extensions) + + # Parse input file inParser = etree.XMLParser() try: inDoc = etree.parse(inF, inParser) @@ -60,6 +171,7 @@ def convert(inNm, outNm, settings): raise Exception("Error parsing input file %r: %s" % ( inNm, e, )) inF.close() + # Process input xsltParams = { } if settings.fold is not None: xsltParams['fold'] = str(settings.fold) diff --git a/sandbox/xml2rst/rst/xml2rst-noexslt.xsl b/sandbox/xml2rst/rst/xml2rst-noexslt.xsl index a10a6acdf..22aa7b19d 100644 --- a/sandbox/xml2rst/rst/xml2rst-noexslt.xsl +++ b/sandbox/xml2rst/rst/xml2rst-noexslt.xsl @@ -461,6 +461,8 @@ data: Data elements used by the stylesheet + @@ -2816,8 +2818,19 @@ data: Data elements used by the stylesheet name="u:outputNamesRefid"/> + + + ` + + + ` + : @@ -4030,15 +4043,21 @@ data: Data elements used by the stylesheet =head1 NAME -xml2rst.xsl - An XSLT script to convert Docutils XML to reStructuredText +xml2rst-noexslt.xsl - An XSLT script to convert Docutils XML to reStructuredText =head1 SYNOPSIS Xalan docutils.xml xml2rst.xsl +=head1 NOTE + +Today B is not the recommended way to use +B. The preferred way is to install B and use +B instead. + =head1 DESCRIPTION -B is an XSLT script to convert Docutils XML to +B is an XSLT script to convert Docutils XML to reStructuredText. You can use your favorite XSLT processor (e.g. Xalan from the Apache project) to generate reStructuredText from the Docutils intermediate XML representation. Its main use is to generate @@ -4093,8 +4112,8 @@ reason is that Docutils transports pretty much but not all information of the original source into the XML. Also the sequence is changed sometimes. -However, the coverage of Docutils features of B is pretty -good. A few minor features are not supported: +However, the coverage of Docutils features of B is +pretty good. A few minor features are not supported: =over 4 diff --git a/sandbox/xml2rst/rst/xml2rst.xsl b/sandbox/xml2rst/rst/xml2rst-nopy.xsl similarity index 99% copy from sandbox/xml2rst/rst/xml2rst.xsl copy to sandbox/xml2rst/rst/xml2rst-nopy.xsl index a763775cc..5bfe7f4bf 100644 --- a/sandbox/xml2rst/rst/xml2rst.xsl +++ b/sandbox/xml2rst/rst/xml2rst-nopy.xsl @@ -13,7 +13,7 @@ @@ -2792,8 +2794,19 @@ data: Data elements used by the stylesheet name="u:outputNamesRefid"/> + + + ` + + + ` + : @@ -3620,15 +3633,21 @@ data: Data elements used by the stylesheet =head1 NAME -xml2rst.xsl - An XSLT script to convert Docutils XML to reStructuredText +xml2rst-nopy.xsl - An XSLT script to convert Docutils XML to reStructuredText =head1 SYNOPSIS - xsltproc docutils.xml xml2rst.xsl + xsltproc docutils.xml xml2rst-nopy.xsl + +=head1 NOTE + +Today B is not the recommended way to use +B. The preferred way is to install B and use +B instead. =head1 DESCRIPTION -B is an XSLT script to convert Docutils XML to +B is an XSLT script to convert Docutils XML to reStructuredText. You can use your favorite XSLT processor supporting EXSLT (e.g. xsltproc from the Gnome project) to generate reStructuredText from the Docutils intermediate XML representation. @@ -3683,8 +3702,8 @@ reason is that Docutils transports pretty much but not all information of the original source into the XML. Also the sequence is changed sometimes. -However, the coverage of Docutils features of B is pretty -good. A few minor features are not supported: +However, the coverage of Docutils features of B is +pretty good. A few minor features are not supported: =over 4 diff --git a/sandbox/xml2rst/rst/xml2rst.xsl b/sandbox/xml2rst/rst/xml2rst.xsl index a763775cc..7c34db599 100644 --- a/sandbox/xml2rst/rst/xml2rst.xsl +++ b/sandbox/xml2rst/rst/xml2rst.xsl @@ -13,7 +13,7 @@ @@ -468,6 +469,8 @@ data: Data elements used by the stylesheet + @@ -1036,10 +1039,13 @@ data: Data elements used by the stylesheet + + - + test="$isParsedLiteral"> .. parsed-literal:: @@ -1086,7 +1092,16 @@ data: Data elements used by the stylesheet name="ancestors" select="ancestor-or-self::*"/> - + + + + + + + + &tEOL; @@ -1107,6 +1122,9 @@ data: Data elements used by the stylesheet select="ancestor::*[position() > 1]"/> + @@ -1246,7 +1264,8 @@ data: Data elements used by the stylesheet name="ancestors" select="ancestor-or-self::*"/> - + &tEOL; @@ -2792,8 +2811,19 @@ data: Data elements used by the stylesheet name="u:outputNamesRefid"/> + + + ` + + + ` + : @@ -2893,6 +2923,17 @@ data: Data elements used by the stylesheet name="u:indentLF"/> + + + + + + @@ -2945,62 +2986,62 @@ data: Data elements used by the stylesheet Indent a block if it's a child of... --> - - - - - - - - - - - - - - - - - - @@ -3042,7 +3083,7 @@ data: Data elements used by the stylesheet + select="str:padding(document('')//data:lookup/data:node[@name=$this]/@indent)"/> @@ -3063,33 +3104,11 @@ data: Data elements used by the stylesheet - - - - - &tEOL; - - - - - - - - - - - - - + + @@ -3612,116 +3631,3 @@ data: Data elements used by the stylesheet - - - - - diff --git a/sandbox/xml2rst/setup.py b/sandbox/xml2rst/setup.py index 9d59629bb..ec0f7420f 100755 --- a/sandbox/xml2rst/setup.py +++ b/sandbox/xml2rst/setup.py @@ -14,5 +14,6 @@ setup(name='xml2rst', requires=[ 'docutils', 'lxml' ], scripts=[ 'xml2rst.py' ], packages=[ 'rst' ], - package_data={ 'rst': [ 'xml2rst.xsl', 'xml2rst-noexslt.xsl' ], }, + package_data={ 'rst': [ 'xml2rst.xsl', + 'xml2rst-nopy.xsl', 'xml2rst-noexslt.xsl' ], }, ) diff --git a/sandbox/xml2rst/tag.log b/sandbox/xml2rst/tag.log index c0d619d0b..e89fe9862 100644 --- a/sandbox/xml2rst/tag.log +++ b/sandbox/xml2rst/tag.log @@ -1 +1 @@ -xml2rst_1_202 +xml2rst_1_224 diff --git a/sandbox/xml2rst/tests.xalan/simple/filterunit.cfg b/sandbox/xml2rst/tests.xalan/simple/filterunit.cfg index 96a9c42ee..6e18a42cb 100644 --- a/sandbox/xml2rst/tests.xalan/simple/filterunit.cfg +++ b/sandbox/xml2rst/tests.xalan/simple/filterunit.cfg @@ -1,3 +1,8 @@ include ../common.cfg suiteDirectory = ../../tests/simple + + + # These tests need Python code + off = quoteBlock quoteOriginal + diff --git a/sandbox/xml2rst/tests.xsltproc/common.cfg b/sandbox/xml2rst/tests.xsltproc/common.cfg index ea64f21ab..e1e05bf63 100644 --- a/sandbox/xml2rst/tests.xsltproc/common.cfg +++ b/sandbox/xml2rst/tests.xsltproc/common.cfg @@ -2,4 +2,4 @@ inputExtension = .xml expectedExtension = .rst command = xsltproc -options = ../../rst/xml2rst.xsl - +arguments = ../../rst/xml2rst-nopy.xsl - diff --git a/sandbox/xml2rst/tests.xsltproc/options/filterunit.cfg b/sandbox/xml2rst/tests.xsltproc/options/filterunit.cfg index b5ffb7f92..60b833c5f 100644 --- a/sandbox/xml2rst/tests.xsltproc/options/filterunit.cfg +++ b/sandbox/xml2rst/tests.xsltproc/options/filterunit.cfg @@ -3,6 +3,6 @@ suiteDirectory = ../../tests/options inputExtension = .xml optionExtension = .xsltproc expectedExtension = .rst -arguments = ../../rst/xml2rst.xsl - +arguments = ../../rst/xml2rst-nopy.xsl - command = xsltproc diff --git a/sandbox/xml2rst/tests.xsltproc/simple/filterunit.cfg b/sandbox/xml2rst/tests.xsltproc/simple/filterunit.cfg index 96a9c42ee..6e18a42cb 100644 --- a/sandbox/xml2rst/tests.xsltproc/simple/filterunit.cfg +++ b/sandbox/xml2rst/tests.xsltproc/simple/filterunit.cfg @@ -1,3 +1,8 @@ include ../common.cfg suiteDirectory = ../../tests/simple + + + # These tests need Python code + off = quoteBlock quoteOriginal + diff --git a/sandbox/xml2rst/tests/options/readable/adornmentX.xml b/sandbox/xml2rst/tests/options/readable/adornmentX.xml index 58a745ef9..81926f480 100644 --- a/sandbox/xml2rst/tests/options/readable/adornmentX.xml +++ b/sandbox/xml2rst/tests/options/readable/adornmentX.xml @@ -1,5 +1,5 @@ - + Title diff --git a/sandbox/xml2rst/tests/options/readable/foldX.xml b/sandbox/xml2rst/tests/options/readable/foldX.xml index 238ef014e..8ecfac75b 100644 --- a/sandbox/xml2rst/tests/options/readable/foldX.xml +++ b/sandbox/xml2rst/tests/options/readable/foldX.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Generated by Docutils 0.8 --> +<!-- Generated by Docutils 0.9 --> <document source="original/foldX.rst"> <paragraph> This is a text consisting of many lines. The lines are broken diff --git a/sandbox/xml2rst/tests/real/input/Machinery.xml b/sandbox/xml2rst/tests/real/input/Machinery.xml index 27f3bfeef..dc0b98055 100644 --- a/sandbox/xml2rst/tests/real/input/Machinery.xml +++ b/sandbox/xml2rst/tests/real/input/Machinery.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Generated by Docutils 0.8 --> +<!-- Generated by Docutils 0.9 --> <document source="original/Machinery.rst"><paragraph>#format rst #language en</paragraph><paragraph><reference anonymous="1" name="Discussion" refuri="/Talk">Discussion</reference></paragraph><target anonymous="1" ids="id1" refuri="/Talk"/><topic classes="contents" ids="contents" names="contents"><title>ContentsOverviewDedicated Oekonux serverMailing listsExisting listsHostingFeaturesSpam protectionWeb sitesHostingProviderDomainsFeaturesWeb spaceTrafficMail addressesGeneration and UploadStatic pagesNavigationLocale search engineRSS-FeedContentGeneralArchivesTextsLink pageStatisticsOpenTheoryWikiNews groupsFeaturesSearch engineThis page describes the machinery used by the Oekonux community. This page is motivated by a thread about this topic on the diff --git a/sandbox/xml2rst/tests/real/input/MediaWikiFAQ.xml b/sandbox/xml2rst/tests/real/input/MediaWikiFAQ.xml index 5b258b21a..13fe57b12 100644 --- a/sandbox/xml2rst/tests/real/input/MediaWikiFAQ.xml +++ b/sandbox/xml2rst/tests/real/input/MediaWikiFAQ.xml @@ -1,5 +1,5 @@ - + #format rst
FAQ for people used to Wikipedia and other MediaWiki wikisContentsFAQ for people used to Wikipedia and other MediaWiki wikisIntroductionQuestion and answersOf all usersWhat about the namespace concept?What about the Users: namespace?What about the Special: namespace?What about the Talk: namespace?Of editorsI'm used to MediaWiki syntax. Can I use it in this Wiki?Though I'm used to MediaWiki syntax I think it sucks. Any alternatives?I tried to create a new page and ended up on this page offering templates. What's this?Page templates, ok. What about the MediaWiki templates?
IntroductionThis page is a FAQ page for users used to Wikipedia and other MediaWiki 1 wikis. In Project Oekonux we chose MoinMoin because at the time of the decision there was a slight technological diff --git a/sandbox/xml2rst/tests/real/input/Technik.xml b/sandbox/xml2rst/tests/real/input/Technik.xml index bbc3bb78b..a5c80fa2a 100644 --- a/sandbox/xml2rst/tests/real/input/Technik.xml +++ b/sandbox/xml2rst/tests/real/input/Technik.xml @@ -1,5 +1,5 @@ - + Sorry, wegen kaputter Formatierung, aber ich habe keine Ahnung, wie das geht und es gibt leider keine Hilfe. Ich verwende einfach mal reStructuredText.Diese Seite beschäftigt sich mit der Technik, die die diff --git a/sandbox/xml2rst/tests/real/input/WikiRequirements.xml b/sandbox/xml2rst/tests/real/input/WikiRequirements.xml index 1980f9e52..4f5763084 100644 --- a/sandbox/xml2rst/tests/real/input/WikiRequirements.xml +++ b/sandbox/xml2rst/tests/real/input/WikiRequirements.xml @@ -1,5 +1,5 @@ - + #FORMAT rst
Requirements for an Oekonux WikiContentsRequirements for an Oekonux WikiIntroductionRequirementsNon-functional requirementsFunctional requirementsRequirements for policy choices########################################################################################################################################################
IntroductionIn Project Oekonux there has been a long discussion about setting up a Wiki for the project. Also several attempts to establish a Wiki have been made. Most of these discussions took place on the projekt mailing list diff --git a/sandbox/xml2rst/tests/real/readable/Machinery.xml b/sandbox/xml2rst/tests/real/readable/Machinery.xml index cf3c0089c..254f39d8a 100644 --- a/sandbox/xml2rst/tests/real/readable/Machinery.xml +++ b/sandbox/xml2rst/tests/real/readable/Machinery.xml @@ -1,5 +1,5 @@ - + #format rst diff --git a/sandbox/xml2rst/tests/real/readable/MediaWikiFAQ.xml b/sandbox/xml2rst/tests/real/readable/MediaWikiFAQ.xml index 17ee89893..cd75b1fcf 100644 --- a/sandbox/xml2rst/tests/real/readable/MediaWikiFAQ.xml +++ b/sandbox/xml2rst/tests/real/readable/MediaWikiFAQ.xml @@ -1,5 +1,5 @@ - + #format rst diff --git a/sandbox/xml2rst/tests/real/readable/Technik.xml b/sandbox/xml2rst/tests/real/readable/Technik.xml index 9487dcd8d..cb1e77223 100644 --- a/sandbox/xml2rst/tests/real/readable/Technik.xml +++ b/sandbox/xml2rst/tests/real/readable/Technik.xml @@ -1,5 +1,5 @@ - + diff --git a/sandbox/xml2rst/tests/real/readable/WikiRequirements.xml b/sandbox/xml2rst/tests/real/readable/WikiRequirements.xml index d7ecb2ae6..e4572fa12 100644 --- a/sandbox/xml2rst/tests/real/readable/WikiRequirements.xml +++ b/sandbox/xml2rst/tests/real/readable/WikiRequirements.xml @@ -1,5 +1,5 @@ - + #FORMAT rst diff --git a/sandbox/xml2rst/tests/simple/expected/docinfoHeader.rst b/sandbox/xml2rst/tests/simple/expected/docinfoHeader.rst new file mode 100644 index 000000000..e14c85b13 --- /dev/null +++ b/sandbox/xml2rst/tests/simple/expected/docinfoHeader.rst @@ -0,0 +1,18 @@ +===== +Title +===== + +:authors: Some Body; Some One +:organization: all + +Header +====== + +Text. + +:Field: Other field + +Another header +============== + +More text. diff --git a/sandbox/xml2rst/tests/simple/expected/quoteBlock.rst b/sandbox/xml2rst/tests/simple/expected/quoteBlock.rst new file mode 100644 index 000000000..8298d660e --- /dev/null +++ b/sandbox/xml2rst/tests/simple/expected/quoteBlock.rst @@ -0,0 +1,30 @@ +\.. Blocks must be detected and +\- quoted properly. This applies to +\.. directives:: just as well as +\* bullet lists +\+ of all types, +\1. enumerations, +\:fields: with a content and +\.. \|other| types:: of explicit markup +\.. _like hyperlink targets: +\__ even if abbreviated + +Section headers +\=============== + +and transitions + +\$$$$$$$$ + +are also subject to quoting. + +Standalone hyperlinks and tables - if crafted fine enough to be +recognized - are consciously kept. + +Markup in literal + +:: + + * blocks + + must *be left as is, however. diff --git a/sandbox/xml2rst/tests/simple/expected/quoteOriginal.rst b/sandbox/xml2rst/tests/simple/expected/quoteOriginal.rst new file mode 100644 index 000000000..32a96964c --- /dev/null +++ b/sandbox/xml2rst/tests/simple/expected/quoteOriginal.rst @@ -0,0 +1,19 @@ +The original \*text may contain \`sequences which \**strongly +look like [incomplete \``markup to \|rst. This is inline\_ including\__ +\_`inline targets. Backslashes must be \\retained as well. + +But \*emphasis* \`title ref`, \**strong**, [CIT]\_, [#foot]\_, \`multi +word ref`_, \``literal``, \|sub|, and \_`target` need to be handled, +too. :as:\`well` \`as`:roles: :sub:\`applying` to \`known`:super:. + +Markup in literal + +:: + + * blocks + + must *be left as is, however. + +.. raw:: html + + In \raw |parts|, too diff --git a/sandbox/xml2rst/tests/simple/expected/targets.rst b/sandbox/xml2rst/tests/simple/expected/targets.rst index ca4359dd4..b32ccc6fd 100644 --- a/sandbox/xml2rst/tests/simple/expected/targets.rst +++ b/sandbox/xml2rst/tests/simple/expected/targets.rst @@ -16,8 +16,12 @@ Another header Some text with reference to the `additional header target`_. +A `special target containing a: colon`_. + .. _first target: .. _second target: .. _third target: http://www.example.com/ + +.. _`special target containing a: colon`: http://www.example.org/ diff --git a/sandbox/xml2rst/tests/simple/filterunit.cfg b/sandbox/xml2rst/tests/simple/filterunit.cfg index 16e6dcb01..2a98c52a1 100644 --- a/sandbox/xml2rst/tests/simple/filterunit.cfg +++ b/sandbox/xml2rst/tests/simple/filterunit.cfg @@ -3,3 +3,8 @@ expectedExtension = .rst command = ../../xml2rst.py arguments = $< + +# Not implemented yet + + off = quoteBlock + diff --git a/sandbox/xml2rst/tests/simple/input/docinfoHeader.xml b/sandbox/xml2rst/tests/simple/input/docinfoHeader.xml new file mode 100644 index 000000000..8dc5de32e --- /dev/null +++ b/sandbox/xml2rst/tests/simple/input/docinfoHeader.xml @@ -0,0 +1,3 @@ + + +TitleSome BodySome Oneall
HeaderText.FieldOther field
Another headerMore text.
\ No newline at end of file diff --git a/sandbox/xml2rst/tests/simple/input/header.xml b/sandbox/xml2rst/tests/simple/input/header.xml index c3631e945..0aafd34a0 100644 --- a/sandbox/xml2rst/tests/simple/input/header.xml +++ b/sandbox/xml2rst/tests/simple/input/header.xml @@ -1,3 +1,3 @@ - + Some text.
A headerText under header.
\ No newline at end of file diff --git a/sandbox/xml2rst/tests/simple/input/manyLines.xml b/sandbox/xml2rst/tests/simple/input/manyLines.xml index ae95583f7..cb78cba95 100644 --- a/sandbox/xml2rst/tests/simple/input/manyLines.xml +++ b/sandbox/xml2rst/tests/simple/input/manyLines.xml @@ -1,5 +1,5 @@ - + This is a text consisting of many lines. The lines are broken according to the "natural" folding of Emacs. This folding sets in at the fill-column which happens to be [^HV fill-column] 70 in this case. diff --git a/sandbox/xml2rst/tests/simple/input/oneLine.xml b/sandbox/xml2rst/tests/simple/input/oneLine.xml index 038b26370..4c88a8e21 100644 --- a/sandbox/xml2rst/tests/simple/input/oneLine.xml +++ b/sandbox/xml2rst/tests/simple/input/oneLine.xml @@ -1,3 +1,3 @@ - + One line. \ No newline at end of file diff --git a/sandbox/xml2rst/tests/simple/input/quoteBlock.xml b/sandbox/xml2rst/tests/simple/input/quoteBlock.xml new file mode 100644 index 000000000..ef586fdf6 --- /dev/null +++ b/sandbox/xml2rst/tests/simple/input/quoteBlock.xml @@ -0,0 +1,16 @@ + + +.. Blocks must be detected and +- quoted properly. This applies to +.. directives:: just as well as +* bullet lists ++ of all types, +1. enumerations, +:fields: with a content and +.. |other| types:: of explicit markup +.. _like hyperlink targets: +__ even if abbreviatedSection headers +===============and transitions$$$$$$$$are also subject to quoting.Standalone hyperlinks and tables - if crafted fine enough to be +recognized - are consciously kept.Markup in literal* blocks + +must *be left as is, however. \ No newline at end of file diff --git a/sandbox/xml2rst/tests/simple/input/quoteOriginal.xml b/sandbox/xml2rst/tests/simple/input/quoteOriginal.xml new file mode 100644 index 000000000..5aeff4835 --- /dev/null +++ b/sandbox/xml2rst/tests/simple/input/quoteOriginal.xml @@ -0,0 +1,9 @@ + + +The original *text may contain `sequences which **strongly +look like [incomplete ``markup to |rst. This is inline_ including__ +_`inline targets. Backslashes must be \retained as well.But *emphasis* `title ref`, **strong**, [CIT]_, [#foot]_, `multi +word ref`_, ``literal``, |sub|, and _`target` need to be handled, +too. :as:`well` `as`:roles: :sub:`applying` to `known`:super:.Markup in literal* blocks + +must *be left as is, however.In \raw |parts|, too \ No newline at end of file diff --git a/sandbox/xml2rst/tests/simple/input/targets.xml b/sandbox/xml2rst/tests/simple/input/targets.xml index f731e4f03..17802be6d 100644 --- a/sandbox/xml2rst/tests/simple/input/targets.xml +++ b/sandbox/xml2rst/tests/simple/input/targets.xml @@ -1,4 +1,4 @@ - + Some text containing an internal target.
A headerThere can be an external target, a header or an internal -target.
Another headerSome text with reference to the additional header target.
\ No newline at end of file +target.
Another headerSome text with reference to the additional header target.A special target containing a: colon.
\ No newline at end of file diff --git a/sandbox/xml2rst/tests/simple/input/titles.xml b/sandbox/xml2rst/tests/simple/input/titles.xml index 1e6816092..1116c78fa 100644 --- a/sandbox/xml2rst/tests/simple/input/titles.xml +++ b/sandbox/xml2rst/tests/simple/input/titles.xml @@ -1,3 +1,3 @@ - + The title - autoraisedThe subtitle - also autoraised
The first sectionSome text in the first section.
The second secondMore text.
\ No newline at end of file diff --git a/sandbox/xml2rst/tests/simple/original/docinfoHeader.rst b/sandbox/xml2rst/tests/simple/original/docinfoHeader.rst new file mode 100644 index 000000000..ba713dcff --- /dev/null +++ b/sandbox/xml2rst/tests/simple/original/docinfoHeader.rst @@ -0,0 +1,18 @@ +===== +Title +===== + +:Authors: Some Body; Some One +:Organization: all + +Header +====== + +Text. + +:Field: Other field + +Another header +============== + +More text. diff --git a/sandbox/xml2rst/tests/simple/original/quoteBlock.rst b/sandbox/xml2rst/tests/simple/original/quoteBlock.rst new file mode 100644 index 000000000..949a455ef --- /dev/null +++ b/sandbox/xml2rst/tests/simple/original/quoteBlock.rst @@ -0,0 +1,28 @@ +\.. Blocks must be detected and +\- quoted properly. This applies to +\.. directives:: just as well as +\* bullet lists +\+ of all types, +\1. enumerations, +\:fields: with a content and +\.. \|other| types:: of explicit markup +\.. _like hyperlink targets: +\__ even if abbreviated + +Section headers +\=============== + +and transitions + +\$$$$$$$$ + +are also subject to quoting. + +Standalone hyperlinks and tables - if crafted fine enough to be +recognized - are consciously kept. + +Markup in literal :: + + * blocks + + must *be left as is, however. diff --git a/sandbox/xml2rst/tests/simple/original/quoteOriginal.rst b/sandbox/xml2rst/tests/simple/original/quoteOriginal.rst new file mode 100644 index 000000000..8e062539b --- /dev/null +++ b/sandbox/xml2rst/tests/simple/original/quoteOriginal.rst @@ -0,0 +1,17 @@ +The original \*text may contain \`sequences which \**strongly +look like \[incomplete \``markup to \|rst. This is inline\_ including\__ +\_`inline targets. \Backslashes must be \\retained as well. + +But \*emphasis* \`title ref`, \**strong**, [CIT]\_, [#foot]\_, \`multi +word ref`_, \``literal``, \|sub|, and \_`target` need to be handled, +too. :as:\`well` \`as`:roles: :sub:\`applying` to \`known`:super:. + +Markup in literal :: + + * blocks + + must *be left as is, however. + +.. raw:: html + + In \raw |parts|, too diff --git a/sandbox/xml2rst/tests/simple/original/targets.rst b/sandbox/xml2rst/tests/simple/original/targets.rst index 6c5807462..9531c9b64 100644 --- a/sandbox/xml2rst/tests/simple/original/targets.rst +++ b/sandbox/xml2rst/tests/simple/original/targets.rst @@ -15,6 +15,10 @@ Another header Some text with reference to the `additional header target`_. +A `special target containing a: colon`_. + .. _first target: .. _second target: .. _third target: http://www.example.com/ + +.. _`special target containing a: colon`: http://www.example.org/ diff --git a/sandbox/xml2rst/tests/simple/readable/docinfoHeader.xml b/sandbox/xml2rst/tests/simple/readable/docinfoHeader.xml new file mode 100644 index 000000000..4cd23dc38 --- /dev/null +++ b/sandbox/xml2rst/tests/simple/readable/docinfoHeader.xml @@ -0,0 +1,48 @@ + + + + + Title + + + + + Some Body + + + Some One + + + + all + + +
+ + Header + + + Text. + + + + + Field + + + + Other field + + + + +
+
+ + Another header + + + More text. + +
+
diff --git a/sandbox/xml2rst/tests/simple/readable/header.xml b/sandbox/xml2rst/tests/simple/readable/header.xml index 355d4b51e..1844c3c28 100644 --- a/sandbox/xml2rst/tests/simple/readable/header.xml +++ b/sandbox/xml2rst/tests/simple/readable/header.xml @@ -1,5 +1,5 @@ - + Some text. diff --git a/sandbox/xml2rst/tests/simple/readable/manyLines.xml b/sandbox/xml2rst/tests/simple/readable/manyLines.xml index 0f59a7e4b..66d5dcb4f 100644 --- a/sandbox/xml2rst/tests/simple/readable/manyLines.xml +++ b/sandbox/xml2rst/tests/simple/readable/manyLines.xml @@ -1,5 +1,5 @@ - + This is a text consisting of many lines. The lines are broken diff --git a/sandbox/xml2rst/tests/simple/readable/oneLine.xml b/sandbox/xml2rst/tests/simple/readable/oneLine.xml index ff5d9a59f..8a22bd011 100644 --- a/sandbox/xml2rst/tests/simple/readable/oneLine.xml +++ b/sandbox/xml2rst/tests/simple/readable/oneLine.xml @@ -1,5 +1,5 @@ - + One line. diff --git a/sandbox/xml2rst/tests/simple/readable/quoteBlock.xml b/sandbox/xml2rst/tests/simple/readable/quoteBlock.xml new file mode 100644 index 000000000..022ce70d3 --- /dev/null +++ b/sandbox/xml2rst/tests/simple/readable/quoteBlock.xml @@ -0,0 +1,41 @@ + + + + + .. Blocks must be detected and +- quoted properly. This applies to +.. directives:: just as well as +* bullet lists ++ of all types, +1. enumerations, +:fields: with a content and +.. |other| types:: of explicit markup +.. _like hyperlink targets: +__ even if abbreviated + + + Section headers +=============== + + + and transitions + + + $$$$$$$$ + + + are also subject to quoting. + + + Standalone hyperlinks and tables - if crafted fine enough to be +recognized - are consciously kept. + + + Markup in literal + + + * blocks + +must *be left as is, however. + + diff --git a/sandbox/xml2rst/tests/simple/readable/quoteOriginal.xml b/sandbox/xml2rst/tests/simple/readable/quoteOriginal.xml new file mode 100644 index 000000000..80cf21856 --- /dev/null +++ b/sandbox/xml2rst/tests/simple/readable/quoteOriginal.xml @@ -0,0 +1,25 @@ + + + + + The original *text may contain `sequences which **strongly +look like [incomplete ``markup to |rst. This is inline_ including__ +_`inline targets. Backslashes must be \retained as well. + + + But *emphasis* `title ref`, **strong**, [CIT]_, [#foot]_, `multi +word ref`_, ``literal``, |sub|, and _`target` need to be handled, +too. :as:`well` `as`:roles: :sub:`applying` to `known`:super:. + + + Markup in literal + + + * blocks + +must *be left as is, however. + + + In \raw |parts|, too + + diff --git a/sandbox/xml2rst/tests/simple/readable/targets.xml b/sandbox/xml2rst/tests/simple/readable/targets.xml index 7e98980d5..a37a732fa 100644 --- a/sandbox/xml2rst/tests/simple/readable/targets.xml +++ b/sandbox/xml2rst/tests/simple/readable/targets.xml @@ -1,5 +1,5 @@ - + Some text containing an @@ -41,9 +41,17 @@ target . + + A + + special target containing a: colon + + . + +
diff --git a/sandbox/xml2rst/tests/simple/readable/titles.xml b/sandbox/xml2rst/tests/simple/readable/titles.xml index 0578453b6..f44741cad 100644 --- a/sandbox/xml2rst/tests/simple/readable/titles.xml +++ b/sandbox/xml2rst/tests/simple/readable/titles.xml @@ -1,5 +1,5 @@ - + The title - autoraised diff --git a/sandbox/xml2rst/tests/synthetic/expected/class.rst b/sandbox/xml2rst/tests/synthetic/expected/class.rst index ea57b1788..a55e9cfe3 100644 --- a/sandbox/xml2rst/tests/synthetic/expected/class.rst +++ b/sandbox/xml2rst/tests/synthetic/expected/class.rst @@ -13,6 +13,7 @@ Examples of Syntax Constructs ----------------------------- :author: David Goodger + .. bibliographic fields (which also require a transform): .. class:: c5 diff --git a/sandbox/xml2rst/tests/synthetic/expected/standard_0_3_7.rst b/sandbox/xml2rst/tests/synthetic/expected/standard_0_3_7.rst index dd00b5be5..955eb2de7 100644 --- a/sandbox/xml2rst/tests/synthetic/expected/standard_0_3_7.rst +++ b/sandbox/xml2rst/tests/synthetic/expected/standard_0_3_7.rst @@ -33,6 +33,7 @@ Examples of Syntax Constructs Like this. + :Dedication: For Docutils users & co-developers. diff --git a/sandbox/xml2rst/tests/synthetic/expected/standard_r6008.rst b/sandbox/xml2rst/tests/synthetic/expected/standard_r6008.rst index 583fa06b8..3b9a0d4ef 100644 --- a/sandbox/xml2rst/tests/synthetic/expected/standard_r6008.rst +++ b/sandbox/xml2rst/tests/synthetic/expected/standard_r6008.rst @@ -33,6 +33,7 @@ Examples of Syntax Constructs Like this. + :Dedication: For Docutils users & co-developers. diff --git a/sandbox/xml2rst/tests/synthetic/input/class.xml b/sandbox/xml2rst/tests/synthetic/input/class.xml index d5d940f66..20518bc40 100644 --- a/sandbox/xml2rst/tests/synthetic/input/class.xml +++ b/sandbox/xml2rst/tests/synthetic/input/class.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Generated by Docutils 0.8 --> +<!-- Generated by Docutils 0.9 --> <document classes="c1 c2" ids="restructuredtext-test-document" names="restructuredtext\ test\ document" source="original/class.rst" title="reStructuredText Test Document"><title>reStructuredText Test DocumentExamples of Syntax ConstructsDavid Goodgerbibliographic fields (which also require a transform):Address123 Example Street Example, EX Canada A1B 2C3Contactgoodger@users.sourceforge.netAuthorsMe; Myself; IorganizationhumankinddateNow, or yesterday. Or maybe even before yesterday.statusThis is a "work in progress"revisionis managed by a version control system.version1copyrightThis document has been placed in the public domain. You may do with it as you wish. You may copy, modify, redistribute, reattribute, sell, buy, rent, lease, destroy, or improve it, quote it at length, diff --git a/sandbox/xml2rst/tests/synthetic/input/standard_0_3_7.xml b/sandbox/xml2rst/tests/synthetic/input/standard_0_3_7.xml index 8843abd0a..6fdd5f681 100644 --- a/sandbox/xml2rst/tests/synthetic/input/standard_0_3_7.xml +++ b/sandbox/xml2rst/tests/synthetic/input/standard_0_3_7.xml @@ -1,5 +1,5 @@ - + reStructuredText Test DocumentExamples of Syntax ConstructsDavid Goodger
123 Example Street Example, EX Canada A1B 2C3
goodger@users.sourceforge.netMeMyselfIhumankindNow, or yesterday. Or maybe even before yesterday.This is a "work in progress"is managed by a version control system.1This document has been placed in the public domain. You diff --git a/sandbox/xml2rst/tests/synthetic/input/standard_r6008.xml b/sandbox/xml2rst/tests/synthetic/input/standard_r6008.xml index 3ec8d4804..c7890193c 100644 --- a/sandbox/xml2rst/tests/synthetic/input/standard_r6008.xml +++ b/sandbox/xml2rst/tests/synthetic/input/standard_r6008.xml @@ -1,5 +1,5 @@ - + reStructuredText Test DocumentExamples of Syntax ConstructsDavid Goodger
123 Example Street Example, EX Canada A1B 2C3
goodger@python.orgMeMyselfIhumankindNow, or yesterday. Or maybe even before yesterday.This is a "work in progress"is managed by a version control system.1This document has been placed in the public domain. You diff --git a/sandbox/xml2rst/tests/synthetic/readable/class.xml b/sandbox/xml2rst/tests/synthetic/readable/class.xml index da1d37784..b1d2ef5d8 100644 --- a/sandbox/xml2rst/tests/synthetic/readable/class.xml +++ b/sandbox/xml2rst/tests/synthetic/readable/class.xml @@ -1,5 +1,5 @@ - + reStructuredText Test Document diff --git a/sandbox/xml2rst/tests/synthetic/readable/standard_0_3_7.xml b/sandbox/xml2rst/tests/synthetic/readable/standard_0_3_7.xml index 62fcebf59..dbf20aba8 100644 --- a/sandbox/xml2rst/tests/synthetic/readable/standard_0_3_7.xml +++ b/sandbox/xml2rst/tests/synthetic/readable/standard_0_3_7.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Generated by Docutils 0.8 --> +<!-- Generated by Docutils 0.9 --> <document ids="restructuredtext-test-document doctitle" names="restructuredtext\ test\ document doctitle" source="original/standard_0_3_7.rst" title="reStructuredText Test Document"> <title> reStructuredText Test Document diff --git a/sandbox/xml2rst/tests/synthetic/readable/standard_r6008.xml b/sandbox/xml2rst/tests/synthetic/readable/standard_r6008.xml index 6075d2cba..ff25b18a2 100644 --- a/sandbox/xml2rst/tests/synthetic/readable/standard_r6008.xml +++ b/sandbox/xml2rst/tests/synthetic/readable/standard_r6008.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Generated by Docutils 0.8 --> +<!-- Generated by Docutils 0.9 --> <document ids="restructuredtext-test-document doctitle" names="restructuredtext\ test\ document doctitle" source="original/standard_r6008.rst" title="reStructuredText Test Document"> <title> reStructuredText Test Document diff --git a/sandbox/xml2rst/version.py b/sandbox/xml2rst/version.py index cbe8c15bd..4eda78c41 100644 --- a/sandbox/xml2rst/version.py +++ b/sandbox/xml2rst/version.py @@ -1 +1 @@ -version = '0.6.1' +version = '1.0.2' -- 2.11.4.GIT