Check in the CommonMark spec suite and pin its exception list #58

Open
lilleman wants to merge 6 commits from commonmark-spec-suite into main
3 changed files with 6 additions and 9 deletions
Showing only changes of commit 12b57a06a9 - Show all commits
+3 -6
View File
@@ -12,12 +12,9 @@ One directory per contract kind, each landing with its milestone:
pins which error. pins which error.
- `real-payloads/``<name>.json`: sanitized live ADF, round-tripped ADF→markdown→ADF. No - `real-payloads/``<name>.json`: sanitized live ADF, round-tripped ADF→markdown→ADF. No
expected markdown. expected markdown.
- `commonmark-spec/``spec.json` (the pinned CommonMark suite, read as corpus data per - `commonmark-spec/``spec.json` (the CommonMark 0.31.2 suite, vendored byte-exact) and
AGENTS.md §1) and `exceptions.json` (examples a documented divergence exempts, keyed by `exceptions.json` (the examples a known divergence exempts, keyed by `check` and `example` with
`check` and `example` with a `reason`). Three checks an example must pass: the §2 canonical a `reason`).
fixpoint — a named error, or markdown that parses and emits back to itself; the reference HTML's
text, tags stripped and entities decoded, against the parsed document's concatenated text; and a
count of the CommonMark subset's elements against the nodes and marks they map to.
JSON is editor-normal (AGENTS.md §2), two-space indent, keys sorted. `spec.json` is the vendored, JSON is editor-normal (AGENTS.md §2), two-space indent, keys sorted. `spec.json` is the vendored,
upstream machine-readable suite (CommonMark 0.31.2, CC-BY-SA-4.0, © John MacFarlane) and is not upstream machine-readable suite (CommonMark 0.31.2, CC-BY-SA-4.0, © John MacFarlane) and is not
+2 -2
View File
@@ -56,8 +56,8 @@ const spec = readSpec()
const exceptions = readExceptions() const exceptions = readExceptions()
const exceptionIndex = new Map(exceptions.map((entry) => [`${entry.example}:${entry.check}`, entry.reason])) const exceptionIndex = new Map(exceptions.map((entry) => [`${entry.example}:${entry.check}`, entry.reason]))
test('the CommonMark spec suite is the version the parser names', () => { test('the CommonMark spec suite is the pinned 0.31.2 run', () => {
assert.ok(spec.length > 600, `spec.json holds ${spec.length} examples, not a full suite`) assert.equal(spec.length, 652)
}) })
test('the exception list is unique per example and check', () => { test('the exception list is unique per example and check', () => {
+1 -1
View File
@@ -53,7 +53,7 @@ function pairedNames(root: string, first: string, second: string): string[] {
function corpusJsonPaths(): string[] { function corpusJsonPaths(): string[] {
return readdirSync(corpusRoot, { encoding: 'utf8', recursive: true }) return readdirSync(corpusRoot, { encoding: 'utf8', recursive: true })
.filter((name) => name.endsWith('.json')) .filter((name) => name.endsWith('.json'))
.filter((name) => !name.startsWith(`commonmark-spec${sep}`)) .filter((name) => name !== `commonmark-spec${sep}spec.json`)
.map((name) => join(corpusRoot, name)) .map((name) => join(corpusRoot, name))
.sort() .sort()
} }