[Zope-Checkins] CVS: Zope/lib/python/DocumentTemplate - DT_Var.py:1.58.10.3
Andreas Jung
andreas@digicool.com
Tue, 5 Nov 2002 13:42:25 -0500
Update of /cvs-repository/Zope/lib/python/DocumentTemplate
In directory cvs.zope.org:/tmp/cvs-serv22389/DocumentTemplate
Modified Files:
Tag: ajung-restructuredtext-integration-branch
DT_Var.py
Log Message:
refactored code
=== Zope/lib/python/DocumentTemplate/DT_Var.py 1.58.10.2 => 1.58.10.3 ===
--- Zope/lib/python/DocumentTemplate/DT_Var.py:1.58.10.2 Tue Nov 5 04:38:23 2002
+++ Zope/lib/python/DocumentTemplate/DT_Var.py Tue Nov 5 13:42:25 2002
@@ -162,7 +162,6 @@
from types import StringType
from Acquisition import aq_base
from ZPublisher.TaintedString import TaintedString
-import docutils.core
class Var:
name='var'
@@ -399,61 +398,14 @@
def restructured_text(v, name='(Unknown name)', md={}):
- class Warnings:
- def __init__(self):
- self.messages = []
- def write(self, message):
- self.messages.append(message)
-
+ from reStructuredText import HTML
if isinstance(v,StringType): txt = v
elif aq_base(v).meta_type in ['DTML Document','DTML Method']:
txt = aq_base(v).read_raw()
else: txt = str(v)
- pub = docutils.core.Publisher()
- pub.set_reader('restructuredtext', None, 'restructuredtext')
- pub.set_writer('html4zope')
-
- # go with the defaults
- pub.get_settings()
-
- # this is needed, but doesn't seem to do anything
- pub.settings._destination = ''
-
- # use the stylesheet chosen by the user
-# pub.settings.stylesheet = self.stylesheet
-
- # set the reporting level to something sane
- pub.settings.report_level = 5
-
- # don't break if we get errors
- pub.settings.halt_level = 6
-
- # remember warnings
- pub.settings.warning_stream = Warnings()
-
- # input
- pub.source = docutils.io.StringInput(pub.settings)
-# pub.source.source = self.source
- pub.source.source = txt
-
- # output - not that it's needed
- pub.destination = docutils.io.StringOutput(pub.settings)
-
- # parse!
- document = pub.reader.read(pub.source, pub.parser, pub.settings)
-
-# self.warnings = ''.join(pub.settings.warning_stream.messages)
-
-# if document.children:
-# item = document.children[0]
-# if item.tagname == 'title':
-# self.title = str(item.children[0])
-
- # do the format
- formatted = pub.writer.write(document, pub.destination)
- return formatted
+ return HTML(txt)
StructuredText=None