File: rst2chtml.py

package info (click to toggle)
pywavelets 0.1.7~svn97-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 2,408 kB
  • ctags: 1,492
  • sloc: ansic: 3,375; python: 1,910; makefile: 44
file content (29 lines) | stat: -rw-r--r-- 819 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Author: Filip Wasilewski
# Date: $Date: 2007-09-11 22:46:56 +0200 (wto, 11.09.2007) $

import docutils
import docutils.parsers.rst
import colorize

def code_block( name, arguments, options, content, lineno,
             content_offset, block_text, state, state_machine ):

    html = colorize.Parser('\n'.join(content).encode('utf-8')).format()
    raw = docutils.nodes.raw('', html, format = 'html')
    return [raw]

code_block.arguments = (1,0,0)
code_block.options = {'language' : docutils.parsers.rst.directives.unchanged }
code_block.content = 1
  
docutils.parsers.rst.directives.register_directive('code-block', code_block )

def publish():
    import docutils.core
    docutils.core.publish_cmdline(writer_name='html')

if __name__ == "__main__":
    publish()