Commit 466c94d5 authored by Andreas Jung's avatar Andreas Jung

- removed debug print

- added env. variables for input/output encodings
parent f2b0ecee
...@@ -17,9 +17,14 @@ __all__ = ["HTML" ] ...@@ -17,9 +17,14 @@ __all__ = ["HTML" ]
import docutils.core import docutils.core
from docutils.io import StringOutput, StringInput from docutils.io import StringOutput, StringInput
import sys import sys, os
default_input_encoding = os.environ.get("REST_INPUT_ENCODING", sys.getdefaultencoding())
default_output_encoding = os.environ.get("REST_OUTPUT_ENCODING", sys.getdefaultencoding())
class Warnings: class Warnings:
def __init__(self): def __init__(self):
self.messages = [] self.messages = []
...@@ -28,7 +33,8 @@ class Warnings: ...@@ -28,7 +33,8 @@ class Warnings:
def HTML(src, writer='html4zope', report_level=1, stylesheet='default.css', def HTML(src, writer='html4zope', report_level=1, stylesheet='default.css',
input_encoding=None, output_encoding=None): input_encoding=default_input_encoding,
output_encoding=default_output_encoding):
""" render HTML from a reStructuredText string """ render HTML from a reStructuredText string
- 'src' -- string containing a valid reST document - 'src' -- string containing a valid reST document
...@@ -44,12 +50,6 @@ def HTML(src, writer='html4zope', report_level=1, stylesheet='default.css', ...@@ -44,12 +50,6 @@ def HTML(src, writer='html4zope', report_level=1, stylesheet='default.css',
pub.set_reader('standalone', None, 'restructuredtext') pub.set_reader('standalone', None, 'restructuredtext')
pub.set_writer(writer) pub.set_writer(writer)
if input_encoding is None:
input_encoding = sys.getdefaultencoding()
if output_encoding is None:
output_encoding = sys.getdefaultencoding()
# go with the defaults # go with the defaults
pub.get_settings() pub.get_settings()
...@@ -78,6 +78,5 @@ def HTML(src, writer='html4zope', report_level=1, stylesheet='default.css', ...@@ -78,6 +78,5 @@ def HTML(src, writer='html4zope', report_level=1, stylesheet='default.css',
warnings = ''.join(pub.settings.warning_stream.messages) warnings = ''.join(pub.settings.warning_stream.messages)
# do the format # do the format
print pub.writer.write(document, pub.destination)
return pub.writer.write(document, pub.destination) return pub.writer.write(document, pub.destination)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment