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

Skip to content

Commit 63a0191

Browse files
committed
Deal with macros that have to be replaced with simple text; only a
couple of these are currently found in index data, but these should all be handled in the same way. Closes SF bug #952737.
1 parent 1c0423a commit 63a0191

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

Doc/tools/buildindex.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,27 @@
1313
bang_join = "!".join
1414
null_join = "".join
1515

16+
REPLACEMENTS = [
17+
# Hackish way to deal with macros replaced with simple text
18+
(re.compile(r"\\ABC\b"), "ABC"),
19+
(re.compile(r"\\ASCII\b"), "ASCII"),
20+
(re.compile(r"\\Cpp\b"), "C++"),
21+
(re.compile(r"\\EOF\b"), "EOF"),
22+
(re.compile(r"\\NULL\b"), "NULL"),
23+
(re.compile(r"\\POSIX\b"), "POSIX"),
24+
(re.compile(r"\\UNIX\b"), "Unix"),
25+
# deal with turds left over from LaTeX2HTML
26+
(re.compile(r"<#\d+#>"), ""),
27+
]
1628

1729
class Node:
18-
__rmjunk = re.compile("<#\d+#>")
19-
2030
continuation = 0
2131

2232
def __init__(self, link, str, seqno):
2333
self.links = [link]
2434
self.seqno = seqno
25-
# remove <#\d+#> left in by moving the data out of LaTeX2HTML
26-
str = self.__rmjunk.sub('', str)
35+
for pattern, replacement in REPLACEMENTS:
36+
str = pattern.sub(replacement, str)
2737
# build up the text
2838
self.text = split_entry_text(str)
2939
self.key = split_entry_key(str)

0 commit comments

Comments
 (0)