Example stylesheets for syntax highlight of code snippets.
[docutils/kirr.git] / sandbox / code-block-directive / rst2html-highlight.py
blob5924da7cf622db5ea8eef718091d4adc7b929a7d
1 #!/usr/bin/python
2 # coding: utf-8
4 # rst2html-highlight
5 # ==================
6 #
7 # Docutils front-end with syntax highlight.
8 #
9 # :Author: David Goodger, Georg Brandl, Günter Milde
10 # :Date: $Date: 2008-05-22 08:42:52 +0200 (Do, 22. Mai 2008) $
11 # :Copyright: This module has been placed in the public domain.
13 # This is a merge of the docutils_ `rst2html` front end with an extension
14 # suggestion by Felix Wiemann.
16 # ::
18 """
19 A front end to docutils, producing HTML with syntax colouring using pygments
21 Generates (X)HTML documents from standalone reStructuredText sources. Uses
22 `pygments` to parse and mark up the content of ``.. code::` directives.
23 Needs an adapted stylesheet
24 """
26 # Requirements
27 # ------------
29 # ::
31 try:
32 import locale
33 locale.setlocale(locale.LC_ALL, '')
34 except:
35 pass
37 from docutils.core import publish_cmdline, default_description
39 # The `pygments_code_block_directive`_ module defines and registers a new
40 # directive `code` that uses the `pygments`_ source highlighter to
41 # render code in color::
43 import pygments_code_block_directive
45 # Call the docutils publisher to render the input as html::
47 description = __doc__ + default_description
48 publish_cmdline(writer_name='html', description=description)
50 # .. _docutils: http://docutils.sf.net/
51 # .. _pygments_code_block_directive: pygments_code_block_directive.py
52 # .. _pygments: http://pygments.org/
53 # .. _Using Pygments in ReST documents: http://pygments.org/docs/rstdirective/