MCPcopy Create free account
hub / github.com/editablejs/editable / transform

Function transform

packages/serializer/src/markdown.ts:50–62  ·  view source on GitHub ↗
(node: Node, options: MarkdownSerializerOptions = {})

Source from the content-addressed store, hash-verified

48
49export const MarkdownSerializer = {
50 transform(node: Node, options: MarkdownSerializerOptions = {}): Content[] {
51 if (Text.isText(node)) return [{ type: 'text', value: node.text }]
52 const tChildren = () => node.children.map(child => this.transform(child, options)).flat()
53 if (Editor.isEditor(node)) return tChildren()
54 const { type = 'paragraph' } = node
55
56 switch (type) {
57 case 'paragraph':
58 return [{ type: 'paragraph', children: tChildren() as Paragraph['children'] }]
59 default:
60 return [{ type: 'html', value: HTMLSerializer.transform(node) }]
61 }
62 },
63
64 with<T = MarkdownSerializerOptions>(transform: MarkdownSerializerWithTransform<T>, options: T) {
65 const { transform: t } = this

Callers 1

withFunction · 0.70

Calls 1

tChildrenFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…