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

Skip to content

Commit 7760cde

Browse files
committed
recognize more latex commands; add obindex
1 parent e83e380 commit 7760cde

2 files changed

Lines changed: 44 additions & 8 deletions

File tree

Doc/partparse.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -857,9 +857,9 @@ def write(self, data):
857857
# ignore these commands
858858
ignoredcommands = ('bcode', 'ecode')
859859
# map commands like these to themselves as plaintext
860-
wordsselves = ('UNIX', 'ABC', 'C', 'ASCII', 'EOF')
860+
wordsselves = ('UNIX', 'ABC', 'C', 'ASCII', 'EOF', 'LaTeX')
861861
# \{ --> {, \} --> }, etc
862-
themselves = ('{', '}', '.', '@') + wordsselves
862+
themselves = ('{', '}', '.', '@', ' ', '\n') + wordsselves
863863
# these ones also themselves (see argargs macro in myformat.sty)
864864
inargsselves = (',', '[', ']', '(', ')')
865865
# this is how *I* would show the difference between emph and strong
@@ -871,8 +871,8 @@ def write(self, data):
871871
fontchanges = {'rm': 'r', 'it': 'i', 'em': 'emph', 'bf': 'b', 'tt': 't'}
872872

873873
# transparent for these commands
874-
for_texi = ('emph', 'var', 'strong', 'code', 'kbd', 'key', 'dfn', 'samp', \
875-
'r', 'i', 't')
874+
for_texi = ('emph', 'var', 'strong', 'code', 'kbd', 'key', 'dfn', 'samp',
875+
'file', 'r', 'i', 't')
876876

877877

878878
# try to remove macros and return flat text
@@ -1759,6 +1759,24 @@ def changeit(buf, pp):
17591759
length, i = length+1, i+1
17601760

17611761

1762+
elif s(buf, ch.data) == 'obindex':
1763+
ch.chtype = chunk_type(CSLINE)
1764+
ch.data = 'findex'
1765+
length, newi = getnextarg(length, buf, pp, i)
1766+
ingroupch = pp[i:newi]
1767+
del pp[i:newi]
1768+
length = length - (newi-i)
1769+
1770+
ingroupch.append(chunk(PLAIN, ch.where, ' '))
1771+
ingroupch.append(chunk(CSNAME, ch.where, 'r'))
1772+
ingroupch.append(chunk(GROUP, ch.where, [\
1773+
chunk(PLAIN, ch.where, \
1774+
'(object)')]))
1775+
1776+
pp.insert(i, chunk(GROUP, ch.where, ingroupch))
1777+
length, i = length+1, i+1
1778+
1779+
17621780
elif s(buf, ch.data) == 'opindex':
17631781
ch.chtype = chunk_type(CSLINE)
17641782
ch.data = 'findex'

Doc/tools/partparse.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -857,9 +857,9 @@ def write(self, data):
857857
# ignore these commands
858858
ignoredcommands = ('bcode', 'ecode')
859859
# map commands like these to themselves as plaintext
860-
wordsselves = ('UNIX', 'ABC', 'C', 'ASCII', 'EOF')
860+
wordsselves = ('UNIX', 'ABC', 'C', 'ASCII', 'EOF', 'LaTeX')
861861
# \{ --> {, \} --> }, etc
862-
themselves = ('{', '}', '.', '@') + wordsselves
862+
themselves = ('{', '}', '.', '@', ' ', '\n') + wordsselves
863863
# these ones also themselves (see argargs macro in myformat.sty)
864864
inargsselves = (',', '[', ']', '(', ')')
865865
# this is how *I* would show the difference between emph and strong
@@ -871,8 +871,8 @@ def write(self, data):
871871
fontchanges = {'rm': 'r', 'it': 'i', 'em': 'emph', 'bf': 'b', 'tt': 't'}
872872

873873
# transparent for these commands
874-
for_texi = ('emph', 'var', 'strong', 'code', 'kbd', 'key', 'dfn', 'samp', \
875-
'r', 'i', 't')
874+
for_texi = ('emph', 'var', 'strong', 'code', 'kbd', 'key', 'dfn', 'samp',
875+
'file', 'r', 'i', 't')
876876

877877

878878
# try to remove macros and return flat text
@@ -1759,6 +1759,24 @@ def changeit(buf, pp):
17591759
length, i = length+1, i+1
17601760

17611761

1762+
elif s(buf, ch.data) == 'obindex':
1763+
ch.chtype = chunk_type(CSLINE)
1764+
ch.data = 'findex'
1765+
length, newi = getnextarg(length, buf, pp, i)
1766+
ingroupch = pp[i:newi]
1767+
del pp[i:newi]
1768+
length = length - (newi-i)
1769+
1770+
ingroupch.append(chunk(PLAIN, ch.where, ' '))
1771+
ingroupch.append(chunk(CSNAME, ch.where, 'r'))
1772+
ingroupch.append(chunk(GROUP, ch.where, [\
1773+
chunk(PLAIN, ch.where, \
1774+
'(object)')]))
1775+
1776+
pp.insert(i, chunk(GROUP, ch.where, ingroupch))
1777+
length, i = length+1, i+1
1778+
1779+
17621780
elif s(buf, ch.data) == 'opindex':
17631781
ch.chtype = chunk_type(CSLINE)
17641782
ch.data = 'findex'

0 commit comments

Comments
 (0)