Skip to content

MarkdownConfiguration

Type of the configuration object used to configure the markdown processor.

This is the resolved configuration the markdown handler is constructed with.

Shared properties

These apply regardless of the selected backend.

components? ComponentInfo[] | undefinedtypes/handlers/Markdown.ts:289

An array of objects describing components that should receive special consideration by SvelTeX.

directives? DirectiveEscapeSettings | undefinedtypes/handlers/Markdown.ts:294

Settings related to markdown directives.

prefersInline? ((tag: string) => boolean) | undefinedtypes/handlers/Markdown.ts:283

Given the tag name of a containing block-level element (e.g. 'div', 'section', a verbatim environment's tag), decide whether SvelTeX should parse the element's content as a single inline run (true) or as a block sequence (false). The default — () => true — keeps short prose inside common wrappers from being wrapped in a stray <p>.

Voided when strict is true.

Default () => true

See: https://sveltex.dev/docs/implementation/markdown

strict? boolean | undefinedtypes/handlers/Markdown.ts:264

By default, SvelTeX makes some adjustments to some kinds of markup that would, if CommonMark were complied with strictly, yield unexpected or even invalid HTML output. If you want to disable these adjustments and comply more strictly with CommonMark for these cases, set this property to true.

Default false // recommended

Setting this property to true will void the prefersInline property.

See: https://sveltex.dev/docs/implementation/markdown

transformers? Transformerstypes/handlers/Markdown.ts:245

Transformers to apply to

  • the content about to be passed to the markdown processor, or to
  • the output produced by the markdown processor.

Note that, in either case, code blocks, math content, TeX content, and the frontmatter will have been escaped to an UUIDv4 string before the transformers are applied.

post?Transformer<Frontmatter & WithOriginal> | Transformer<Frontmatter & With…types/handlers/Handler.ts:58-62

Transformations to apply to the output produced by the backend.

Each transformation may be a function (str: string, opts: Options) => string, or a 2-tuple [string | RegExp, string]. The transformers are called in the order they are listed on the output of the previous transformation (or on the original content if it's the first transformation). Each transformation transformation is applied as follows, depending on its type:

  • 2-tuple: transformed = content.replaceAll(...transformation)
  • Function: transformed = transformation(content, opts)
pre?Transformer<Frontmatter> | Transformer<Frontmatter>[] | null | undefinedtypes/handlers/Handler.ts:44

Transformations to apply to the content before passing it to the backend for processing.

Each transformation may be a function (str: string, opts: Options) => string, or a 2-tuple [string | RegExp, string]. The transformers are called in the order they are listed on the output of the previous transformation (or on the original content if it's the first transformation). Each transformation transformation is applied as follows, depending on its type:

  • 2-tuple: transformed = content.replaceAll(...transformation)
  • Function: transformed = transformation(content, opts)

marked backend

Options available when the backend is marked.

extensions? MarkedExtension<string, string>[]types/handlers/Markdown.ts:104

Extensions to use with the marked processor.

See: https://marked.js.org/using_advanced#extensions

options? MarkedOptions<string, string>types/handlers/Markdown.ts:97

Options to pass to the marked processor.

See: https://marked.js.org/using_advanced#options

markdown-it backend

Options available when the backend is markdown-it.

extensions? (PluginSimple | [PluginWithOptions<any>, Record<string, unknown>] | [Plu…types/handlers/Markdown.ts:81-88

options? { breaks?: boolean | undefined | undefined; xhtmlOut?: boolean | undefin…types/handlers/Markdown.ts:76-79

Options to pass to the markdown-it processor.

The highlight, html, and langPrefix options are not supported here, since they relate to features that are dealt with by the Sveltex instance's code handler, instead of its markdown handler.

See: https://github.com/markdown-it/markdown-it

micromark backend

Options available when the backend is micromark.

options? Omit<Options, "allowDangerousHtml"> | undefinedtypes/handlers/Markdown.ts:131-133

Options to pass to the micromark processor.

Default

ts
{
    extensions: [],
    htmlExtensions: [],
    allowDangerousProtocol: false,
}

The allowDangerousHtml option is not supported here, since SvelTeX needs it to be true to work properly.

The extensions option passed to the micromark processor will always be a (nonempty) array with a custom extension in its first position (i.e., at index 0) that disables indented code blocks and autolinks. The array of extensions passed to the extensions property here in the SvelTeX configuration will merely be appended to this array.

unified backend

Options available when the backend is unified.

rehypePlugins? PluggableList | undefinedtypes/handlers/Markdown.ts:165

Plugins to use with the rehype processor.

These will be used after remark-rehype but before rehype-stringify.

Default []

See: https://unifiedjs.com/explore/keyword/rehype/

rehypeStringifyOptions? Omit<Options, "allowDangerousHtml"> | undefinedtypes/handlers/Markdown.ts:218-223

Options to pass to the rehype-stringify unified plugin.

Default {}

The allowDangerousHtml option is not supported here, since SvelTeX always needs it to be true to work properly.

remarkPlugins? PluggableList | undefinedtypes/handlers/Markdown.ts:150

Plugins to use with the remark processor.

These will be used after remark-parse but before remark-rehype.

Default []

See: https://unifiedjs.com/explore/keyword/remark/

remarkRehypeOptions? Omit<Options, "allowDangerousHtml"> | undefinedtypes/handlers/Markdown.ts:198-203

Options to pass to the remark-rehype unified plugin.

Default {}

The allowDangerousHtml option is not supported here, since SvelTeX always needs it to be true to work properly.

retextPlugins? PluggableList | undefinedtypes/handlers/Markdown.ts:183

retext plugins to use with remark-retext to check the Latin-script natural language content of the markup. Note that these plugins will not be able to transform the content in any way, but rather just check it and possibly log warnings.

Default []

See: https://unifiedjs.com/explore/keyword/retext/

custom backend

Options available when the backend is custom.

process (content: string, options: MarkdownProcessOptions, handler: MarkdownHandtypes/handlers/Markdown.ts:227