Type Editor / @type-editor/markdown / to-markdown/MarkdownSerializer / MarkdownSerializer
Class: MarkdownSerializer
Defined in: to-markdown/MarkdownSerializer.ts:12
A specification for serializing a ProseMirror document as Markdown/CommonMark text.
Constructors
Constructor
new MarkdownSerializer(
nodes,
marks,
options?): MarkdownSerializer;Defined in: to-markdown/MarkdownSerializer.ts:28
Construct a serializer with the given configuration. The nodes object should map node names in a given schema to functions that take a serializer state and such a node, and serialize the node.
Parameters
| Parameter | Type | Description |
|---|---|---|
nodes | Record<string, NodeSerializerFunc> | A record mapping node type names to their serializer functions |
marks | Record<string, MarkSerializerSpec> | A record mapping mark type names to their serializer specifications |
options? | MarkdownSerializerOptions | Optional configuration for the serializer behavior |
Returns
MarkdownSerializer
Properties
| Property | Modifier | Type | Defined in |
|---|---|---|---|
_nodes | readonly | Record<string, NodeSerializerFunc> | to-markdown/MarkdownSerializer.ts:14 |
Accessors
marks
Get Signature
get marks(): Record<string, MarkSerializerSpec>;Defined in: to-markdown/MarkdownSerializer.ts:41
Returns
Record<string, MarkSerializerSpec>
nodes
Get Signature
get nodes(): Record<string, NodeSerializerFunc>;Defined in: to-markdown/MarkdownSerializer.ts:37
Returns
Record<string, NodeSerializerFunc>
options
Get Signature
get options(): MarkdownSerializerOptions;Defined in: to-markdown/MarkdownSerializer.ts:45
Returns
Methods
serialize()
serialize(content, tightLists?): string;Defined in: to-markdown/MarkdownSerializer.ts:57
Serialize the content of the given node to CommonMark.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
content | Node_2 | undefined | The ProseMirror node to serialize to Markdown |
tightLists | boolean | false | Whether to render lists in tight style (no blank lines between items) |
Returns
string
The serialized Markdown string