Skip to content

Function: toMarkdown() ​

ts
function toMarkdown(doc, options): string;

Write a document as Markdown (CommonMark + GitHub strikethrough). Works without a DOM. Text is escaped so it reads back as the same text, never as formatting or HTML. Formatting Markdown cannot express (underline) is left out and its text kept; links with unsafe protocols keep only their text.

Parameters ​

ParameterType
docDocJSON
optionsToMarkdownOptions

Returns ​

string

Example ​

ts
const { toMarkdown } = await import('@writeon/markdown')
const markdown = toMarkdown(editor.getJSON(), { extensions })