Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
5faf384b
Commit
5faf384b
authored
Feb 17, 1997
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for "foo title", http:/foohost/foo
parent
09f0b213
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
11 deletions
+36
-11
lib/python/StructuredText/StructuredText.py
lib/python/StructuredText/StructuredText.py
+36
-11
No files found.
lib/python/StructuredText/StructuredText.py
View file @
5faf384b
...
@@ -44,9 +44,9 @@ Special symbology is used to indicate special constructs:
...
@@ -44,9 +44,9 @@ Special symbology is used to indicate special constructs:
- Text surrounded by '**' characters (with white-space to the left of the
- Text surrounded by '**' characters (with white-space to the left of the
first '**' and whitespace or puctuation to the right of the second '**')
first '**' and whitespace or puctuation to the right of the second '**')
is
emphasized
.
is
made strong
.
$Id: StructuredText.py,v 1.
3 1996/12/06 15:57:37
jim Exp $'''
$Id: StructuredText.py,v 1.
4 1997/02/17 23:36:35
jim Exp $'''
# Copyright
# Copyright
#
#
# Copyright 1996 Digital Creations, L.C., 910 Princess Anne
# Copyright 1996 Digital Creations, L.C., 910 Princess Anne
...
@@ -98,6 +98,9 @@ $Id: StructuredText.py,v 1.3 1996/12/06 15:57:37 jim Exp $'''
...
@@ -98,6 +98,9 @@ $Id: StructuredText.py,v 1.3 1996/12/06 15:57:37 jim Exp $'''
# (540) 371-6909
# (540) 371-6909
#
#
# $Log: StructuredText.py,v $
# $Log: StructuredText.py,v $
# Revision 1.4 1997/02/17 23:36:35 jim
# Added support for "foo title", http:/foohost/foo
#
# Revision 1.3 1996/12/06 15:57:37 jim
# Revision 1.3 1996/12/06 15:57:37 jim
# Fixed bugs in character tags.
# Fixed bugs in character tags.
#
#
...
@@ -222,8 +225,9 @@ class StructuredText:
...
@@ -222,8 +225,9 @@ class StructuredText:
ctag_prefix="
\
([
\
0- (]
\
|^
\
)"
ctag_prefix="
\
([
\
0- (]
\
|^
\
)"
ctag_suffix="
\
([
\
0- ,.:;!?)]
\
|$
\
)"
ctag_suffix="
\
([
\
0- ,.:;!?)]
\
|$
\
)"
ctag_middle="[%s]
\
([^
\
0- %s][^%s]*[^
\
0
- %s]
\
|[^%s]
\
)[%s]"
ctag_middle="[%s]
\
([^
\
0- %s][^%s]*[^
\
0
- %s]
\
|[^%s]
\
)[%s]"
ctag_middl2="[%s][%s]
\
([^
\
0- %s][^%s]*[^
\
0
- %s]
\
|[^%s]
\
)[%s][%s]"
em =regex.compile(ctag_prefix+(ctag_middle % (("*",)*6) )+ctag_suffix)
em =regex.compile(ctag_prefix+(ctag_middle % (("*",)*6) )+ctag_suffix)
strong=regex.compile(ctag_prefix+(ctag_middl
e % (("**",)*6
))+ctag_suffix)
strong=regex.compile(ctag_prefix+(ctag_middl
2 % (("*",)*8
))+ctag_suffix)
code =regex.compile(ctag_prefix+(ctag_middle % (("
\
'
",)*6))+ctag_suffix)
code =regex.compile(ctag_prefix+(ctag_middle % (("
\
'
",)*6))+ctag_suffix)
def ctag(s):
def ctag(s):
...
@@ -336,29 +340,50 @@ def html_quote(v,
...
@@ -336,29 +340,50 @@ def html_quote(v,
def
html_with_references
(
text
):
def
html_with_references
(
text
):
text
=
gsub
(
text
=
gsub
(
'[
\
0
\
n
]..
\
[
\
([-_0-9_a-zA-Z]+
\
)
\
]'
,
'[
\
0
\
n
]..
\
[
\
([-_0-9_a-zA-Z
-
]+
\
)
\
]'
,
'
\
n
<a name="
\
\
1">[
\
\
1]</a>'
,
'
\
n
<a name="
\
\
1">[
\
\
1]</a>'
,
text
)
text
)
text
=
gsub
(
text
=
gsub
(
'
\
([
\
0- ,]
\
)
\
[
\
([
0
-9_a-zA-Z]+
\
)
\
]
\
([
\
0- ,.:]
\
)
'
,
'
\
([
\
0- ,]
\
)
\
[
\
([
0
-9_a-zA-Z
-
]+
\
)
\
]
\
([
\
0- ,.:]
\
)
'
,
'
\\
1
<
a
href
=
"#
\
\
2"
>
[
\\
2
]
</
a
>
\\
3
',
'
\\
1
<
a
href
=
"#
\
\
2"
>
[
\\
2
]
</
a
>
\\
3
',
text)
text)
text = gsub(
text = gsub(
'
\
([
\
0
-
]
\
)
\
([
a
-
z
]
+
:
//
[
^
\
0
-
]
+
\
)
',
'
\
([
\
0
-
,]
\
)
\
[
\
([
^
]]
+
\
)
\
.
html
\
]
\
([
\
0
-
,.:]
\
)
',
'
\\
1
<
a
href
=
"
\
\
2"
>
\\
2
</
a
>
',
'
\\
1
<
a
href
=
"
\
\
2.html"
>
[
\\
2
]
</
a
>
\\
3
',
text)
text = gsub(
'
\
(
\
"[^
\
"
\
0
]+
\
"
\
),[
\
0- ]+' # title part
'
\
([
a
-zA-Z]+:[-:a-zA-Z0-9_,./?=]+
\
)
'
# URL
'
\
(,
\
|
\
([.:?;]
\
)
\
)
'
# trailing puctuation
'
\
([
\
0- ]
\
)
'
, # trailing space
'<a href="
\\
2
">
\
\
1</a>
\
\
4
\
\
5',
text)
text)
return HTML(text,level=1)
return HTML(text,level=1)
def main():
def main():
import sys
import sys
, getopt
if '
-
t
' in sys.argv:
opts,args=getopt.getopt(sys.argv[1:],'tw')
import regex, string
if args:
[infile]=args
s=open(infile,'r').read()
else:
s=sys.stdin.read()
s=sys.stdin.read()
if opts:
import regex, string, regsub
if filter(lambda o: o[0]=='-w', opts):
print 'Content-Type: text/html
\
n
'
if s[:2]=='#!': s=regsub.sub('^#![^
\
n
]+','',s)
r=regex.compile('
\
([
\
0-
\
n
]*
\
n
\
)
'
)
r=regex.compile('
\
([
\
0-
\
n
]*
\
n
\
)
'
)
if r.match(s) >= 0:
if r.match(s) >= 0:
s=s[len(r.group(1)):]
s=s[len(r.group(1)):]
...
@@ -372,7 +397,7 @@ def main():
...
@@ -372,7 +397,7 @@ def main():
''' % (t,s)
''' % (t,s)
print s
print s
else:
else:
print html_with_references(s
ys.stdin.read()
)
print html_with_references(s)
if __name__=="
__main__
": main()
if __name__=="
__main__
": main()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment