summaryrefslogtreecommitdiff
path: root/sandbox/code-block-directive/rst2html-highlight
diff options
context:
space:
mode:
authormilde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2007-06-13 10:20:42 +0000
committermilde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2007-06-13 10:20:42 +0000
commit37aec3754971395f373c48f5ca2a2aca4caaed96 (patch)
tree1f892c2dc24ccfe834071bebdda9d512c5497d18 /sandbox/code-block-directive/rst2html-highlight
parent2e5900fc8a1de5348802b8069ed65bb05e424263 (diff)
downloaddocutils-37aec3754971395f373c48f5ca2a2aca4caaed96.tar.gz
Added links to the README file.
self-documenting feature: literal code with syntax highlight Moved the front-end to the base dir. This way it works without installing. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@5234 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'sandbox/code-block-directive/rst2html-highlight')
-rwxr-xr-xsandbox/code-block-directive/rst2html-highlight36
1 files changed, 36 insertions, 0 deletions
diff --git a/sandbox/code-block-directive/rst2html-highlight b/sandbox/code-block-directive/rst2html-highlight
new file mode 100755
index 000000000..737a8c802
--- /dev/null
+++ b/sandbox/code-block-directive/rst2html-highlight
@@ -0,0 +1,36 @@
+#!/usr/bin/python
+
+# :Author: David Goodger, a Pygments author|contributor, Guenter Milde
+# :Date: $Date: $
+# :Copyright: This module has been placed in the public domain.
+
+# This is a merge of the docutils_ `rst2html` front end with an extension
+# suggestion taken from the pygments_ documentation.
+
+"""
+A front end to docutils, producing HTML with syntax colouring using pygments
+
+Generates (X)HTML documents from standalone reStructuredText sources. Uses
+`pygments` to parse and mark up the content of ``.. code-block::` directives.
+Needs an adapted stylesheet
+"""
+
+try:
+ import locale
+ locale.setlocale(locale.LC_ALL, '')
+except:
+ pass
+
+from docutils.core import publish_cmdline, default_description
+
+# Define and register a new directive `code-block` that uses the `pygments`_
+# source highlighter to render code in color.
+import pygments_code_block_directive
+
+# Call the docutils publisher to render the input as html::
+description = __doc__ + default_description
+publish_cmdline(writer_name='html', description=description)
+
+# .. _doctutile: http://docutils.sf.net/
+# .. _pygments: http://pygments.org/
+# .. _Using Pygments in ReST documents: http://pygments.org/docs/rstdirective/