From 78f99afef066571fb035223e4ec1a059b828e07e Mon Sep 17 00:00:00 2001 From: James Brumond Date: Thu, 18 May 2023 21:38:05 -0700 Subject: [PATCH] do not render anchors to nowhere --- src/renderer.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/renderer.ts b/src/renderer.ts index 0042f05..b069569 100644 --- a/src/renderer.ts +++ b/src/renderer.ts @@ -30,16 +30,14 @@ export function create_renderer(opts: MarkdownOptions) { function heading(renderer: marked.Renderer, opts: MarkdownOptions) { return function(orig_text: string, level: 1 | 2 | 3 | 4 | 5 | 6, raw: string) { let { text, id, html_attrs } = parse_attributes(raw); + if (id) { + text += `\n` + + `\n\t\t${icons.link}` + + `\n\t\tSection titled ${text}` + + `\n\t`; + } - return ` - - ${text} - - ${icons.link} - Section titled ${text} - - -`; + return `\n\n\t${text}\n`; }; }