Add paperspec correct, check math forms and datasets, and give the tools public names

The work the other paper tools planned for paperspec (paperdesk PLAN M5.4,
paperform PLAN 4.2):

- paperspec correct and paperspec.revision apply proposed corrections to a
  package, folder or zip, and write it only once it validates.
- doc.math.form is checked: label and style commands always, the form's own
  spelling when papermath is installed or forms= is passed.
- paperspec.datasets and seven doc.dataset.* rules check a package's datasets.
- fixtures/invalid gains suspect-witness and math-form-label (33 in all).
- Canonical JSON reads numbers as doubles, so 1e20 round-trips.
- The registries and the JSON-LD context ship in the wheel.
- Public names for what paperdesk and paperform imported as private ones,
  with the old names kept as aliases.
- The text and lossy-projection functions are about three times faster
  through the gate, tested equal to the old code on every code point.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013XwDhn4LkrKQfw4ArDEr2E
This commit is contained in:
alexmandClaude committed 2026-10-20 22:10:17 -04:00
1 parent 8c07dd7c15
commit 4fb8b4f5a7
70 files changed
+4470 -270

No files matched your search

+48
View File
@@ -352,3 +352,51 @@ def test_cp_to_utf16_counts_astral_characters_twice():
assert cp_to_utf16("a\U0001d465b", 0) == 0
assert cp_to_utf16("a\U0001d465b", 2) == 3
assert cp_to_utf16("a\U0001d465b", 3) == 4
# The whitespace and digit helpers are written with regular expressions and str methods for
# speed; these hold them to the character-by-character definitions over every code point.
EVERY_CHARACTER = "".join(chr(c) for c in range(0x110000) if not 0xD800 <= c <= 0xDFFF)
def test_digits_is_general_category_nd_over_every_code_point():
assert text.digits(EVERY_CHARACTER) == "".join(
ch for ch in EVERY_CHARACTER if unicodedata.category(ch) == "Nd"
)
def test_remove_ws_removes_exactly_white_space_over_every_code_point():
assert text.remove_ws(EVERY_CHARACTER) == "".join(
ch for ch in EVERY_CHARACTER if ord(ch) not in text.WHITE_SPACE
)
def _collapse_by_hand(s):
out, prev = [], False
for ch in s:
if text.is_ws(ch):
if not prev:
out.append(" ")
prev = True
else:
out.append(ch)
prev = False
return "".join(out)
@given(
st.text(
alphabet=st.sampled_from(
[*map(chr, sorted(text.WHITE_SPACE)), "a", "é", "\x00", "1"]
)
)
)
@settings(derandomize=True, max_examples=300, database=None, deadline=None)
def test_collapse_ws_and_trim_match_their_definitions(s):
assert text.collapse_ws(s) == _collapse_by_hand(s)
a, b = 0, len(s)
while a < b and text.is_ws(s[a]):
a += 1
while b > a and text.is_ws(s[b - 1]):
b -= 1
assert text.trim(s) == s[a:b]