mirror of
https://github.com/larvit/adf-codec.git
synced 2026-11-20 23:25:43 +01:00
Answer architecture round 2: the claims type keeps directives apart from alerts and highlights, two paragraphs reflowed
This commit is contained in:
@@ -167,12 +167,12 @@ carries it opaquely and restores it unchanged ([`docs/decisions.md`](https://git
|
|||||||
|
|
||||||
`ConvertError` is `{ code, message, path, position? }`. `code` is the exported `ConvertErrorCode`,
|
`ConvertError` is `{ code, message, path, position? }`. `code` is the exported `ConvertErrorCode`,
|
||||||
stable across minors and safe to `switch` on exhaustively with no `default`; `message` is free text
|
stable across minors and safe to `switch` on exhaustively with no `default`; `message` is free text
|
||||||
and may change in any release. A parse always names a position, so the three markdown readers
|
and may change in any release. A parse always names a position, so the three markdown readers return
|
||||||
return `ParseError`, whose `position` reads without a guard; an emit reads no
|
`ParseError`, whose `position` reads without a guard; an emit reads no source and carries `path`
|
||||||
source and carries `path` alone; one handler typed on `ConvertError` takes both, which is what the
|
alone; one handler typed on `ConvertError` takes both, which is what the calls between markdown and
|
||||||
calls between markdown and HTML hand back. `path` is the node's place from the
|
HTML hand back. `path` is the node's place from the document root, alternating `'content'` and an
|
||||||
document root, alternating `'content'` and an index, so `path.map((step) => '/' + step).join('')`
|
index, so `path.map((step) => '/' + step).join('')` is a JSON Pointer at the node — the empty path
|
||||||
is a JSON Pointer at the node — the empty path being the document itself.
|
being the document itself.
|
||||||
|
|
||||||
A call reports the first refusal in document order and stops, so a document with several surfaces
|
A call reports the first refusal in document order and stops, so a document with several surfaces
|
||||||
them one per call. Every refusal is deterministic — there is no I/O anywhere — so a retry returns
|
them one per call. Every refusal is deterministic — there is no I/O anywhere — so a retry returns
|
||||||
|
|||||||
@@ -18,8 +18,10 @@ export type Claims = {
|
|||||||
// The writer spells pipe tables and `~~` in every flavour it writes.
|
// The writer spells pipe tables and `~~` in every flavour it writes.
|
||||||
type WrittenClaims = Claims & { pipeTables: true; strikethrough: true }
|
type WrittenClaims = Claims & { pipeTables: true; strikethrough: true }
|
||||||
|
|
||||||
// No flavour claims directives beside alerts or highlights: an expand directive leaves `inExpand` unset and a directive's slot reads `==`.
|
// Directives exclude alerts and highlights: an expand directive leaves `inExpand` unset and a directive's slot reads `==`.
|
||||||
export const flavourClaims: Readonly<{ commonmark: Claims } & Record<WrittenFlavour, WrittenClaims>> = {
|
type ReadClaims = Claims & ({ directives: false } | { alerts: false; directives: true; highlights: false })
|
||||||
|
|
||||||
|
export const flavourClaims: Readonly<{ commonmark: ReadClaims } & Record<WrittenFlavour, ReadClaims & WrittenClaims>> = {
|
||||||
commonmark: { alerts: false, carryFence: false, directives: false, highlights: false, pipeTables: false, strikethrough: false, taskMarkers: false },
|
commonmark: { alerts: false, carryFence: false, directives: false, highlights: false, pipeTables: false, strikethrough: false, taskMarkers: false },
|
||||||
lossless: { alerts: false, carryFence: true, directives: true, highlights: false, pipeTables: true, strikethrough: true, taskMarkers: false },
|
lossless: { alerts: false, carryFence: true, directives: true, highlights: false, pipeTables: true, strikethrough: true, taskMarkers: false },
|
||||||
portable: { alerts: true, carryFence: false, directives: false, highlights: true, pipeTables: true, strikethrough: true, taskMarkers: true },
|
portable: { alerts: true, carryFence: false, directives: false, highlights: true, pipeTables: true, strikethrough: true, taskMarkers: true },
|
||||||
|
|||||||
@@ -128,9 +128,10 @@ and its spelling leaves the README's "Four CommonMark spellings" bullet, which c
|
|||||||
|
|
||||||
### 7. Ship HTML: `adfToHtml`, `htmlToAdf`, and markdown to and from HTML composed through ADF, each call named by its flavour.
|
### 7. Ship HTML: `adfToHtml`, `htmlToAdf`, and markdown to and from HTML composed through ADF, each call named by its flavour.
|
||||||
|
|
||||||
Lands after items 6, 59, 60, 61 and 62. Which flavours get a composed call is this item's to
|
Lands after items 6, 59, 60, 61 and 62. Which flavours get a composed call is this item's to settle;
|
||||||
settle; the CommonMark spec suite also runs against the one reading CommonMark. The README documents HTML as it documents markdown. `htmlToAdf` refuses a value
|
the CommonMark spec suite also runs against the one reading CommonMark. The README documents HTML as
|
||||||
that is not a string as `not-a-string` (`docs/decisions.md` §Which code a cause takes).
|
it documents markdown. `htmlToAdf` refuses a value that is not a string as `not-a-string`
|
||||||
|
(`docs/decisions.md` §Which code a cause takes).
|
||||||
|
|
||||||
### 45. Replace `isAdfDocument` with a reader returning `Result<AdfDocument>`.
|
### 45. Replace `isAdfDocument` with a reader returning `Result<AdfDocument>`.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user