comrak
Version:
Comrak is an efficient, extensible, and highly configurable Markdown parser and renderer, written in Rust and compiled to WebAssembly. Portable and agnostic, it works seamlessly in any WebAssembly-friendly JS runtime.
89 lines (88 loc) • 2.48 kB
JavaScript
import { cloneDeep } from "./_internal.js";
/**
* Default options for the various parsing, rendering, and conversion functions
* in the Comrak library.
*
* @category Options
*/
export const defaultOptions = {
extension: {
autolink: false,
descriptionLists: false,
footnotes: false,
inlineFootnotes: false,
frontMatterDelimiter: null,
headerIDs: null,
strikethrough: false,
superscript: false,
table: false,
tagfilter: false,
tasklist: false,
multilineBlockQuotes: false,
alerts: false,
mathDollars: false,
mathCode: false,
wikilinksTitleBeforePipe: false,
wikilinksTitleAfterPipe: false,
underline: false,
subscript: false,
spoiler: false,
shortcodes: false,
greentext: false,
linkURLRewriter: null,
imageURLRewriter: null,
cjkFriendlyEmphasis: false,
subtext: false,
highlight: false,
},
parse: {
defaultInfoString: null,
smart: false,
relaxedTasklistMatching: false,
tasklistInTable: false,
relaxedAutolinks: false,
ignoreSetext: false,
brokenLinkCallback: null,
leaveFootnoteDefinitions: false,
escapedCharSpans: false,
},
render: {
escape: false,
githubPreLang: false,
hardbreaks: false,
unsafe: false,
width: 0,
fullInfoString: false,
listStyle: "dash",
sourcepos: false,
escapedCharSpans: false,
ignoreEmptyLinks: false,
gfmQuirks: false,
preferFenced: false,
figureWithCaption: false,
tasklistClasses: false,
olWidth: 0,
experimentalMinimizeCommonmark: false,
},
plugins: {
render: {
codefenceSyntaxHighlighter: null,
headingAdapter: null,
},
},
};
/**
* The `Options` object contains the default options for Comrak, as well as a
* `default` helper method to obtain a fresh copy of those defaults.
*
* This is useful when constructing new options objects to pass to Comrak's
* parsing, rendering, and conversion functions, as it ensures that all fields
* are set and avoids any issues with mutation-related side-effects.
*
* @category Options
* @tags defaults
*/
export const Options = {
__proto__: defaultOptions,
default: () => cloneDeep(defaultOptions),
};