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
0fd525fd
Commit
0fd525fd
authored
May 10, 2003
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add table level validation and made minor fix-ups.
parent
0dfd7a93
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
8 deletions
+22
-8
Tools/scripts/texcheck.py
Tools/scripts/texcheck.py
+22
-8
No files found.
Tools/scripts/texcheck.py
View file @
0fd525fd
...
...
@@ -22,10 +22,6 @@ Options:
-v: Verbose. Shows current delimiter and unclosed delimiters.
"""
# Todo:
# Add tableiii/lineiii cross-checking
# Add braces matching
import
re
import
sets
import
sys
...
...
@@ -53,7 +49,8 @@ cmdstr = r"""
\textbackslash \
mime
type \
m
ailheader \
seepep
\textunderscore
\
lo
ngprogramopt \
i
nfinity \
plusmi
nus \
sho
rtversion \version
\refmodindex \
see
rfc \
m
akeindex \
m
akemodindex \renewcommand
\
i
ndexname \appendix
\
i
ndexname \appendix \
p
rotect \
i
ndexiv \
m
box \textasciitilde
\
pl
atform \
seeu
rl \
le
ftmargin \
l
abelwidth \
loc
almoduletable
"""
def
matchclose
(
c_lineno
,
c_symbol
,
openers
,
pairmap
):
...
...
@@ -68,7 +65,7 @@ def matchclose(c_lineno, c_symbol, openers, pairmap):
raise
Exception
,
msg
def
checkit
(
source
,
opts
,
morecmds
=
[]):
"""Check the LaTe
x
formatting in a sequence of lines.
"""Check the LaTe
X
formatting in a sequence of lines.
Opts is a mapping of options to option values if any:
-m munge parenthesis and brackets
...
...
@@ -77,7 +74,7 @@ def checkit(source, opts, morecmds=[]):
-v verbose listing on delimiters
-s lineno: linenumber to start scan (default is 1).
Morecmds is a sequence of LaTe
x
commands (without backslashes) that
Morecmds is a sequence of LaTe
X
commands (without backslashes) that
are to be considered valid in the scan.
"""
...
...
@@ -97,6 +94,12 @@ def checkit(source, opts, morecmds=[]):
delimiters
=
re
.
compile
(
r'\\(begin|end){([_a-zA-Z]+)}|([()\
[
\]])'
)
tablestart
=
re
.
compile
(
r'\\begin{(?:long)?table([iv]+)}'
)
tableline
=
re
.
compile
(
r'\\line([iv]+){'
)
tableend
=
re
.
compile
(
r'\\end{(?:long)?table([iv]+)}'
)
tablelevel
=
''
tablestartline
=
0
startline
=
int
(
opts
.
get
(
'-s'
,
'1'
))
lineno
=
0
...
...
@@ -134,8 +137,19 @@ def checkit(source, opts, morecmds=[]):
if '
-
v
' in opts:
print '
-->
', openers
# Check table levels (make sure lineii only inside lineiii)
m = tablestart.search(line)
if m:
tablelevel = m.group(1)
tablestartline = lineno
m = tableline.search(line)
if m and m.group(1) != tablelevel:
print r'
Warning
,
\
line
%
s
on
line
%
d
does
not
match
\
table
%
s
on
line
%
d
' % (m.group(1), lineno, tablelevel, tablestartline)
if tableend.search(line):
tablelevel = ''
for lineno, symbol in openers:
print "Unmatched open delimiter '
%
s
' on line %d"
,
(symbol, lineno)
print "Unmatched open delimiter '
%
s
' on line %d"
%
(symbol, lineno)
print '
Done
checking
%
d
lines
.
' % (lineno,)
return 0
...
...
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