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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
""" Alias module for StructuredTextClassic compatibility which makes
use of StructuredTextNG """
import HTMLClass, DocumentClass, ClassicDocumentClass
from ST import Basic
import re, string,sys
from STletters import letters
Document = DocumentClass.DocumentClass()
HTMLNG = HTMLClass.HTMLClass()
def HTML(aStructuredString, level=1, header=1):
st = Basic(aStructuredString)
doc = Document(st)
return HTMLNG(doc,header=header,level=level)
def StructuredText(aStructuredString, level=1):
return HTML(aStructuredString,level)
def html_with_references(text, level=1, header=1):
text = re.sub(
r'[\000\n]\.\. \[([0-9_%s-]+)\]' % letters,
r'\n <a name="\1">[\1]</a>',
text)
text = re.sub(
r'([\000- ,])\[(?P<ref>[0-9_%s-]+)\]([\000- ,.:])' % letters,
r'\1<a href="#\2">[\2]</a>\3',
text)
text = re.sub(
r'([\000- ,])\[([^]]+)\.html\]([\000- ,.:])',
r'\1<a href="\2.html">[\2]</a>\3',
text)
return HTML(text,level=level,header=header)
def html_quote(v,
character_entities=(
(re.compile('&'), '&'),
(re.compile("<"), '<' ),
(re.compile(">"), '>' ),
(re.compile('"'), '"')
)): #"
text=str(v)
for re,name in character_entities:
text=re.sub(name,text)
return text
if __name__=='__main__':
import getopt
opts,args = getopt.getopt(sys.argv[1:],'',[])
for k,v in opts:
pass
for f in args:
print HTML(open(f).read())
|