Read the emphasis, the links and the lone image CommonMark spells #34
+2
-1
@@ -245,7 +245,8 @@ The moon, at night.
|
|||||||
|
|
||||||
**The CommonMark image.** A paragraph whose entire inline content is one image `` is
|
**The CommonMark image.** A paragraph whose entire inline content is one image `` is
|
||||||
a `mediaSingle` with attrs exactly `{"layout":"center"}` holding an `external` `media` — `url`
|
a `mediaSingle` with attrs exactly `{"layout":"center"}` holding an `external` `media` — `url`
|
||||||
from the destination, `alt` the description's plain-text content when non-empty. `adfToMarkdown`
|
from the destination, `alt` the description's plain-text content when non-empty — a link or image
|
||||||
|
inside it contributing its own text, and a break of either kind a space. `adfToMarkdown`
|
||||||
emits the image form for exactly that shape — those attrs and no others, no marks on either
|
emits the image form for exactly that shape — those attrs and no others, no marks on either
|
||||||
node, no caption, and a `media` carrying nothing beyond `alt`, `type` and `url` — and only where
|
node, no caption, and a `media` carrying nothing beyond `alt`, `type` and `url` — and only where
|
||||||
CommonMark spells the pair: a destination or a description the image form cannot hold, an empty
|
CommonMark spells the pair: a destination or a description the image form cannot hold, an empty
|
||||||
|
|||||||
@@ -250,7 +250,6 @@ function closeImage(scan: Scan, at: number, inner: readonly Piece[], definition:
|
|||||||
return success(null)
|
return success(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
// spec/flavour.md: the description's plain-text content, where a break of either kind reads as a space.
|
|
||||||
function imageAlt(inner: readonly Piece[]): string {
|
function imageAlt(inner: readonly Piece[]): string {
|
||||||
return resolveNodes(inner)
|
return resolveNodes(inner)
|
||||||
.map((node) => (node.type === 'hardBreak' ? ' ' : (node.text ?? '')))
|
.map((node) => (node.type === 'hardBreak' ? ' ' : (node.text ?? '')))
|
||||||
@@ -268,11 +267,17 @@ function resolveNodes(pieces: readonly Piece[]): AdfNode[] {
|
|||||||
|
|
||||||
// Only `imageAlt` reaches the image arm: everywhere else an image amid other content is refused first.
|
// Only `imageAlt` reaches the image arm: everywhere else an image amid other content is refused first.
|
||||||
function pieceNodes(piece: Piece): AdfNode[] {
|
function pieceNodes(piece: Piece): AdfNode[] {
|
||||||
if (piece.kind === 'nodes') return piece.nodes
|
switch (piece.kind) {
|
||||||
if (piece.kind === 'open') return bracketNodes(piece)
|
case 'image':
|
||||||
if (piece.kind === 'image') return piece.alt === '' ? [] : [{ text: piece.alt, type: 'text' }]
|
return piece.alt === '' ? [] : [{ text: piece.alt, type: 'text' }]
|
||||||
|
case 'nodes':
|
||||||
|
return piece.nodes
|
||||||
|
case 'open':
|
||||||
|
return bracketNodes(piece)
|
||||||
|
case 'run':
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function delimiterRuns(pieces: readonly Piece[]): Run[] {
|
function delimiterRuns(pieces: readonly Piece[]): Run[] {
|
||||||
const runs: Run[] = []
|
const runs: Run[] = []
|
||||||
|
|||||||
Reference in New Issue
Block a user