]>
Commit | Line | Data |
---|---|---|
c12bc4de RD |
1 | ############################################################################## |
2 | # | |
3 | # Zope Public License (ZPL) Version 1.0 | |
4 | # ------------------------------------- | |
5 | # | |
6 | # Copyright (c) Digital Creations. All rights reserved. | |
7 | # | |
8 | # This license has been certified as Open Source(tm). | |
9 | # | |
10 | # Redistribution and use in source and binary forms, with or without | |
11 | # modification, are permitted provided that the following conditions are | |
12 | # met: | |
13 | # | |
14 | # 1. Redistributions in source code must retain the above copyright | |
15 | # notice, this list of conditions, and the following disclaimer. | |
16 | # | |
17 | # 2. Redistributions in binary form must reproduce the above copyright | |
18 | # notice, this list of conditions, and the following disclaimer in | |
19 | # the documentation and/or other materials provided with the | |
20 | # distribution. | |
21 | # | |
22 | # 3. Digital Creations requests that attribution be given to Zope | |
23 | # in any manner possible. Zope includes a "Powered by Zope" | |
24 | # button that is installed by default. While it is not a license | |
25 | # violation to remove this button, it is requested that the | |
26 | # attribution remain. A significant investment has been put | |
27 | # into Zope, and this effort will continue if the Zope community | |
28 | # continues to grow. This is one way to assure that growth. | |
29 | # | |
30 | # 4. All advertising materials and documentation mentioning | |
31 | # features derived from or use of this software must display | |
32 | # the following acknowledgement: | |
33 | # | |
34 | # "This product includes software developed by Digital Creations | |
35 | # for use in the Z Object Publishing Environment | |
36 | # (http://www.zope.org/)." | |
37 | # | |
38 | # In the event that the product being advertised includes an | |
39 | # intact Zope distribution (with copyright and license included) | |
40 | # then this clause is waived. | |
41 | # | |
42 | # 5. Names associated with Zope or Digital Creations must not be used to | |
43 | # endorse or promote products derived from this software without | |
44 | # prior written permission from Digital Creations. | |
45 | # | |
46 | # 6. Modified redistributions of any form whatsoever must retain | |
47 | # the following acknowledgment: | |
48 | # | |
49 | # "This product includes software developed by Digital Creations | |
50 | # for use in the Z Object Publishing Environment | |
51 | # (http://www.zope.org/)." | |
52 | # | |
53 | # Intact (re-)distributions of any official Zope release do not | |
54 | # require an external acknowledgement. | |
55 | # | |
56 | # 7. Modifications are encouraged but must be packaged separately as | |
57 | # patches to official Zope releases. Distributions that do not | |
58 | # clearly separate the patches from the original work must be clearly | |
59 | # labeled as unofficial distributions. Modifications which do not | |
60 | # carry the name Zope may be packaged in any form, as long as they | |
61 | # conform to all of the clauses above. | |
62 | # | |
63 | # | |
64 | # Disclaimer | |
65 | # | |
66 | # THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS ``AS IS'' AND ANY | |
67 | # EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
68 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
69 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL CREATIONS OR ITS | |
70 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
71 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
72 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |
73 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |
74 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |
75 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |
76 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
77 | # SUCH DAMAGE. | |
78 | # | |
79 | # | |
80 | # This software consists of contributions made by Digital Creations and | |
81 | # many individuals on behalf of Digital Creations. Specific | |
82 | # attributions are listed in the accompanying credits file. | |
83 | # | |
84 | ############################################################################## | |
c12bc4de | 85 | |
ddfc587a RD |
86 | """ Alias module for StructuredTextClassic compatibility which makes |
87 | use of StructuredTextNG """ | |
c12bc4de | 88 | |
c12bc4de | 89 | |
ddfc587a RD |
90 | import HTMLClass, DocumentClass, ClassicDocumentClass |
91 | from ST import Basic | |
c12bc4de | 92 | |
ddfc587a RD |
93 | import re, string,sys |
94 | from STletters import letters | |
c12bc4de | 95 | |
ddfc587a RD |
96 | Document = ClassicDocumentClass.DocumentClass() |
97 | HTMLNG = HTMLClass.HTMLClass() | |
c12bc4de | 98 | |
ddfc587a RD |
99 | def HTML(aStructuredString, level=0): |
100 | st = Basic(aStructuredString) | |
101 | doc = Document(st) | |
102 | return HTMLNG(doc) | |
c12bc4de | 103 | |
ddfc587a RD |
104 | def StructuredText(aStructuredString, level=0): |
105 | return HTML(aStructuredString,level) | |
c12bc4de | 106 | |
ddfc587a RD |
107 | def html_with_references(text, level=1): |
108 | text = re.sub( | |
109 | r'[\000\n]\.\. \[([0-9_%s-]+)\]' % letters, | |
110 | r'\n <a name="\1">[\1]</a>', | |
111 | text) | |
c12bc4de | 112 | |
ddfc587a RD |
113 | text = re.sub( |
114 | r'([\000- ,])\[(?P<ref>[0-9_%s-]+)\]([\000- ,.:])' % letters, | |
115 | r'\1<a href="#\2">[\2]</a>\3', | |
116 | text) | |
c12bc4de | 117 | |
ddfc587a RD |
118 | text = re.sub( |
119 | r'([\000- ,])\[([^]]+)\.html\]([\000- ,.:])', | |
120 | r'\1<a href="\2.html">[\2]</a>\3', | |
121 | text) | |
c12bc4de | 122 | |
ddfc587a | 123 | return HTML(text,level=level) |
c12bc4de RD |
124 | |
125 | def html_quote(v, | |
126 | character_entities=( | |
ddfc587a RD |
127 | (re.compile('&'), '&'), |
128 | (re.compile("<"), '<' ), | |
129 | (re.compile(">"), '>' ), | |
130 | (re.compile('"'), '"') | |
c12bc4de RD |
131 | )): #" |
132 | text=str(v) | |
133 | for re,name in character_entities: | |
ddfc587a | 134 | text=re.sub(name,text) |
c12bc4de RD |
135 | return text |
136 | ||
c12bc4de | 137 | |
ddfc587a RD |
138 | if __name__=='__main__': |
139 | import getopt | |
c12bc4de | 140 | |
ddfc587a | 141 | opts,args = getopt.getopt(sys.argv[1:],'',[]) |
c12bc4de | 142 | |
ddfc587a RD |
143 | for k,v in opts: |
144 | pass | |
c12bc4de | 145 | |
c12bc4de | 146 | |
ddfc587a RD |
147 | for f in args: |
148 | print HTML(open(f).read()) |