Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 43c9350

Browse files
committed
Getting uglier. But it doesn't completely bomb except for some table stuff.
I'll get to it when I can.
1 parent 78f8e98 commit 43c9350

2 files changed

Lines changed: 146 additions & 80 deletions

File tree

Doc/partparse.py

Lines changed: 73 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ def write(self, data):
827827
self.data = self.data + data
828828

829829
# ignore these commands
830-
ignoredcommands = ('bcode', 'ecode', 'hline', 'fulllineitems', 'small', '/')
830+
ignoredcommands = ('bcode', 'ecode', 'hline', 'small', '/')
831831
# map commands like these to themselves as plaintext
832832
wordsselves = ('UNIX', 'ABC', 'C', 'ASCII', 'EOF', 'LaTeX')
833833
# \{ --> {, \} --> }, etc
@@ -1191,18 +1191,19 @@ def do_opcodedesc(length, buf, pp, i):
11911191
del pp[i:newi]
11921192
length = length - (newi-i)
11931193

1194-
ch.chtype = chunk_type[CSLINE]
1195-
ch.data = "defcv"
1194+
ch.chtype = CSLINE
1195+
ch.data = "deffn"
11961196

1197-
cslinearg = [chunk(GROUP, wh, [chunk(PLAIN, wh, "data")]),
1198-
chunk(PLAIN, wh, ' '),
1197+
cslinearg = [#chunk(GROUP, wh, [chunk(PLAIN, wh, "exception")]),
1198+
chunk(PLAIN, wh, 'exception '),
11991199
chunk(GROUP, wh, [chunk(PLAIN, wh, "byte code instruction")]),
12001200
chunk(PLAIN, wh, ' '),
12011201
dataname,
1202+
chunk(PLAIN, wh, ' '),
1203+
pp[i],
12021204
]
12031205

1204-
pp.insert(i, chunk(GROUP, wh, cslinearg))
1205-
i, length = i+1, length+1
1206+
pp[i] = chunk(GROUP, wh, cslinearg)
12061207
hist.command = ch.data
12071208
return length, i
12081209

@@ -1224,14 +1225,18 @@ def rm_commas_etc(text):
12241225
result = result + text
12251226
break
12261227
if changed:
1227-
print 'Warning: nodename changhed to ' + `result`
1228+
print 'Warning: nodename changed to ' + `result`
12281229

12291230
return result
12301231

12311232
# boolean flags
12321233
flags = {'texi': 1}
12331234

12341235

1236+
# map of \label{} to node names
1237+
label_nodes = {}
1238+
1239+
12351240
##
12361241
## changeit: the actual routine, that changes the contents of the parsed
12371242
## chunks
@@ -1260,12 +1265,22 @@ def changeit(buf, pp):
12601265
# check for {\em ...} constructs
12611266
if ch.data and \
12621267
ch.data[0].chtype == chunk_type[CSNAME] and \
1263-
s(buf, ch.data[0].data) in fontchanges.keys():
1268+
fontchanges.has_key(s(buf, ch.data[0].data)):
12641269
k = s(buf, ch.data[0].data)
12651270
del ch.data[0]
12661271
pp.insert(i-1, chunk(CSNAME, ch.where, fontchanges[k]))
12671272
length, i = length+1, i+1
12681273

1274+
elif ch.data:
1275+
k = s(buf, ch.data[0].data)
1276+
if k == "fulllineitems":
1277+
del ch.data[0]
1278+
data = ch.data
1279+
pp[i-1:i] = data
1280+
i = i - 1
1281+
length = length + len(data) - 1
1282+
continue
1283+
12691284
# recursively parse the contents of the group
12701285
changeit(buf, ch.data)
12711286

@@ -1424,6 +1439,9 @@ def changeit(buf, pp):
14241439
length = length + len(chunks) - 1
14251440
i = i + len(chunks) - 1
14261441

1442+
elif envname in ('sloppypar', 'flushleft'):
1443+
pass
1444+
14271445
else:
14281446
print 'WARNING: don\'t know what to do with env ' + `envname`
14291447

@@ -1436,48 +1454,48 @@ def changeit(buf, pp):
14361454
i, length = i-1, length-1
14371455

14381456
if envname == 'verbatim':
1439-
pp[i:i] = [
1440-
chunk(CSLINE, ch.where, 'end'),
1441-
chunk(GROUP, ch.where, [
1442-
chunk(PLAIN, ch.where, 'example')])]
1457+
pp[i:i] = [chunk(CSLINE, ch.where, 'end'),
1458+
chunk(GROUP, ch.where, [
1459+
chunk(PLAIN, ch.where, 'example')])]
14431460
i, length = i+2, length+2
14441461
elif envname == 'itemize':
14451462
hist.itemizenesting = hist.itemizenesting - 1
1446-
pp[i:i] = [
1447-
chunk(CSLINE, ch.where, 'end'),
1448-
chunk(GROUP, ch.where, [
1449-
chunk(PLAIN, ch.where, 'itemize')])]
1463+
pp[i:i] = [chunk(CSLINE, ch.where, 'end'),
1464+
chunk(GROUP, ch.where, [
1465+
chunk(PLAIN, ch.where, 'itemize')])]
14501466
i, length = i+2, length+2
14511467
elif envname == 'enumerate':
14521468
hist.enumeratenesting = hist.enumeratenesting-1
1453-
pp[i:i] = [
1454-
chunk(CSLINE, ch.where, 'end'),
1455-
chunk(GROUP, ch.where, [
1456-
chunk(PLAIN, ch.where, 'enumerate')])]
1469+
pp[i:i] = [chunk(CSLINE, ch.where, 'end'),
1470+
chunk(GROUP, ch.where, [
1471+
chunk(PLAIN, ch.where, 'enumerate')])]
14571472
i, length = i+2, length+2
14581473
elif envname == 'description':
1459-
pp[i:i] = [
1460-
chunk(CSLINE, ch.where, 'end'),
1461-
chunk(GROUP, ch.where, [
1462-
chunk(PLAIN, ch.where, 'table')])]
1474+
pp[i:i] = [chunk(CSLINE, ch.where, 'end'),
1475+
chunk(GROUP, ch.where, [
1476+
chunk(PLAIN, ch.where, 'table')])]
14631477
i, length = i+2, length+2
14641478
elif (envname == 'tableiii') or (envname == 'tableii'):
1465-
pp[i:i] = [
1466-
chunk(CSLINE, ch.where, 'end'),
1467-
chunk(GROUP, ch.where, [
1468-
chunk(PLAIN, ch.where, 'table')])]
1479+
pp[i:i] = [chunk(CSLINE, ch.where, 'end'),
1480+
chunk(GROUP, ch.where, [
1481+
chunk(PLAIN, ch.where, 'table')])]
14691482
i, length = i+2, length + 2
14701483
pp.insert(i, chunk(DENDLINE, ch.where, '\n'))
14711484
i, length = i+1, length+1
14721485

14731486
elif envname in ('funcdesc', 'excdesc', 'datadesc'):
1474-
pp[i:i] = [
1475-
chunk(CSLINE, ch.where, 'end'),
1476-
chunk(GROUP, ch.where, [
1477-
chunk(PLAIN, ch.where, hist.command)])]
1487+
pp[i:i] = [chunk(CSLINE, ch.where, 'end'),
1488+
chunk(GROUP, ch.where, [
1489+
chunk(PLAIN, ch.where, hist.command)])]
14781490
i, length = i+2, length+2
14791491

1480-
elif envname in ('seealso', 'opcodedesc'):
1492+
elif envname == 'opcodedesc':
1493+
pp[i:i] = [chunk(CSLINE, ch.where, 'end'),
1494+
chunk(GROUP, ch.where, [
1495+
chunk(PLAIN, ch.where, "deffn")])]
1496+
i, length = i+2, length+2
1497+
1498+
elif envname in ('seealso', 'sloppypar', 'flushleft'):
14811499
pass
14821500

14831501
else:
@@ -1553,6 +1571,10 @@ def changeit(buf, pp):
15531571
del pp[i:newi]
15541572
length = length - (newi-i)
15551573

1574+
elif s_buf_data == "fulllineitems":
1575+
del pp[i-1]
1576+
i, length = i-1, length-1
1577+
15561578
elif s_buf_data == 'item':
15571579
ch.chtype = chunk_type[CSLINE]
15581580
length, newi = getoptarg(length, buf, pp, i)
@@ -1828,12 +1850,6 @@ def changeit(buf, pp):
18281850
del pp[i:newi]
18291851
length = length - (newi-i)
18301852

1831-
## ingroupch.append(chunk(PLAIN, ch.where, ' '))
1832-
## ingroupch.append(chunk(CSNAME, ch.where, 'r'))
1833-
## ingroupch.append(chunk(GROUP, ch.where, [
1834-
## chunk(PLAIN, ch.where,
1835-
## '(built-in)')]))
1836-
18371853
pp.insert(i, chunk(GROUP, ch.where, ingroupch))
18381854
length, i = length+1, i+1
18391855

@@ -2048,13 +2064,30 @@ def changeit(buf, pp):
20482064
i = i - 1
20492065
length = length + len(data) - 2
20502066

2067+
elif s_buf_data == "quad":
2068+
ch.chtype = PLAIN
2069+
ch.data = " "
2070+
20512071
elif s_buf_data in ('noindent', 'indexsubitem'):
20522072
pass
20532073

20542074
elif s_buf_data == 'label':
2075+
name = s(buf, pp[i].data[0].data)
20552076
del pp[i-1:i+1]
20562077
length = length - 2
20572078
i = i - 1
2079+
label_nodes[name] = hist.nodenames[-1]
2080+
2081+
elif s_buf_data == 'ref':
2082+
name = s(buf, pp[i].data[0].data)
2083+
if label_nodes.has_key(name):
2084+
pp[i].data[0].data = label_nodes[name]
2085+
else:
2086+
pp[i-1:i+1] = [
2087+
chunk(PLAIN, ch.where,
2088+
"(unknown node reference: %s)" % name)]
2089+
length = length - 1
2090+
print "WARNING: unknown node label", `name`
20582091

20592092
else:
20602093
print "don't know what to do with keyword " + s_buf_data

0 commit comments

Comments
 (0)