Commit 791b17fa authored by Andreas Jung's avatar Andreas Jung

replace StructuredText module with zope.structuredtext

parent 3e1c30b7
...@@ -154,14 +154,17 @@ Evaluating expressions without rendering results ...@@ -154,14 +154,17 @@ Evaluating expressions without rendering results
__rcs_id__='$Id$' __rcs_id__='$Id$'
__version__='$Revision: 1.60 $'[11:-2] __version__='$Revision: 1.60 $'[11:-2]
from DT_Util import parse_params, name_param, str, ustr
import os, string, re, sys
from urllib import quote, quote_plus, unquote, unquote_plus
from cgi import escape from cgi import escape
import string, re, sys
from urllib import quote, quote_plus, unquote, unquote_plus
from DT_Util import parse_params, name_param, str, ustr
from html_quote import html_quote # for import by other modules, dont remove! from html_quote import html_quote # for import by other modules, dont remove!
from types import StringType
from Acquisition import aq_base from Acquisition import aq_base
from ZPublisher.TaintedString import TaintedString from ZPublisher.TaintedString import TaintedString
from zope.structuredtext.html import HTMLWithImages, HTML
from zope.structuredtext.document import DocumentWithImages
from App.config import getConfiguration
class Var: class Var:
name='var' name='var'
...@@ -400,30 +403,28 @@ def restructured_text(v, name='(Unknown name)', md={}): ...@@ -400,30 +403,28 @@ def restructured_text(v, name='(Unknown name)', md={}):
from reStructuredText import HTML from reStructuredText import HTML
if isinstance(v,StringType): txt = v if isinstance(v, str):
txt = v
elif aq_base(v).meta_type in ['DTML Document','DTML Method']: elif aq_base(v).meta_type in ['DTML Document','DTML Method']:
txt = aq_base(v).read_raw() txt = aq_base(v).read_raw()
else: txt = str(v) else:
txt = str(v)
return HTML(txt) return HTML(txt)
StructuredText=None
def structured_text(v, name='(Unknown name)', md={}): def structured_text(v, name='(Unknown name)', md={}):
global StructuredText
if StructuredText is None:
from StructuredText.StructuredText import HTML
if isinstance(v,StringType): txt = v
if isinstance(v, str):
txt = v
elif aq_base(v).meta_type in ['DTML Document','DTML Method']: elif aq_base(v).meta_type in ['DTML Document','DTML Method']:
txt = aq_base(v).read_raw() txt = aq_base(v).read_raw()
else:
txt = str(v)
else: txt = str(v) level = getConfiguration().structured_text_header_level
doc = DocumentWithImages()(txt)
return HTML(txt, return HTML()(doc, level, header=False)
level=int(os.environ.get('STX_DEFAULT_LEVEL',3)),
header=0)
def sql_quote(v, name='(Unknown name)', md={}): def sql_quote(v, name='(Unknown name)', md={}):
......
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