feat: use `markdown-it-attrs` for markdown-it plugins (#393)

pull/395/head
QiChang Li 3 years ago committed by GitHub
parent 182b59fc83
commit 610e9b7111
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -80,6 +80,7 @@
"lru-cache": "^6.0.0", "lru-cache": "^6.0.0",
"markdown-it": "^12.0.6", "markdown-it": "^12.0.6",
"markdown-it-anchor": "^8.1.2", "markdown-it-anchor": "^8.1.2",
"markdown-it-attrs": "^4.0.0",
"markdown-it-container": "^3.0.0", "markdown-it-container": "^3.0.0",
"markdown-it-emoji": "^2.0.0", "markdown-it-emoji": "^2.0.0",
"markdown-it-table-of-contents": "^0.5.2", "markdown-it-table-of-contents": "^0.5.2",

@ -14,6 +14,7 @@ import { extractHeaderPlugin } from './plugins/header'
import { Header } from '../shared' import { Header } from '../shared'
import anchor, { AnchorOptions } from 'markdown-it-anchor' import anchor, { AnchorOptions } from 'markdown-it-anchor'
const attrs = require('markdown-it-attrs')
const emoji = require('markdown-it-emoji') const emoji = require('markdown-it-emoji')
const toc = require('markdown-it-table-of-contents') const toc = require('markdown-it-table-of-contents')
@ -23,6 +24,11 @@ export interface MarkdownOptions extends MarkdownIt.Options {
anchor?: { anchor?: {
permalink?: AnchorOptions['permalink'] permalink?: AnchorOptions['permalink']
} }
attrs?: {
leftDelimiter?: string
rightDelimiter?: string
allowedAttributes?: string[]
}
// https://github.com/Oktavilla/markdown-it-table-of-contents // https://github.com/Oktavilla/markdown-it-table-of-contents
toc?: any toc?: any
externalLinks?: Record<string, string> externalLinks?: Record<string, string>
@ -64,6 +70,12 @@ export const createMarkdownRenderer = (
...options.externalLinks ...options.externalLinks
}) })
.use(attrs, {
leftDelimiter: '{',
rightDelimiter: '}',
allowedAttributes: [],
...options.attrs
})
// 3rd party plugins // 3rd party plugins
.use(anchor, { .use(anchor, {
slugify, slugify,

@ -3570,6 +3570,11 @@ markdown-it-anchor@^8.1.2:
resolved "https://registry.yarnpkg.com/markdown-it-anchor/-/markdown-it-anchor-8.1.2.tgz#1f26b102005cb7750d5159d06ba3cfa9400ebc3d" resolved "https://registry.yarnpkg.com/markdown-it-anchor/-/markdown-it-anchor-8.1.2.tgz#1f26b102005cb7750d5159d06ba3cfa9400ebc3d"
integrity sha512-9D58TKK4dakqmjcmVuqHoB3ntKBpQJ0Ld38B83aiHJcBD72IZIyPjNtihPA6ayRI5WD33e1W68mArliNLHCprg== integrity sha512-9D58TKK4dakqmjcmVuqHoB3ntKBpQJ0Ld38B83aiHJcBD72IZIyPjNtihPA6ayRI5WD33e1W68mArliNLHCprg==
markdown-it-attrs@^4.0.0:
version "4.0.0"
resolved "https://registry.npmjs.org/markdown-it-attrs/-/markdown-it-attrs-4.0.0.tgz#eadae3ea0c7d17c5e83b98a4ec95a47f4e4960f5"
integrity sha512-uLjtdCmhhmL3BuZsReYkFxk74qKjj5ahe34teBpOCJ4hYZZl7/ftLyXWLowngC2moRkbLEvKwN/7TMwbhbHE/A==
markdown-it-container@^3.0.0: markdown-it-container@^3.0.0:
version "3.0.0" version "3.0.0"
resolved "https://registry.yarnpkg.com/markdown-it-container/-/markdown-it-container-3.0.0.tgz#1d19b06040a020f9a827577bb7dbf67aa5de9a5b" resolved "https://registry.yarnpkg.com/markdown-it-container/-/markdown-it-container-3.0.0.tgz#1d19b06040a020f9a827577bb7dbf67aa5de9a5b"

Loading…
Cancel
Save