Skip to content

Function: fromMarkdown() ​

ts
function fromMarkdown(markdown, options): DocJSON;

Turn Markdown (CommonMark + GitHub tables, strikethrough, autolinks) into a document. Works without a DOM, in the browser and on a server.

Raw HTML in the Markdown never becomes markup: it is kept as plain text. Links with unsafe protocols lose the link and keep their text. Anything the extensions' schema cannot hold degrades to plain content (a fenced code block becomes code-formatted text when there is no code block node, an image becomes its alt text, a horizontal rule is dropped).

Parameters ​

ParameterType
markdownstring
optionsFromMarkdownOptions

Returns ​

DocJSON

Example ​

ts
const { fromMarkdown } = await import('@writeon/markdown')
editor.setContent(fromMarkdown('# Title\n\nHello **world**', { extensions }))