|
4 | 4 | from download import downloadUnicodeXML
|
5 | 5 | from math import ceil
|
6 | 6 | from inline_axis_operators import stretchAxis, inlineAxisOperators
|
7 |
| - |
| 7 | +from bisect import bisect_left |
8 | 8 | import operator
|
9 | 9 | import json
|
10 | 10 |
|
@@ -489,7 +489,24 @@ def serializeValue(value, fence, separator):
|
489 | 489 | print("done.");
|
490 | 490 | ################################################################################
|
491 | 491 |
|
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))) |
493 | 510 | del knownTables["infixEntriesWithDefaultValues"]
|
494 | 511 |
|
495 | 512 | # Convert nonBMP characters to surrogates pair (multiChar)
|
|
0 commit comments