mirror of
https://github.com/python/cpython.git
synced 2025-07-23 11:15:24 +00:00
recognize more latex commands; add obindex
This commit is contained in:
parent
e83e380930
commit
7760cdea81
2 changed files with 44 additions and 8 deletions
|
@ -857,9 +857,9 @@ class Wobj:
|
||||||
# ignore these commands
|
# ignore these commands
|
||||||
ignoredcommands = ('bcode', 'ecode')
|
ignoredcommands = ('bcode', 'ecode')
|
||||||
# map commands like these to themselves as plaintext
|
# map commands like these to themselves as plaintext
|
||||||
wordsselves = ('UNIX', 'ABC', 'C', 'ASCII', 'EOF')
|
wordsselves = ('UNIX', 'ABC', 'C', 'ASCII', 'EOF', 'LaTeX')
|
||||||
# \{ --> {, \} --> }, etc
|
# \{ --> {, \} --> }, etc
|
||||||
themselves = ('{', '}', '.', '@') + wordsselves
|
themselves = ('{', '}', '.', '@', ' ', '\n') + wordsselves
|
||||||
# these ones also themselves (see argargs macro in myformat.sty)
|
# these ones also themselves (see argargs macro in myformat.sty)
|
||||||
inargsselves = (',', '[', ']', '(', ')')
|
inargsselves = (',', '[', ']', '(', ')')
|
||||||
# this is how *I* would show the difference between emph and strong
|
# this is how *I* would show the difference between emph and strong
|
||||||
|
@ -871,8 +871,8 @@ markcmds = {'code': ('', ''), 'var': 1, 'emph': ('_', '_'), \
|
||||||
fontchanges = {'rm': 'r', 'it': 'i', 'em': 'emph', 'bf': 'b', 'tt': 't'}
|
fontchanges = {'rm': 'r', 'it': 'i', 'em': 'emph', 'bf': 'b', 'tt': 't'}
|
||||||
|
|
||||||
# transparent for these commands
|
# transparent for these commands
|
||||||
for_texi = ('emph', 'var', 'strong', 'code', 'kbd', 'key', 'dfn', 'samp', \
|
for_texi = ('emph', 'var', 'strong', 'code', 'kbd', 'key', 'dfn', 'samp',
|
||||||
'r', 'i', 't')
|
'file', 'r', 'i', 't')
|
||||||
|
|
||||||
|
|
||||||
# try to remove macros and return flat text
|
# try to remove macros and return flat text
|
||||||
|
@ -1759,6 +1759,24 @@ def changeit(buf, pp):
|
||||||
length, i = length+1, i+1
|
length, i = length+1, i+1
|
||||||
|
|
||||||
|
|
||||||
|
elif s(buf, ch.data) == 'obindex':
|
||||||
|
ch.chtype = chunk_type(CSLINE)
|
||||||
|
ch.data = 'findex'
|
||||||
|
length, newi = getnextarg(length, buf, pp, i)
|
||||||
|
ingroupch = pp[i:newi]
|
||||||
|
del pp[i:newi]
|
||||||
|
length = length - (newi-i)
|
||||||
|
|
||||||
|
ingroupch.append(chunk(PLAIN, ch.where, ' '))
|
||||||
|
ingroupch.append(chunk(CSNAME, ch.where, 'r'))
|
||||||
|
ingroupch.append(chunk(GROUP, ch.where, [\
|
||||||
|
chunk(PLAIN, ch.where, \
|
||||||
|
'(object)')]))
|
||||||
|
|
||||||
|
pp.insert(i, chunk(GROUP, ch.where, ingroupch))
|
||||||
|
length, i = length+1, i+1
|
||||||
|
|
||||||
|
|
||||||
elif s(buf, ch.data) == 'opindex':
|
elif s(buf, ch.data) == 'opindex':
|
||||||
ch.chtype = chunk_type(CSLINE)
|
ch.chtype = chunk_type(CSLINE)
|
||||||
ch.data = 'findex'
|
ch.data = 'findex'
|
||||||
|
|
|
@ -857,9 +857,9 @@ class Wobj:
|
||||||
# ignore these commands
|
# ignore these commands
|
||||||
ignoredcommands = ('bcode', 'ecode')
|
ignoredcommands = ('bcode', 'ecode')
|
||||||
# map commands like these to themselves as plaintext
|
# map commands like these to themselves as plaintext
|
||||||
wordsselves = ('UNIX', 'ABC', 'C', 'ASCII', 'EOF')
|
wordsselves = ('UNIX', 'ABC', 'C', 'ASCII', 'EOF', 'LaTeX')
|
||||||
# \{ --> {, \} --> }, etc
|
# \{ --> {, \} --> }, etc
|
||||||
themselves = ('{', '}', '.', '@') + wordsselves
|
themselves = ('{', '}', '.', '@', ' ', '\n') + wordsselves
|
||||||
# these ones also themselves (see argargs macro in myformat.sty)
|
# these ones also themselves (see argargs macro in myformat.sty)
|
||||||
inargsselves = (',', '[', ']', '(', ')')
|
inargsselves = (',', '[', ']', '(', ')')
|
||||||
# this is how *I* would show the difference between emph and strong
|
# this is how *I* would show the difference between emph and strong
|
||||||
|
@ -871,8 +871,8 @@ markcmds = {'code': ('', ''), 'var': 1, 'emph': ('_', '_'), \
|
||||||
fontchanges = {'rm': 'r', 'it': 'i', 'em': 'emph', 'bf': 'b', 'tt': 't'}
|
fontchanges = {'rm': 'r', 'it': 'i', 'em': 'emph', 'bf': 'b', 'tt': 't'}
|
||||||
|
|
||||||
# transparent for these commands
|
# transparent for these commands
|
||||||
for_texi = ('emph', 'var', 'strong', 'code', 'kbd', 'key', 'dfn', 'samp', \
|
for_texi = ('emph', 'var', 'strong', 'code', 'kbd', 'key', 'dfn', 'samp',
|
||||||
'r', 'i', 't')
|
'file', 'r', 'i', 't')
|
||||||
|
|
||||||
|
|
||||||
# try to remove macros and return flat text
|
# try to remove macros and return flat text
|
||||||
|
@ -1759,6 +1759,24 @@ def changeit(buf, pp):
|
||||||
length, i = length+1, i+1
|
length, i = length+1, i+1
|
||||||
|
|
||||||
|
|
||||||
|
elif s(buf, ch.data) == 'obindex':
|
||||||
|
ch.chtype = chunk_type(CSLINE)
|
||||||
|
ch.data = 'findex'
|
||||||
|
length, newi = getnextarg(length, buf, pp, i)
|
||||||
|
ingroupch = pp[i:newi]
|
||||||
|
del pp[i:newi]
|
||||||
|
length = length - (newi-i)
|
||||||
|
|
||||||
|
ingroupch.append(chunk(PLAIN, ch.where, ' '))
|
||||||
|
ingroupch.append(chunk(CSNAME, ch.where, 'r'))
|
||||||
|
ingroupch.append(chunk(GROUP, ch.where, [\
|
||||||
|
chunk(PLAIN, ch.where, \
|
||||||
|
'(object)')]))
|
||||||
|
|
||||||
|
pp.insert(i, chunk(GROUP, ch.where, ingroupch))
|
||||||
|
length, i = length+1, i+1
|
||||||
|
|
||||||
|
|
||||||
elif s(buf, ch.data) == 'opindex':
|
elif s(buf, ch.data) == 'opindex':
|
||||||
ch.chtype = chunk_type(CSLINE)
|
ch.chtype = chunk_type(CSLINE)
|
||||||
ch.data = 'findex'
|
ch.data = 'findex'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue