Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
3c0bfd0d
Commit
3c0bfd0d
authored
Sep 22, 1995
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix <!...!> parsing; added verbose option; don't lowercase entityrefs
parent
8421c4e8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
Lib/sgmllib.py
Lib/sgmllib.py
+7
-5
No files found.
Lib/sgmllib.py
View file @
3c0bfd0d
...
@@ -40,7 +40,8 @@ commentclose = regex.compile('--[ \t\n]*>')
...
@@ -40,7 +40,8 @@ commentclose = regex.compile('--[ \t\n]*>')
class
SGMLParser
:
class
SGMLParser
:
# Interface -- initialize and reset this instance
# Interface -- initialize and reset this instance
def
__init__
(
self
):
def
__init__
(
self
,
verbose
=
0
):
self
.
verbose
=
verbose
self
.
reset
()
self
.
reset
()
# Interface -- reset this instance. Loses all unprocessed data
# Interface -- reset this instance. Loses all unprocessed data
...
@@ -141,7 +142,8 @@ class SGMLParser:
...
@@ -141,7 +142,8 @@ class SGMLParser:
k
=
incomplete
.
match
(
rawdata
,
i
)
k
=
incomplete
.
match
(
rawdata
,
i
)
if
k
<
0
:
raise
RuntimeError
,
'no incomplete match ??'
if
k
<
0
:
raise
RuntimeError
,
'no incomplete match ??'
j
=
i
+
k
j
=
i
+
k
if
j
==
n
:
break
# Really incomplete
if
j
==
n
or
rawdata
[
i
:
i
+
2
]
==
'<!'
:
break
# Really incomplete
self
.
handle_data
(
rawdata
[
i
:
j
])
self
.
handle_data
(
rawdata
[
i
:
j
])
i
=
j
i
=
j
# end while
# end while
...
@@ -234,6 +236,7 @@ class SGMLParser:
...
@@ -234,6 +236,7 @@ class SGMLParser:
# Example -- report an unbalanced </...> tag.
# Example -- report an unbalanced </...> tag.
def
report_unbalanced
(
self
,
tag
):
def
report_unbalanced
(
self
,
tag
):
if
self
.
verbose
:
print
'*** Unbalanced </'
+
tag
+
'>'
print
'*** Unbalanced </'
+
tag
+
'>'
print
'*** Stack:'
,
self
.
stack
print
'*** Stack:'
,
self
.
stack
...
@@ -256,7 +259,6 @@ class SGMLParser:
...
@@ -256,7 +259,6 @@ class SGMLParser:
# Example -- handle entity reference, no need to override
# Example -- handle entity reference, no need to override
def
handle_entityref
(
self
,
name
):
def
handle_entityref
(
self
,
name
):
table
=
self
.
entitydefs
table
=
self
.
entitydefs
name
=
string
.
lower
(
name
)
if
table
.
has_key
(
name
):
if
table
.
has_key
(
name
):
self
.
handle_data
(
table
[
name
])
self
.
handle_data
(
table
[
name
])
else
:
else
:
...
...
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