Spell 'a text node holding its text and marks alone' once, as isPlainText

This commit is contained in:
2026-10-03 14:44:00 +02:00
parent ade3997cfd
commit a565d49c24
7 changed files with 18 additions and 15 deletions
+2 -6
View File
@@ -1,5 +1,5 @@
import type { AdfNode } from '../adf/document.ts'
import { identicalMarks, nodeMarks } from '../adf/document.ts'
import { identicalMarks, isPlainText, nodeMarks } from '../adf/document.ts'
import { spellInlineLeafDirective } from './directive-syntax.ts'
export const textBreakName = 'textBreak'
@@ -8,9 +8,5 @@ export const textBreakSpelling = spellInlineLeafDirective(textBreakName, '')
// Whether CommonMark reads the pair back as one text node, where neither rides the carry (spec/flavour.md, Inline nodes).
export function readsAsOne(previous: AdfNode, node: AdfNode): boolean {
return spelledAsText(previous) && spelledAsText(node) && identicalMarks(nodeMarks(previous), nodeMarks(node))
}
function spelledAsText(node: AdfNode): boolean {
return node.type === 'text' && node.attrs === undefined && node.content === undefined && node.marks?.length !== 0
return isPlainText(previous) && isPlainText(node) && identicalMarks(nodeMarks(previous), nodeMarks(node))
}