Skip to content
QuireKit Markdown
Developer docs
Preview · unreleased
Extensions and renderingView Markdown ↗

Custom components

Replace links, images or code-block presentation while retaining Markdown parsing.

Suppose every Markdown link should have an arrow, while body text, lists and headings keep their default appearance. Supply a Vue component for components.a; the source and Markdown parser stay the same.

The example's reading/link.vue receives a validated href, displays its default slot and adds an arrow. Keeping an ordinary <a> retains the browser's link and keyboard behavior.

Import the link component beside the reader and supply it as components.a:

vue

a names the semantic tag produced for Markdown links. Tags without a replacement keep their default output. In the example, body text remains unchanged and the link gains an arrow. reading/components.vue assembles the reader; reading/link.vue defines the link itself.

Preparing the example…

Data received by a component

ReplacementData supplied
aValidated href and a slot containing link text
imgValidated image destination and other semantic attributes
preExact code and language, suitable for a code viewer
h2, table and othersCorresponding semantic attributes and default children

Explicitly declare node?: MarkdownNodeInfo if you need source positions. It contains type/from/to with UTF-16 offsets in the current normalized text. Do not forward this object as a DOM attribute.

Changing components, locale, HTML policy or transport status does not reparse source. Component maps and renderNode callbacks are trusted application code and own any additional behavior. They should not execute expressions supplied by Markdown.

QuireKit Markdown · QuireKitStreaming Markdown · @quirekit/incremark · MIT