From 2d0a7007c49c2de361ac6f9188fe417083cf8ae7 Mon Sep 17 00:00:00 2001 From: VadimMakishvili Date: Fri, 7 Jul 2023 17:07:59 +0300 Subject: [PATCH] fix(heading): Double text in mini-toc --- src/transform/headings.ts | 2 +- src/transform/plugins/anchors/index.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/transform/headings.ts b/src/transform/headings.ts index 6702df97..b0c22fc6 100644 --- a/src/transform/headings.ts +++ b/src/transform/headings.ts @@ -4,7 +4,7 @@ import {Heading} from './typings'; function getTitle(token: Token) { return ( token.children?.reduce((acc, tok) => { - if (tok.type === 'text' || tok.type === 'code_inline') { + if ((tok.type === 'text' && !tok.meta?.hidden) || tok.type === 'code_inline') { return acc + tok.content; } diff --git a/src/transform/plugins/anchors/index.ts b/src/transform/plugins/anchors/index.ts index a405961d..96c4647c 100644 --- a/src/transform/plugins/anchors/index.ts +++ b/src/transform/plugins/anchors/index.ts @@ -26,6 +26,7 @@ function createLinkTokens(state: StateCore, id: string, title: string, setId = f const spanClose = new state.Token('span_close', 'span', -1); spanOpen.attrSet('class', 'visually-hidden'); spanText.content = title; + spanText.meta = {hidden: true}; return [open, spanOpen, spanText, spanClose, close]; }