Using QMarkdown

API

Loading QMarkdown API...

Markdown

This page covers everyday rendering and built-in QMarkdown handling. For Prism customization, global defaults, markdown-it plugin setup, CSS variables, and theme-aware styling, see Advanced.

Importing Markdown

The app extension needs to be installed in order to import markdown (*.md) files. In QMarkdown v4, this is supported through Quasar CLI Vite. To import markdown files, DO NOT place them into your public folder. Put them into your assets folder.

<template>
  <q-markdown :src="ContactUs" show-copy />
</template>

<script>
import { defineComponent } from 'vue'
import ContactUs from '@/assets/contact-us.md'

export default defineComponent({
  setup () {
    return {
      ContactUs
    }
  }
})
</script>

For Prism customization, site-wide defaults, and global markdown-it plugins, see Advanced.

Source and rendering

These properties control how QMarkdown handles its source before and during rendering.

PropertyDescription
srcSupplies the Markdown source when content is not provided through the default slot.
fix-crReplaces escaped \n sequences in src with newline characters before rendering.
no-htmlPrevents HTML tags in the Markdown source from being rendered as HTML.
no-breaksPrevents newline characters from being converted to <br> elements.

QMarkdown Native Handling

QMarkdown has a number of built-in processors to handle inline markdown. These are listed below:

Blockquotes

Blockquotes


Code

PropertyDescription
no-highlightDisables syntax highlighting in code blocks.
no-line-numbersHides line numbers in code blocks.
line-number-altReplaces generated line numbers with a single alternative character.
Code


Copy to clipboard

When copying succeeds, the copy button temporarily changes to the configured done-icon. By default, QMarkdown also shows a notification; use no-notification when the icon is sufficient feedback.

PropertyDescription
show-copyShows the copy-to-clipboard button.
copy-iconSets the icon displayed before the content is copied.
done-iconSets the icon temporarily displayed after the content is copied successfully.
no-copy-tooltipHides the copy button tooltip.
copy-tooltip-textSets the text displayed in the copy button tooltip.
no-notificationPrevents the notification from being shown after the content is copied.
copy-response-textSets the text displayed in the notification after the content is copied.
CopyToClipboard


Containers

Containers


Emphasis

Emphasis


Heading

Use the data event to receive the generated table-of-contents entries when toc is enabled.

PropertyDescription
tocEnables table-of-contents generation and the data event.
toc-startSets the first heading level included in the table of contents and generated heading anchor links.
toc-endSets the last heading level included in the table of contents and generated heading anchor links.
no-heading-anchor-linksPrevents automatic anchor links from being added to headings.
Heading


Horizontal rules

HorizontalRules


Images

Images


Inline rendering

Use the inline prop when markdown needs to live inside existing paragraph or text structure. Inline mode uses markdown-it.renderInline() and a span root, so emphasis, links, and tokens render without generated paragraph wrappers.

Inline


PropertyDescription
no-linkPrevents Markdown links from being converted to anchor elements.
no-linkifyPrevents URL-like text from being converted automatically to links.
linkify-optionsConfigures markdown-it’s automatic link detection.
no-noopenerPrevents QMarkdown from adding rel="noopener" to external links.
no-noreferrerPrevents QMarkdown from adding rel="noreferrer" to external links.

External-link icons are styled with CSS variables. Set --q-markdown-link-external-icon to a CSS image, such as an SVG URL, on the QMarkdown content container:

.custom-markdown-links {
  --q-markdown-link-external-icon: url('/icons/open-in-new.svg');
}

Apply the class with content-class="custom-markdown-links". The icon can also be hidden, resized, or repositioned with the related variables documented under CSS Variables.



Lists

Lists


Tables

Tables


Titles

Titles


Typography

Typography