Skip to content

Commit 610e9b7

Browse files
authored
feat: use markdown-it-attrs for markdown-it plugins (#393)
1 parent 182b59f commit 610e9b7

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
"lru-cache": "^6.0.0",
8181
"markdown-it": "^12.0.6",
8282
"markdown-it-anchor": "^8.1.2",
83+
"markdown-it-attrs": "^4.0.0",
8384
"markdown-it-container": "^3.0.0",
8485
"markdown-it-emoji": "^2.0.0",
8586
"markdown-it-table-of-contents": "^0.5.2",

src/node/markdown/markdown.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { extractHeaderPlugin } from './plugins/header'
1414
import { Header } from '../shared'
1515
import anchor, { AnchorOptions } from 'markdown-it-anchor'
1616

17+
const attrs = require('markdown-it-attrs')
1718
const emoji = require('markdown-it-emoji')
1819
const toc = require('markdown-it-table-of-contents')
1920

@@ -23,6 +24,11 @@ export interface MarkdownOptions extends MarkdownIt.Options {
2324
anchor?: {
2425
permalink?: AnchorOptions['permalink']
2526
}
27+
attrs?: {
28+
leftDelimiter?: string
29+
rightDelimiter?: string
30+
allowedAttributes?: string[]
31+
}
2632
// https://github.com/Oktavilla/markdown-it-table-of-contents
2733
toc?: any
2834
externalLinks?: Record<string, string>
@@ -64,6 +70,12 @@ export const createMarkdownRenderer = (
6470
...options.externalLinks
6571
})
6672

73+
.use(attrs, {
74+
leftDelimiter: '{',
75+
rightDelimiter: '}',
76+
allowedAttributes: [],
77+
...options.attrs
78+
})
6779
// 3rd party plugins
6880
.use(anchor, {
6981
slugify,

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3570,6 +3570,11 @@ markdown-it-anchor@^8.1.2:
35703570
resolved "https://registry.yarnpkg.com/markdown-it-anchor/-/markdown-it-anchor-8.1.2.tgz#1f26b102005cb7750d5159d06ba3cfa9400ebc3d"
35713571
integrity sha512-9D58TKK4dakqmjcmVuqHoB3ntKBpQJ0Ld38B83aiHJcBD72IZIyPjNtihPA6ayRI5WD33e1W68mArliNLHCprg==
35723572

3573+
markdown-it-attrs@^4.0.0:
3574+
version "4.0.0"
3575+
resolved "https://registry.npmjs.org/markdown-it-attrs/-/markdown-it-attrs-4.0.0.tgz#eadae3ea0c7d17c5e83b98a4ec95a47f4e4960f5"
3576+
integrity sha512-uLjtdCmhhmL3BuZsReYkFxk74qKjj5ahe34teBpOCJ4hYZZl7/ftLyXWLowngC2moRkbLEvKwN/7TMwbhbHE/A==
3577+
35733578
markdown-it-container@^3.0.0:
35743579
version "3.0.0"
35753580
resolved "https://registry.yarnpkg.com/markdown-it-container/-/markdown-it-container-3.0.0.tgz#1d19b06040a020f9a827577bb7dbf67aa5de9a5b"

0 commit comments

Comments
 (0)