From f44e6de6239cb3b33204b8fb3236f198b07cec4b Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Thu, 5 Aug 2021 10:26:09 +0200 Subject: [PATCH] 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**. --- package.json | 2 +- src/node/markdown/markdown.ts | 11 +++-------- yarn.lock | 8 ++++---- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 81807166fb85..80448d9ce6cf 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,7 @@ "gray-matter": "^4.0.3", "lru-cache": "^6.0.0", "markdown-it": "^12.0.6", - "markdown-it-anchor": "^7.1.0", + "markdown-it-anchor": "^8.1.2", "markdown-it-container": "^3.0.0", "markdown-it-emoji": "^2.0.0", "markdown-it-table-of-contents": "^0.5.2", diff --git a/src/node/markdown/markdown.ts b/src/node/markdown/markdown.ts index 63ea6d093d9c..f27e5551acdc 100644 --- a/src/node/markdown/markdown.ts +++ b/src/node/markdown/markdown.ts @@ -12,18 +12,16 @@ import { preWrapperPlugin } from './plugins/preWrapper' import { linkPlugin } from './plugins/link' import { extractHeaderPlugin } from './plugins/header' import { Header } from '../shared' +import anchor, { AnchorOptions } from 'markdown-it-anchor' const emoji = require('markdown-it-emoji') -const anchor = require('markdown-it-anchor') const toc = require('markdown-it-table-of-contents') export interface MarkdownOptions extends MarkdownIt.Options { lineNumbers?: boolean config?: (md: MarkdownIt) => void anchor?: { - permalink?: boolean - permalinkBefore?: boolean - permalinkSymbol?: string + permalink?: AnchorOptions['permalink'] } // https://github.com/Oktavilla/markdown-it-table-of-contents toc?: any @@ -70,10 +68,7 @@ export const createMarkdownRenderer = ( .use(emoji) .use(anchor, { slugify, - permalink: true, - permalinkBefore: true, - permalinkSymbol: '#', - permalinkAttrs: () => ({ 'aria-hidden': true }), + permalink: anchor.permalink.ariaHidden({}), ...options.anchor }) .use(toc, { diff --git a/yarn.lock b/yarn.lock index 9ef07bd853e4..56953e5e2aa3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3600,10 +3600,10 @@ map-obj@^4.0.0: resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-4.2.1.tgz#e4ea399dbc979ae735c83c863dd31bdf364277b7" integrity sha512-+WA2/1sPmDj1dlvvJmB5G6JKfY9dpn7EVBUL06+y6PoljPkh+6V1QihwxNkbcGxCRjt2b0F9K0taiCuo7MbdFQ== -markdown-it-anchor@^7.1.0: - version "7.1.0" - resolved "https://registry.yarnpkg.com/markdown-it-anchor/-/markdown-it-anchor-7.1.0.tgz#30fb21497bf59e83ff4d1ddc052d821962e2489e" - integrity sha512-loQggrwsIkkP7TOrESvmYkV2ikbQNNKhHcWyqC7/C2CmfHl1tkUizJJU8C5aGgg7J6oXVQJx17gk7i47tNn/lQ== +markdown-it-anchor@^8.1.2: + version "8.1.2" + resolved "https://registry.yarnpkg.com/markdown-it-anchor/-/markdown-it-anchor-8.1.2.tgz#1f26b102005cb7750d5159d06ba3cfa9400ebc3d" + integrity sha512-9D58TKK4dakqmjcmVuqHoB3ntKBpQJ0Ld38B83aiHJcBD72IZIyPjNtihPA6ayRI5WD33e1W68mArliNLHCprg== markdown-it-container@^3.0.0: version "3.0.0"