Skip to content

Commit 6c533ee

Browse files
committed
Add a check for #104 (comment)
1 parent a80a3ca commit 6c533ee

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

tables/operator-dictionary.py

+19-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from download import downloadUnicodeXML
55
from math import ceil
66
from inline_axis_operators import stretchAxis, inlineAxisOperators
7-
7+
from bisect import bisect_left
88
import operator
99
import json
1010

@@ -489,7 +489,24 @@ def serializeValue(value, fence, separator):
489489
print("done.");
490490
################################################################################
491491

492-
# Delete infix operators using default values.
492+
# Delete infix operators using default values. But before doing that, check
493+
# (for single char entries) whether they actually don't exist in another
494+
# category. Otherwise, such a category will be used when no explicit form is
495+
# specified, which will override the default values.
496+
# https://w3c.github.io/mathml-core/#ref-for-dfn-algorithm-for-determining-the-properties-of-an-embellished-operator-1
497+
498+
for entry in knownTables["infixEntriesWithDefaultValues"]["singleChar"]:
499+
otherCategories = []
500+
for name in knownTables:
501+
if name.startswith("infix") or name == "fence":
502+
continue
503+
i = bisect_left(knownTables[name]["singleChar"], entry)
504+
if (i != len(knownTables[name]["singleChar"]) and
505+
knownTables[name]["singleChar"][i] == entry):
506+
otherCategories.append(name)
507+
assert len(otherCategories) == 0, (
508+
"U+%04X is in infixEntriesWithDefaultValues but also in %s" %
509+
(entry, str(otherCategories)))
493510
del knownTables["infixEntriesWithDefaultValues"]
494511

495512
# Convert nonBMP characters to surrogates pair (multiChar)

0 commit comments

Comments
 (0)