mirror of
https://github.com/larvit/adf-codec.git
synced 2026-11-18 22:25:44 +01:00
Answer prose round 1: one name per thing in the new docs, the changelog points at MIGRATION's rows, item 82 drops its partial file list
This commit is contained in:
@@ -11,7 +11,7 @@ import { readEntityReference } from '../commonmark/entity-references.ts'
|
||||
|
||||
export type DelimiterRole = 'close' | 'open'
|
||||
|
||||
// A segment's kind: `backslash` text, `bracketed` text inside `[…]` (link text, alt, a directive's content), `bracketed-link-target` a link target inside `[…]`, `none` syntax written as is.
|
||||
// A segment's kind: `backslash` text, `bracketed` text inside `[…]` (link text, alt, a directive's content), `bracketed-link-target` syntax: a link target inside `[…]`, `none` syntax written as is.
|
||||
export type InlineEscaping = 'backslash' | 'bracketed' | 'bracketed-link-target' | 'none'
|
||||
|
||||
export type NodeRange = { first: number; last: number }
|
||||
|
||||
@@ -344,7 +344,7 @@ function holdsImage(pieces: readonly Piece[]): boolean {
|
||||
return pieces.some((piece) => piece.kind === 'image')
|
||||
}
|
||||
|
||||
// An `ownMarks` piece restores its link with its node, so only a link a `nodes` piece spells counts.
|
||||
// Only a link a `nodes` piece spells makes the outer brackets literal; an `ownMarks` node's link is its own, so the own-marks guard in `closeLink` refuses it.
|
||||
function holdsLink(pieces: readonly Piece[]): boolean {
|
||||
return pieces.some((piece) => piece.kind === 'nodes' && marksLink(piece.nodes))
|
||||
}
|
||||
@@ -647,7 +647,7 @@ function markType(character: string, used: number): string {
|
||||
return used === 2 ? 'strong' : 'em'
|
||||
}
|
||||
|
||||
// Nested spellings of one mark (`*(*a*)*`) name it once: a node carries one mark of a type.
|
||||
// `*(*a*)*` builds one `em`: a node holds at most one mark of each type.
|
||||
function applyMark(nodes: readonly Inline[], mark: AdfMark): Inline[] {
|
||||
return nodes.map((node) => {
|
||||
if (!isNode(node)) return node
|
||||
|
||||
@@ -237,7 +237,7 @@ function leafEdges(leaf: AdfNode, previous: AdfNode | undefined, next: AdfNode |
|
||||
return edges
|
||||
}
|
||||
|
||||
// How many of the leaf's marks the edge whitespace keeps, `undefined` where it goes at a line edge.
|
||||
// How many of the leaf's marks the edge whitespace keeps, `undefined` where it drops at a line edge.
|
||||
function edgeDepth(marks: readonly AdfMark[], neighbour: AdfNode | undefined, whitespace: string): number | undefined {
|
||||
if (whitespace === '') return marks.length
|
||||
const lineEdge = neighbour === undefined || neighbour.type === 'hardBreak'
|
||||
|
||||
Reference in New Issue
Block a user