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
1dba24ee
Commit
1dba24ee
authored
Mar 04, 1995
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove redundant backslashes; some cosnetics
parent
7b5430f2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
69 deletions
+69
-69
Lib/htmllib.py
Lib/htmllib.py
+59
-60
Lib/sgmllib.py
Lib/sgmllib.py
+10
-9
No files found.
Lib/htmllib.py
View file @
1dba24ee
...
...
@@ -62,7 +62,7 @@ class CollectingParser(HTMLParser):
def
__init__
(
self
):
HTMLParser
.
__init__
(
self
)
self
.
savetext
=
None
self
.
nextid
=
''
self
.
nextid
=
[]
self
.
isindex
=
0
self
.
title
=
''
self
.
inanchor
=
0
...
...
@@ -470,54 +470,54 @@ class NullStylesheet:
class
X11Stylesheet
(
NullStylesheet
):
stdfontset
=
[
\
'-*-helvetica-medium-r-normal-*-*-100-100-*-*-*-*-*'
,
\
'-*-helvetica-medium-o-normal-*-*-100-100-*-*-*-*-*'
,
\
'-*-helvetica-bold-r-normal-*-*-100-100-*-*-*-*-*'
,
\
'-*-courier-medium-r-normal-*-*-100-100-*-*-*-*-*'
,
\
stdfontset
=
[
'-*-helvetica-medium-r-normal-*-*-100-100-*-*-*-*-*'
,
'-*-helvetica-medium-o-normal-*-*-100-100-*-*-*-*-*'
,
'-*-helvetica-bold-r-normal-*-*-100-100-*-*-*-*-*'
,
'-*-courier-medium-r-normal-*-*-100-100-*-*-*-*-*'
,
]
h1fontset
=
[
\
'-*-helvetica-medium-r-normal-*-*-180-100-*-*-*-*-*'
,
\
'-*-helvetica-medium-o-normal-*-*-180-100-*-*-*-*-*'
,
\
'-*-helvetica-bold-r-normal-*-*-180-100-*-*-*-*-*'
,
\
h1fontset
=
[
'-*-helvetica-medium-r-normal-*-*-180-100-*-*-*-*-*'
,
'-*-helvetica-medium-o-normal-*-*-180-100-*-*-*-*-*'
,
'-*-helvetica-bold-r-normal-*-*-180-100-*-*-*-*-*'
,
]
h2fontset
=
[
\
'-*-helvetica-medium-r-normal-*-*-140-100-*-*-*-*-*'
,
\
'-*-helvetica-medium-o-normal-*-*-140-100-*-*-*-*-*'
,
\
'-*-helvetica-bold-r-normal-*-*-140-100-*-*-*-*-*'
,
\
h2fontset
=
[
'-*-helvetica-medium-r-normal-*-*-140-100-*-*-*-*-*'
,
'-*-helvetica-medium-o-normal-*-*-140-100-*-*-*-*-*'
,
'-*-helvetica-bold-r-normal-*-*-140-100-*-*-*-*-*'
,
]
h3fontset
=
[
\
'-*-helvetica-medium-r-normal-*-*-120-100-*-*-*-*-*'
,
\
'-*-helvetica-medium-o-normal-*-*-120-100-*-*-*-*-*'
,
\
'-*-helvetica-bold-r-normal-*-*-120-100-*-*-*-*-*'
,
\
h3fontset
=
[
'-*-helvetica-medium-r-normal-*-*-120-100-*-*-*-*-*'
,
'-*-helvetica-medium-o-normal-*-*-120-100-*-*-*-*-*'
,
'-*-helvetica-bold-r-normal-*-*-120-100-*-*-*-*-*'
,
]
ddindent
=
40
class
MacStylesheet
(
NullStylesheet
):
stdfontset
=
[
\
(
'Geneva'
,
'p'
,
10
),
\
(
'Geneva'
,
'i'
,
10
),
\
(
'Geneva'
,
'b'
,
10
),
\
(
'Monaco'
,
'p'
,
10
),
\
stdfontset
=
[
(
'Geneva'
,
'p'
,
10
),
(
'Geneva'
,
'i'
,
10
),
(
'Geneva'
,
'b'
,
10
),
(
'Monaco'
,
'p'
,
10
),
]
h1fontset
=
[
\
(
'Geneva'
,
'p'
,
18
),
\
(
'Geneva'
,
'i'
,
18
),
\
(
'Geneva'
,
'b'
,
18
),
\
(
'Monaco'
,
'p'
,
18
),
\
h1fontset
=
[
(
'Geneva'
,
'p'
,
18
),
(
'Geneva'
,
'i'
,
18
),
(
'Geneva'
,
'b'
,
18
),
(
'Monaco'
,
'p'
,
18
),
]
h3fontset
=
[
\
(
'Geneva'
,
'p'
,
14
),
\
(
'Geneva'
,
'i'
,
14
),
\
(
'Geneva'
,
'b'
,
14
),
\
(
'Monaco'
,
'p'
,
14
),
\
h3fontset
=
[
(
'Geneva'
,
'p'
,
14
),
(
'Geneva'
,
'i'
,
14
),
(
'Geneva'
,
'b'
,
14
),
(
'Monaco'
,
'p'
,
14
),
]
h3fontset
=
[
\
(
'Geneva'
,
'p'
,
12
),
\
(
'Geneva'
,
'i'
,
12
),
\
(
'Geneva'
,
'b'
,
12
),
\
(
'Monaco'
,
'p'
,
12
),
\
h3fontset
=
[
(
'Geneva'
,
'p'
,
12
),
(
'Geneva'
,
'i'
,
12
),
(
'Geneva'
,
'b'
,
12
),
(
'Monaco'
,
'p'
,
12
),
]
...
...
@@ -528,29 +528,29 @@ else:
class
GLStylesheet
(
NullStylesheet
):
stdfontset
=
[
\
'Helvetica 10'
,
\
'Helvetica-Italic 10'
,
\
'Helvetica-Bold 10'
,
\
'Courier 10'
,
\
stdfontset
=
[
'Helvetica 10'
,
'Helvetica-Italic 10'
,
'Helvetica-Bold 10'
,
'Courier 10'
,
]
h1fontset
=
[
\
'Helvetica 18'
,
\
'Helvetica-Italic 18'
,
\
'Helvetica-Bold 18'
,
\
'Courier 18'
,
\
h1fontset
=
[
'Helvetica 18'
,
'Helvetica-Italic 18'
,
'Helvetica-Bold 18'
,
'Courier 18'
,
]
h2fontset
=
[
\
'Helvetica 14'
,
\
'Helvetica-Italic 14'
,
\
'Helvetica-Bold 14'
,
\
'Courier 14'
,
\
h2fontset
=
[
'Helvetica 14'
,
'Helvetica-Italic 14'
,
'Helvetica-Bold 14'
,
'Courier 14'
,
]
h3fontset
=
[
\
'Helvetica 12'
,
\
'Helvetica-Italic 12'
,
\
'Helvetica-Bold 12'
,
\
'Courier 12'
,
\
h3fontset
=
[
'Helvetica 12'
,
'Helvetica-Italic 12'
,
'Helvetica-Bold 12'
,
'Courier 12'
,
]
...
...
@@ -595,8 +595,7 @@ def testStdwin():
if
not
b
:
b
=
fmt
.
StdwinBackEnd
(
window
,
1
)
f
=
fmt
.
BaseFormatter
(
b
.
d
,
b
)
p
=
FormattingParser
(
f
,
\
MacStylesheet
)
p
=
FormattingParser
(
f
,
MacStylesheet
)
p
.
feed
(
data
)
p
.
close
()
b
.
finish
()
...
...
Lib/sgmllib.py
View file @
1dba24ee
...
...
@@ -14,8 +14,8 @@ import string
# Regular expressions used for parsing
incomplete
=
regex
.
compile
(
\
'<!-?
\
|</[
a
-zA-Z][a-zA-Z0-9]*[
\
t
\
n
]*
\
|</?
\
|'
+
\
incomplete
=
regex
.
compile
(
'<!-?
\
|</[
a
-zA-Z][a-zA-Z0-9]*[
\
t
\
n
]*
\
|</?
\
|'
+
'&#[a-zA-Z0-9]*
\
|&[
a
-zA-Z][a-zA-Z0-9]*
\
|&
'
)
entityref = regex.compile('
&
[
a
-
zA
-
Z
][
a
-
zA
-
Z0
-
9
]
*
[;.]
')
charref = regex.compile('
&
#[a-zA-Z0-9]+;')
...
...
@@ -59,7 +59,7 @@ class SGMLParser:
# Interface -- feed some data to the parser. Call this as
# often as you want, with as little or as much text as you
# want (may include '\n'). (This just saves the text, all the
# processing is done by
process() or close
().)
# processing is done by
goahead
().)
def
feed
(
self
,
data
):
self
.
rawdata
=
self
.
rawdata
+
data
self
.
goahead
(
0
)
...
...
@@ -172,9 +172,9 @@ class SGMLParser:
# Now parse the data between i+1 and j into a tag and attrs
attrs
=
[]
tagfind
=
regex
.
compile
(
'[a-zA-Z][a-zA-Z0-9]*'
)
attrfind
=
regex
.
compile
(
\
'[
\
t
\
n
]+
\
([
a
-zA-Z][a-zA-Z0-9]*
\
)
'
+
\
'
\
([
\
t
\
n
]
*=
[
\
t
\
n
]
*
' +
\
attrfind
=
regex
.
compile
(
'[
\
t
\
n
]+
\
([
a
-zA-Z][a-zA-Z0-9]*
\
)
'
+
'
\
([
\
t
\
n
]
*=
[
\
t
\
n
]
*
' +
'
\
(
\
'[^
\
'
]*
\
'
;
\
|
"
[^"]*"
\
|[-
a
-zA-Z0-9./:+*%?!()_#]+
\
)
\
)?'
)
k
=
tagfind
.
match
(
rawdata
,
i
+
1
)
if
k
<
0
:
...
...
@@ -196,7 +196,7 @@ class SGMLParser:
attrvalue
=
attrvalue
[
1
:
-
1
]
else
:
attrvalue
=
''
attrs
.
append
(
string
.
lower
(
attrname
),
attrvalue
)
attrs
.
append
(
(
string
.
lower
(
attrname
),
attrvalue
)
)
k
=
k
+
l
j
=
j
+
1
try
:
...
...
@@ -253,7 +253,7 @@ class SGMLParser:
# Example -- handle entity reference, no need to override
def
handle_entityref
(
self
,
name
):
table
=
self
.
__class__
.
entitydefs
table
=
self
.
entitydefs
name
=
string
.
lower
(
name
)
if
table
.
has_key
(
name
):
self
.
handle_data
(
table
[
name
])
...
...
@@ -318,4 +318,5 @@ def test():
x
.
feed
(
line
)
#test()
if
__name__
==
'__main__'
:
test
()
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