Make markdownToAdf(adfToMarkdown(doc)) deep-equal doc: textBreak, empty keys, -0, typed carry fences, code blocks of several text nodes
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import type { AdfNode } from '../adf/document.ts'
|
||||
import { identicalMarks } from '../adf/document.ts'
|
||||
import { spellInlineLeafDirective } from './directive-syntax.ts'
|
||||
|
||||
export const textBreakName = 'textBreak'
|
||||
|
||||
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(previous, node)
|
||||
}
|
||||
|
||||
function spelledAsText(node: AdfNode): boolean {
|
||||
return node.type === 'text' && node.attrs === undefined && node.content === undefined && node.marks?.length !== 0
|
||||
}
|
||||
Reference in New Issue
Block a user