2024-12-02 17:25:10 +08:00
|
|
|
|
import md, { type Options } from 'markdown-it'
|
|
|
|
|
// @ts-ignore
|
2024-12-04 09:45:55 +08:00
|
|
|
|
import mm from 'markdown-it-mathjax3'
|
2024-12-02 17:25:10 +08:00
|
|
|
|
const options: Options = {
|
|
|
|
|
// Enable HTML tags in source
|
|
|
|
|
html: true,
|
|
|
|
|
|
|
|
|
|
// Use '/' to close single tags (<br />).
|
|
|
|
|
// This is only for full CommonMark compatibility.
|
|
|
|
|
xhtmlOut: true,
|
|
|
|
|
|
|
|
|
|
// Convert '\n' in paragraphs into <br>
|
|
|
|
|
breaks: true,
|
|
|
|
|
|
|
|
|
|
// CSS language prefix for fenced blocks. Can be
|
|
|
|
|
// useful for external highlighters.
|
|
|
|
|
langPrefix: 'language-',
|
|
|
|
|
|
|
|
|
|
// Autoconvert URL-like text to links
|
|
|
|
|
linkify: true,
|
|
|
|
|
|
|
|
|
|
// Enable some language-neutral replacement + quotes beautification
|
|
|
|
|
// For the full list of replacements, see https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/replacements.mjs
|
|
|
|
|
typographer: true,
|
|
|
|
|
|
|
|
|
|
// Double + single quotes replacement pairs, when typographer enabled,
|
|
|
|
|
// and smartquotes on. Could be either a String or an Array.
|
|
|
|
|
//
|
|
|
|
|
// For example, you can use '«»„“' for Russian, '„“‚‘' for German,
|
|
|
|
|
// and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
|
|
|
|
|
quotes: '“”‘’',
|
|
|
|
|
|
|
|
|
|
// Highlighter function. Should return escaped HTML,
|
|
|
|
|
// or '' if the source string is not changed and should be escaped externally.
|
|
|
|
|
// If result starts with <pre... internal wrapper is skipped.
|
|
|
|
|
highlight: function (/*str, lang*/) { return ''; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default defineNuxtPlugin(() => {
|
2024-12-04 09:45:55 +08:00
|
|
|
|
const render = md(options)
|
|
|
|
|
.use(mm, {
|
|
|
|
|
})
|
2024-12-02 17:25:10 +08:00
|
|
|
|
return {
|
|
|
|
|
provide: {
|
|
|
|
|
mdRender: render
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|