3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-20 07:05:44 +01:00

Read every CommonMark image and empty link: an image ADF holds no node for as its linked alt text, a title as its caption, an empty link text as its destination

This commit is contained in:
2026-10-09 03:28:12 +02:00
committed by Lillem4n
parent 847c358358
commit 3b621a9cef
19 changed files with 473 additions and 242 deletions
+3 -1
View File
@@ -16,7 +16,9 @@ One directory per contract kind:
`spec.json` is the suite; `refusals.json` pins each refusing example to its error `code`;
`exceptions.json` pins each known divergence by `check`, `example`, `kind` and the exact
`divergence`, with a `reason`. `kind` is `mark-model` (the permanent count divergence from ADF's
mark-per-text-node model) or `pending` (a parser gap).
mark-per-node model), `node-model` (a permanent divergence where ADF holds no node for what
CommonMark renders: an empty link text, an image amid text, an image's title) or `pending` (a
parser gap).
JSON is two-space indent, keys sorted, and a document read back must deep-equal the fixture's
(`docs/decisions.md` §Equality is deep). `spec.json` is the vendored, upstream machine-readable
+105 -21
View File
@@ -286,33 +286,19 @@
"kind": "mark-model",
"reason": "The mark spans adjacent text nodes, counted once per node where CommonMark nests one element."
},
{
"check": "count",
"divergence": "a 1/0",
"example": 484,
"kind": "pending",
"reason": "An empty link text stays literal text; CommonMark renders an empty link."
},
{
"check": "text",
"divergence": "\"\" against \"[](./target.md)\"",
"divergence": "\"\" against \"./target.md\"",
"example": 484,
"kind": "pending",
"reason": "An empty link text stays literal text; CommonMark renders an empty link."
"kind": "node-model",
"reason": "ADF holds no empty text node, so an empty link text reads as its destination, and an empty destination as nothing."
},
{
"check": "count",
"divergence": "a 1/0",
"example": 487,
"kind": "pending",
"reason": "An empty link text stays literal text; CommonMark renders an empty link."
},
{
"check": "text",
"divergence": "\"\" against \"[]()\"",
"example": 487,
"kind": "pending",
"reason": "An empty link text stays literal text; CommonMark renders an empty link."
"kind": "node-model",
"reason": "ADF holds no empty text node, so an empty link text reads as its destination, and an empty destination as nothing."
},
{
"check": "count",
@@ -377,16 +363,114 @@
"kind": "mark-model",
"reason": "The mark spans adjacent text nodes, counted once per node where CommonMark nests one element."
},
{
"check": "text",
"divergence": "\"\" against \"title\"",
"example": 572,
"kind": "node-model",
"reason": "ADF's media holds no title, so the image's title reads as its caption."
},
{
"check": "text",
"divergence": "\"\" against \"train & tracks\"",
"example": 573,
"kind": "node-model",
"reason": "ADF's media holds no title, so the image's title reads as its caption."
},
{
"check": "text",
"divergence": "\"\" against \"train & tracks\"",
"example": 576,
"kind": "node-model",
"reason": "ADF's media holds no title, so the image's title reads as its caption."
},
{
"check": "text",
"divergence": "\"\" against \"train & tracks\"",
"example": 577,
"kind": "node-model",
"reason": "ADF's media holds no title, so the image's title reads as its caption."
},
{
"check": "count",
"divergence": "em 1/2",
"divergence": "a 0/1 img 1/0",
"example": 579,
"kind": "node-model",
"reason": "ADF holds no image amid text, so the image reads as its alt text, linked to its destination."
},
{
"check": "text",
"divergence": "\"My \" against \"My foo bar\"",
"example": 579,
"kind": "node-model",
"reason": "ADF holds no image amid text, so the image reads as its alt text, linked to its destination."
},
{
"check": "text",
"divergence": "\"\" against \"title\"",
"example": 584,
"kind": "node-model",
"reason": "ADF's media holds no title, so the image's title reads as its caption."
},
{
"check": "text",
"divergence": "\"\" against \"title\"",
"example": 585,
"kind": "node-model",
"reason": "ADF's media holds no title, so the image's title reads as its caption."
},
{
"check": "text",
"divergence": "\"\" against \"title\"",
"example": 586,
"kind": "node-model",
"reason": "ADF's media holds no title, so the image's title reads as its caption."
},
{
"check": "count",
"divergence": "a 0/1 img 1/0",
"example": 587,
"kind": "node-model",
"reason": "ADF holds no image amid text, so the image reads as its alt text, linked to its destination."
},
{
"check": "text",
"divergence": "\" []\" against \"foo []\"",
"example": 587,
"kind": "node-model",
"reason": "ADF holds no image amid text, so the image reads as its alt text, linked to its destination."
},
{
"check": "text",
"divergence": "\"\" against \"title\"",
"example": 588,
"kind": "node-model",
"reason": "ADF's media holds no title, so the image's title reads as its caption."
},
{
"check": "text",
"divergence": "\"\" against \"title\"",
"example": 589,
"kind": "node-model",
"reason": "ADF's media holds no title, so the image's title reads as its caption."
},
{
"check": "text",
"divergence": "\"\" against \"title\"",
"example": 591,
"kind": "node-model",
"reason": "ADF's media holds no title, so the image's title reads as its caption."
},
{
"check": "count",
"divergence": "em 1/3",
"example": 638,
"kind": "mark-model",
"reason": "The mark spans adjacent text nodes, counted once per node where CommonMark nests one element."
},
{
"check": "count",
"divergence": "em 1/2",
"divergence": "em 1/3",
"example": 639,
"kind": "mark-model",
"reason": "The mark spans adjacent text nodes, counted once per node where CommonMark nests one element."
-56
View File
@@ -219,70 +219,14 @@
"code": "unmappable-html",
"example": 494
},
{
"code": "unmappable-image",
"example": 517
},
{
"code": "unmappable-html",
"example": 524
},
{
"code": "unmappable-image",
"example": 531
},
{
"code": "unmappable-html",
"example": 536
},
{
"code": "unmappable-image",
"example": 572
},
{
"code": "unmappable-image",
"example": 573
},
{
"code": "unmappable-image",
"example": 576
},
{
"code": "unmappable-image",
"example": 577
},
{
"code": "unmappable-image",
"example": 579
},
{
"code": "unmappable-image",
"example": 584
},
{
"code": "unmappable-image",
"example": 585
},
{
"code": "unmappable-image",
"example": 586
},
{
"code": "unmappable-image",
"example": 587
},
{
"code": "unmappable-image",
"example": 588
},
{
"code": "unmappable-image",
"example": 589
},
{
"code": "unmappable-image",
"example": 591
},
{
"code": "unmappable-html",
"example": 613
-1
View File
@@ -1 +0,0 @@
unmappable-image
-1
View File
@@ -1 +0,0 @@
See ![the moon](https://example.com/moon.png) tonight.
+158
View File
@@ -0,0 +1,158 @@
{
"content": [
{
"content": [
{
"text": "See ",
"type": "text"
},
{
"marks": [
{
"attrs": {
"href": "https://example.com/moon.png",
"title": "Full"
},
"type": "link"
}
],
"text": "the moon",
"type": "text"
},
{
"text": " tonight, or ",
"type": "text"
},
{
"marks": [
{
"attrs": {
"href": "https://example.com/sun.png"
},
"type": "link"
}
],
"text": "https://example.com/sun.png",
"type": "text"
},
{
"text": ".",
"type": "text"
}
],
"type": "paragraph"
},
{
"attrs": {
"layout": "center"
},
"content": [
{
"attrs": {
"alt": "the moon",
"type": "external",
"url": "https://example.com/moon.png"
},
"type": "media"
},
{
"content": [
{
"text": "The moon, at night.",
"type": "text"
}
],
"type": "caption"
}
],
"type": "mediaSingle"
},
{
"attrs": {
"layout": "center"
},
"content": [
{
"attrs": {
"alt": "the moon",
"type": "external",
"url": "https://example.com/moon.png"
},
"marks": [
{
"attrs": {
"href": "https://example.com/"
},
"type": "link"
}
],
"type": "media"
}
],
"type": "mediaSingle"
},
{
"content": [
{
"text": "Look ",
"type": "text"
},
{
"marks": [
{
"attrs": {
"href": "https://example.com/"
},
"type": "link"
}
],
"text": "here the moon",
"type": "text"
},
{
"text": ", ",
"type": "text"
},
{
"marks": [
{
"attrs": {
"href": "https://example.com/"
},
"type": "link"
}
],
"text": "https://example.com/",
"type": "text"
},
{
"text": " and .",
"type": "text"
}
],
"type": "paragraph"
},
{
"attrs": {
"level": 1
},
"content": [
{
"marks": [
{
"attrs": {
"href": "https://example.com/moon.png"
},
"type": "link"
}
],
"text": "the moon",
"type": "text"
}
],
"type": "heading"
}
],
"type": "doc",
"version": 1
}
+9
View File
@@ -0,0 +1,9 @@
See ![the moon](https://example.com/moon.png "Full") tonight, or ![](https://example.com/sun.png).
![the moon](https://example.com/moon.png "The moon, at night.")
[![the moon](https://example.com/moon.png)](https://example.com/)
Look [here ![the moon](https://example.com/moon.png)](https://example.com/), [](https://example.com/) and []().
# ![the moon](https://example.com/moon.png)