Skip to content
This repository has been archived by the owner on Feb 6, 2022. It is now read-only.

Definitions for a reStructuredText code-block directive using pygments, and scripts to render HTML and LaTeX.

Notifications You must be signed in to change notification settings

dwf/pygments-code-block-directive

Repository files navigation

rst2html-highlight

Docutils front-end with syntax highlight.

Author

David Goodger, a Pygments author|contributor, Guenter Milde

Date

$Date: 2008-05-22 08:42:52 +0200 (Don, 22 Mai 2008) $

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  
"""

Requirements

try:
    import locale
    locale.setlocale(locale.LC_ALL, '')
except:
    pass

from docutils.core import publish_cmdline, default_description

The pygments_code_block_directive module defines and registers 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)

About

Definitions for a reStructuredText code-block directive using pygments, and scripts to render HTML and LaTeX.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages