Skip to content

Commit

Permalink
feat: use markdown-it-attrs for markdown-it plugins (#393)
Browse files Browse the repository at this point in the history
  • Loading branch information
QC-L committed Sep 16, 2021
1 parent 182b59f commit 610e9b7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"lru-cache": "^6.0.0",
"markdown-it": "^12.0.6",
"markdown-it-anchor": "^8.1.2",
"markdown-it-attrs": "^4.0.0",
"markdown-it-container": "^3.0.0",
"markdown-it-emoji": "^2.0.0",
"markdown-it-table-of-contents": "^0.5.2",
Expand Down
12 changes: 12 additions & 0 deletions src/node/markdown/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { extractHeaderPlugin } from './plugins/header'
import { Header } from '../shared'
import anchor, { AnchorOptions } from 'markdown-it-anchor'

const attrs = require('markdown-it-attrs')
const emoji = require('markdown-it-emoji')
const toc = require('markdown-it-table-of-contents')

Expand All @@ -23,6 +24,11 @@ export interface MarkdownOptions extends MarkdownIt.Options {
anchor?: {
permalink?: AnchorOptions['permalink']
}
attrs?: {
leftDelimiter?: string
rightDelimiter?: string
allowedAttributes?: string[]
}
// https://github.com/Oktavilla/markdown-it-table-of-contents
toc?: any
externalLinks?: Record<string, string>
Expand Down Expand Up @@ -64,6 +70,12 @@ export const createMarkdownRenderer = (
...options.externalLinks
})

.use(attrs, {
leftDelimiter: '{',
rightDelimiter: '}',
allowedAttributes: [],
...options.attrs
})
// 3rd party plugins
.use(anchor, {
slugify,
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
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:
version "3.0.0"
resolved "https://registry.yarnpkg.com/markdown-it-container/-/markdown-it-container-3.0.0.tgz#1d19b06040a020f9a827577bb7dbf67aa5de9a5b"
Expand Down

0 comments on commit 610e9b7

Please sign in to comment.