Skip to content

Type Editor


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

ts
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

ParameterTypeDescription
nodesRecord<string, NodeSerializerFunc>A record mapping node type names to their serializer functions
marksRecord<string, MarkSerializerSpec>A record mapping mark type names to their serializer specifications
options?MarkdownSerializerOptionsOptional configuration for the serializer behavior

Returns

MarkdownSerializer

Properties

PropertyModifierTypeDefined in
_nodesreadonlyRecord<string, NodeSerializerFunc>to-markdown/MarkdownSerializer.ts:14

Accessors

marks

Get Signature

ts
get marks(): Record<string, MarkSerializerSpec>;

Defined in: to-markdown/MarkdownSerializer.ts:41

Returns

Record<string, MarkSerializerSpec>


nodes

Get Signature

ts
get nodes(): Record<string, NodeSerializerFunc>;

Defined in: to-markdown/MarkdownSerializer.ts:37

Returns

Record<string, NodeSerializerFunc>


options

Get Signature

ts
get options(): MarkdownSerializerOptions;

Defined in: to-markdown/MarkdownSerializer.ts:45

Returns

MarkdownSerializerOptions

Methods

serialize()

ts
serialize(content, tightLists?): string;

Defined in: to-markdown/MarkdownSerializer.ts:57

Serialize the content of the given node to CommonMark.

Parameters

ParameterTypeDefault valueDescription
contentNode_2undefinedThe ProseMirror node to serialize to Markdown
tightListsbooleanfalseWhether to render lists in tight style (no blank lines between items)

Returns

string

The serialized Markdown string