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
a06f8164
Commit
a06f8164
authored
Mar 11, 2002
by
Andreas Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
string module free zone
parent
8aa66f99
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
25 deletions
+23
-25
lib/python/StructuredText/ClassicDocumentClass.py
lib/python/StructuredText/ClassicDocumentClass.py
+9
-10
lib/python/StructuredText/ClassicStructuredText.py
lib/python/StructuredText/ClassicStructuredText.py
+14
-15
No files found.
lib/python/StructuredText/ClassicDocumentClass.py
View file @
a06f8164
...
...
@@ -12,7 +12,6 @@
##############################################################################
import
re
,
ST
,
STDOM
from
string
import
split
,
join
,
replace
,
expandtabs
,
strip
,
find
from
STletters
import
letters
StringType
=
type
(
''
)
...
...
@@ -25,7 +24,7 @@ class StructuredTextExample(ST.StructuredTextParagraph):
t
=
[];
a
=
t
.
append
for
s
in
subs
:
a
(
s
.
getNodeValue
())
apply
(
ST
.
StructuredTextParagraph
.
__init__
,
(
self
,
join
(
t
,
'
\
n
\
n
'
),
()),
(
self
,
'
\
n
\
n
'
.
join
(
t
),
()),
kw
)
def
getColorizableTexts
(
self
):
return
()
...
...
@@ -374,15 +373,15 @@ class DocumentClass:
rows = []
# initial split
for row in
split(text,
"
\
n
"):
for row in
text.split(
"
\
n
"):
rows.append(row)
# clean up the rows
for index in range(len(rows)):
tmp = []
rows[index] =
strip(rows[index]
)
rows[index] =
rows[index].strip(
)
l = len(rows[index])-2
result =
split(rows[index][:l],
"||")
result =
rows[index][:l].split(
"||")
for text in result:
if text:
tmp.append(text)
...
...
@@ -462,7 +461,7 @@ class DocumentClass:
if not d: return None
start, end = d.span()
title=top[:start]
if
find(title,
'
\
n
') >= 0: return None
if
title.find(
'
\
n
') >= 0: return None
if not nb(title): return None
d=top[start:end]
top=top[end:]
...
...
@@ -483,16 +482,16 @@ class DocumentClass:
subs
=
paragraph
.
getSubparagraphs
()
if
not
subs
:
return
None
top
=
paragraph
.
getColorizableTexts
()[
0
]
if
not
strip
(
top
):
return
None
if
not
top
.
strip
(
):
return
None
if
top
[
-
2
:]
==
'::'
:
subs
=
StructuredTextExample
(
subs
)
if
strip
(
top
)
==
'::'
:
return
subs
if
top
.
strip
(
)
==
'::'
:
return
subs
return
ST
.
StructuredTextParagraph
(
top
[:
-
1
],
[
subs
],
indent
=
paragraph
.
indent
,
level
=
paragraph
.
level
)
if
find
(
top
,
'
\
n
'
)
>=
0
:
return
None
if
top
.
find
(
'
\
n
'
)
>=
0
:
return
None
return
StructuredTextSection
(
top
,
subs
,
indent
=
paragraph
.
indent
,
level
=
paragraph
.
level
)
def
doc_literal
(
...
...
@@ -602,7 +601,7 @@ class DocumentClass:
start,e = r.span(1)
name = s[start:e]
name =
replace(name,
'"','',2)
name =
name.replace(
'"','',2)
#start = start + 1
st,end = r.span(3)
if punctuation(s[end-1:end]):
...
...
lib/python/StructuredText/ClassicStructuredText.py
View file @
a06f8164
...
...
@@ -136,7 +136,6 @@ Special symbology is used to indicate special constructs:
import
ts_regex
import
regex
from
ts_regex
import
gsub
from
string
import
split
,
join
,
strip
,
find
import
string
,
re
...
...
@@ -162,11 +161,11 @@ def untabify(aString,
def
indent
(
aString
,
indent
=
2
):
"""Indent a string the given number of spaces"""
r
=
split
(
untabify
(
aString
),
'
\
n
'
)
r
=
untabify
(
aString
).
split
(
'
\
n
'
)
if
not
r
:
return
''
if
not
r
[
-
1
]:
del
r
[
-
1
]
tab
=
' '
*
indent
return
"%s%s
\
n
"
%
(
tab
,
join
(
r
,
'
\
n
'
+
tab
))
return
"%s%s
\
n
"
%
(
tab
,
(
'
\
n
'
+
tab
).
join
(
r
))
def
reindent
(
aString
,
indent
=
2
,
already_untabified
=
0
):
"reindent a block of text, so that the minimum indent is as given"
...
...
@@ -182,12 +181,12 @@ def reindent(aString, indent=2, already_untabified=0):
if
indent
>
l
:
tab
=
' '
*
(
indent
-
l
)
for
s
in
split
(
aString
,
'
\
n
'
):
append
(
tab
+
s
)
for
s
in
aString
.
split
(
'
\
n
'
):
append
(
tab
+
s
)
else
:
l
=
l
-
indent
for
s
in
split
(
aString
,
'
\
n
'
):
append
(
s
[
l
:])
for
s
in
aString
.
split
(
'
\
n
'
):
append
(
s
[
l
:])
return
join
(
r
,
'
\
n
'
)
return
'
\
n
'
.
join
(
r
)
def
indent_level
(
aString
,
indent_space
=
ts_regex
.
compile
(
'
\
n
\
( *
\
)'
).
search_group
,
...
...
@@ -242,7 +241,7 @@ class Table:
'''parses a table and returns nested list representing the
table'''
self
.
table
=
[]
text
=
filter
(
None
,
split
(
aPar
,
'
\
n
'
))
text
=
filter
(
None
,
aPar
.
split
(
'
\
n
'
))
for
line
in
text
:
row
=
[]
while
1
:
...
...
@@ -268,8 +267,8 @@ class Table:
else
:
htmlrow
.
append
(
self
.
CELL
%
(
colspan
,
cell
))
colspan
=
1
htmltable
.
append
(
self
.
ROW
%
join
(
htmlrow
,
''
))
return
self
.
TABLE
%
join
(
htmltable
,
''
)
htmltable
.
append
(
self
.
ROW
%
''
.
join
(
htmlrow
))
return
self
.
TABLE
%
''
.
join
(
htmltable
)
table
=
Table
()
...
...
@@ -312,7 +311,7 @@ class StructuredText:
aStructuredString
=
p_reg
.
sub
(
r'<a href="\2">\1</a>\3 '
,
aStructuredString
)
protoless
=
find
(
aStructuredString
,
'<a href=":'
)
protoless
=
aStructuredString
.
find
(
'<a href=":'
)
if
protoless
!=
-
1
:
aStructuredString
=
re
.
sub
(
'<a href=":'
,
'<a href="'
,
aStructuredString
)
...
...
@@ -373,12 +372,12 @@ class HTML(StructuredText):
return
s
def
ul
(
self
,
before
,
p
,
after
):
if
p
:
p
=
"<p>%s</p>"
%
strip
(
ctag
(
p
)
)
if
p
:
p
=
"<p>%s</p>"
%
ctag
(
p
).
strip
(
)
return
(
'%s<ul><li>%s
\
n
%s
\
n
</li></ul>
\
n
'
%
(
before
,
p
,
after
))
def
ol
(
self
,
before
,
p
,
after
):
if
p
:
p
=
"<p>%s</p>"
%
strip
(
ctag
(
p
)
)
if
p
:
p
=
"<p>%s</p>"
%
ctag
(
p
).
strip
(
)
return
(
'%s<ol><li>%s
\
n
%s
\
n
</li></ol>
\
n
'
%
(
before
,
p
,
after
))
...
...
@@ -389,9 +388,9 @@ class HTML(StructuredText):
def
head
(
self
,
before
,
t
,
level
,
d
):
if
level
>
0
and
level
<
6
:
return
(
'%s<h%d>%s</h%d>
\
n
%s
\
n
'
%
(
before
,
level
,
strip
(
ctag
(
t
)
),
level
,
d
))
%
(
before
,
level
,
ctag
(
t
).
strip
(
),
level
,
d
))
t
=
"<p><strong>%s</strong></p>"
%
strip
(
ctag
(
t
)
)
t
=
"<p><strong>%s</strong></p>"
%
ctag
(
t
).
strip
(
)
return
(
'%s<dl><dt>%s
\
n
</dt><dd>%s
\
n
</dd></dl>
\
n
'
%
(
before
,
t
,
d
))
...
...
@@ -540,7 +539,7 @@ def main():
s
=
str
(
html_with_references
(
s
))
if
s
[:
4
]
==
'<h1>'
:
t
=
s
[
4
:
find
(
s
,
'</h1>'
)]
t
=
s
[
4
:
s
.
find
(
'</h1>'
)]
s
=
'''<html><head><title>%s</title>
</head><body>
%s
...
...
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