Skip to content

Commit f44e6de

Browse files
committed
feat: upgrade markdown-it-anchor
BREAKING CHANGE: the `markdown.anchor` option is updated. Refer to https://github.com/valeriangalliat/markdown-it-anchor#permalinks for instructions to upgrade your existing `markdown.anchor.permalink` option. **This doesn't affect you if you weren't changing the header permalinks behavior**.
1 parent 3038829 commit f44e6de

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"gray-matter": "^4.0.3",
8080
"lru-cache": "^6.0.0",
8181
"markdown-it": "^12.0.6",
82-
"markdown-it-anchor": "^7.1.0",
82+
"markdown-it-anchor": "^8.1.2",
8383
"markdown-it-container": "^3.0.0",
8484
"markdown-it-emoji": "^2.0.0",
8585
"markdown-it-table-of-contents": "^0.5.2",

src/node/markdown/markdown.ts

+3-8
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,16 @@ import { preWrapperPlugin } from './plugins/preWrapper'
1212
import { linkPlugin } from './plugins/link'
1313
import { extractHeaderPlugin } from './plugins/header'
1414
import { Header } from '../shared'
15+
import anchor, { AnchorOptions } from 'markdown-it-anchor'
1516

1617
const emoji = require('markdown-it-emoji')
17-
const anchor = require('markdown-it-anchor')
1818
const toc = require('markdown-it-table-of-contents')
1919

2020
export interface MarkdownOptions extends MarkdownIt.Options {
2121
lineNumbers?: boolean
2222
config?: (md: MarkdownIt) => void
2323
anchor?: {
24-
permalink?: boolean
25-
permalinkBefore?: boolean
26-
permalinkSymbol?: string
24+
permalink?: AnchorOptions['permalink']
2725
}
2826
// https://github.com/Oktavilla/markdown-it-table-of-contents
2927
toc?: any
@@ -70,10 +68,7 @@ export const createMarkdownRenderer = (
7068
.use(emoji)
7169
.use(anchor, {
7270
slugify,
73-
permalink: true,
74-
permalinkBefore: true,
75-
permalinkSymbol: '#',
76-
permalinkAttrs: () => ({ 'aria-hidden': true }),
71+
permalink: anchor.permalink.ariaHidden({}),
7772
...options.anchor
7873
})
7974
.use(toc, {

yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -3600,10 +3600,10 @@ map-obj@^4.0.0:
36003600
resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-4.2.1.tgz#e4ea399dbc979ae735c83c863dd31bdf364277b7"
36013601
integrity sha512-+WA2/1sPmDj1dlvvJmB5G6JKfY9dpn7EVBUL06+y6PoljPkh+6V1QihwxNkbcGxCRjt2b0F9K0taiCuo7MbdFQ==
36023602

3603-
markdown-it-anchor@^7.1.0:
3604-
version "7.1.0"
3605-
resolved "https://registry.yarnpkg.com/markdown-it-anchor/-/markdown-it-anchor-7.1.0.tgz#30fb21497bf59e83ff4d1ddc052d821962e2489e"
3606-
integrity sha512-loQggrwsIkkP7TOrESvmYkV2ikbQNNKhHcWyqC7/C2CmfHl1tkUizJJU8C5aGgg7J6oXVQJx17gk7i47tNn/lQ==
3603+
markdown-it-anchor@^8.1.2:
3604+
version "8.1.2"
3605+
resolved "https://registry.yarnpkg.com/markdown-it-anchor/-/markdown-it-anchor-8.1.2.tgz#1f26b102005cb7750d5159d06ba3cfa9400ebc3d"
3606+
integrity sha512-9D58TKK4dakqmjcmVuqHoB3ntKBpQJ0Ld38B83aiHJcBD72IZIyPjNtihPA6ayRI5WD33e1W68mArliNLHCprg==
36073607

36083608
markdown-it-container@^3.0.0:
36093609
version "3.0.0"

0 commit comments

Comments
 (0)