Ceasar / Encyclopedia

Tool for keeping a hypermedia encyclopedia
MIT License
55 stars 7 forks source link

It should be possible to compile templates without `make` #34

Closed Ceasar closed 10 years ago

Ceasar commented 10 years ago

rst2html.py is just a Python script which reads a file and turns it into HTML. If we can compile rst files from within Python, we will gain several benefits:

Ceasar commented 10 years ago

I discovered minutes ago we can do this by extending the following working script 1:

from docutils import core
from docutils.writers.html4css1 import Writer, HTMLTranslator

if __name__ == '__main__':
    test = """
Test example of reST__ document.

__ http://docutils.sf.net/rst.html

- item 1
- item 2
- item 3

"""
    writer = Writer()
    writer.translator_class = HTMLTranslator
    print core.publish_string(test, writer=writer)
Ceasar commented 10 years ago

This should have been closed by https://github.com/Ceasar/Encyclopedia/commit/406dbdb1192b20a0f79106f870567738003e3b99.