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
328b6d00
Commit
328b6d00
authored
May 10, 2000
by
john
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updating StructuredTextNG ST.py
parent
ac442f42
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
9 deletions
+19
-9
lib/python/StructuredText/ST.py
lib/python/StructuredText/ST.py
+19
-9
No files found.
lib/python/StructuredText/ST.py
View file @
328b6d00
...
@@ -85,7 +85,7 @@
...
@@ -85,7 +85,7 @@
##############################################################################
##############################################################################
import
re
import
re
from
string
import
split
,
join
,
replace
,
expandtabs
from
string
import
split
,
join
,
replace
,
expandtabs
,
strip
def
indention
(
str
):
def
indention
(
str
):
...
@@ -97,7 +97,7 @@ def indention(str):
...
@@ -97,7 +97,7 @@ def indention(str):
if
str
==
'
\
n
'
:
if
str
==
'
\
n
'
:
return
-
1
return
-
1
str
=
expandtabs
(
str
)
# covert tabs into spaces
#
str = expandtabs(str) # covert tabs into spaces
front
=
re
.
compile
(
'( *)'
)
front
=
re
.
compile
(
'( *)'
)
m
=
front
.
match
(
str
)
m
=
front
.
match
(
str
)
...
@@ -160,11 +160,17 @@ def split_paragraphs(paragraphs):
...
@@ -160,11 +160,17 @@ def split_paragraphs(paragraphs):
tmp
=
''
tmp
=
''
par
=
re
.
compile
(
'
\
n
[ ]*
\
n
'
)
par
=
re
.
compile
(
'
\
n
[ ]*
\
n
'
)
if
type
(
paragraphs
).
__name__
==
"list"
:
for
paragraph
in
paragraphs
:
tmp
=
tmp
+
expandtabs
(
paragraph
)
for
paragraph
in
paragraphs
:
paragraphs
=
par
.
split
(
tmp
)
tmp
=
tmp
+
paragraph
elif
type
(
paragraphs
).
__name__
==
"string"
:
paragraphs
=
par
.
split
(
expandtabs
(
paragraphs
))
paragraphs
=
par
.
split
(
tmp
)
else
:
print
"paragraphs in unacceptable format, must be string or list"
return
[]
for
i
in
range
(
len
(
paragraphs
)):
for
i
in
range
(
len
(
paragraphs
)):
paragraphs
[
i
]
=
paragraphs
[
i
]
+
'
\
n
\
n
'
paragraphs
[
i
]
=
paragraphs
[
i
]
+
'
\
n
\
n
'
...
@@ -187,14 +193,18 @@ def StructuredText(paragraphs):
...
@@ -187,14 +193,18 @@ def StructuredText(paragraphs):
top
=
-
1
# which header are we under
top
=
-
1
# which header are we under
numbers
=
{
0
:
0
}
# how many sub-paragraphs already at a level
numbers
=
{
0
:
0
}
# how many sub-paragraphs already at a level
struct
=
[]
# the structure to be returned
struct
=
[]
# the structure to be returned
paragraphs
=
split_paragraphs
(
paragraphs
)
paragraphs
=
split_paragraphs
(
paragraphs
)
if
not
paragraphs
:
result
=
[
""
,[]]
return
result
for
paragraph
in
paragraphs
:
for
paragraph
in
paragraphs
:
if
paragraph
==
'
\
n
'
:
if
paragraph
==
'
\
n
'
:
ind
.
append
([
-
1
,
paragraph
])
ind
.
append
([
-
1
,
paragraph
])
else
:
else
:
ind
.
append
([
indention
(
paragraph
),
paragraph
])
ind
.
append
([
indention
(
paragraph
),
strip
(
paragraph
)
+
"
\
n
"
])
for
indent
,
paragraph
in
ind
:
for
indent
,
paragraph
in
ind
:
...
...
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