summaryrefslogtreecommitdiff
path: root/docutils/tools
diff options
context:
space:
mode:
authormilde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2020-12-01 11:38:25 +0000
committermilde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2020-12-01 11:38:25 +0000
commit8686cf2dfe321f3e4febbb036e1cad7bcfbdea20 (patch)
tree1eb1c1297a7bcc535a8e3dc32ee5d9fd977ad39b /docutils/tools
parentacefd27f9221cd2ced4085449004f00e1414aac6 (diff)
downloaddocutils-8686cf2dfe321f3e4febbb036e1cad7bcfbdea20.tar.gz
Add support for Markdown.
Provide a wrapper for the 3rd party `recommonmark`__ Markdown parser already in use in Sphinx. Add test cases for CommonMark parsing. Also: Correct copyright note and set executable bit on two tests. Fix small typo in test content. __ https://pypi.org/project/recommonmark/ git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@8585 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils/tools')
-rwxr-xr-xdocutils/tools/md2html5.py39
-rw-r--r--docutils/tools/md2pseudoxml.py33
-rw-r--r--docutils/tools/md2xml.py34
3 files changed, 106 insertions, 0 deletions
diff --git a/docutils/tools/md2html5.py b/docutils/tools/md2html5.py
new file mode 100755
index 000000000..55b9238ce
--- /dev/null
+++ b/docutils/tools/md2html5.py
@@ -0,0 +1,39 @@
+#!/usr/bin/env python
+# -*- coding: utf8 -*-
+# :Copyright: © 2020 Günter Milde.
+# :License: Released under the terms of the `2-Clause BSD license`_, in short:
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.
+# This file is offered as-is, without any warranty.
+#
+# .. _2-Clause BSD license: https://opensource.org/licenses/BSD-2-Clause
+#
+# Revision: $Revision$
+# Date: $Date$
+
+"""
+A minimal front end to the Docutils Publisher, parsing CommonMark markdown files
+with `recommonmark` and producing HTML 5 documents.
+
+The output is also valid XML.
+"""
+
+try:
+ import locale # module missing in Jython
+ locale.setlocale(locale.LC_ALL, '')
+except locale.Error:
+ pass
+
+from docutils.core import publish_cmdline, default_description
+
+
+description = (u'Generate HTML5 documents from standalone '
+ u'Markdown (CommonMark) sources.\n'
+ + default_description)
+
+publish_cmdline(#parser=mdparser,
+ parser_name="recommonmark",
+ writer_name='html5',
+ description=description)
diff --git a/docutils/tools/md2pseudoxml.py b/docutils/tools/md2pseudoxml.py
new file mode 100644
index 000000000..17673347f
--- /dev/null
+++ b/docutils/tools/md2pseudoxml.py
@@ -0,0 +1,33 @@
+#!/usr/bin/env python
+# -*- coding: utf8 -*-
+# :Copyright: © 2020 Günter Milde.
+# :License: Released under the terms of the `2-Clause BSD license`_, in short:
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.
+# This file is offered as-is, without any warranty.
+#
+# .. _2-Clause BSD license: https://opensource.org/licenses/BSD-2-Clause
+#
+# Revision: $Revision$
+# Date: $Date$
+
+"""
+A minimal front end to the Docutils Publisher, parsing CommonMark markdown
+files with `recommonmark` and producing Pseudo-XML.
+"""
+
+try:
+ import locale
+ locale.setlocale(locale.LC_ALL, '')
+except:
+ pass
+
+from docutils.core import publish_cmdline, default_description
+
+
+description = ('Generates Pseudo-XML from standalone '
+ 'CommonMark sources. ' + default_description)
+
+publish_cmdline(parser_name='recommonmark', description=description)
diff --git a/docutils/tools/md2xml.py b/docutils/tools/md2xml.py
new file mode 100644
index 000000000..5743b7c39
--- /dev/null
+++ b/docutils/tools/md2xml.py
@@ -0,0 +1,34 @@
+#!/usr/bin/env python
+# -*- coding: utf8 -*-
+# :Copyright: © 2020 Günter Milde.
+# :License: Released under the terms of the `2-Clause BSD license`_, in short:
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.
+# This file is offered as-is, without any warranty.
+#
+# .. _2-Clause BSD license: https://opensource.org/licenses/BSD-2-Clause
+#
+# Revision: $Revision$
+# Date: $Date$
+
+"""
+A minimal front end to the Docutils Publisher, parsing CommonMark markdown
+files with `recommonmark` and producing Docutils XML.
+"""
+
+try:
+ import locale
+ locale.setlocale(locale.LC_ALL, '')
+except:
+ pass
+
+from docutils.core import publish_cmdline, default_description
+
+
+description = ('Generates Docutils-native XML from standalone '
+ 'CommonMark sources. ' + default_description)
+
+publish_cmdline(parser_name='recommonmark', writer_name='xml',
+ description=description)