From 83269ac26e41f8e81b56e000b4347ee60d4ff84b Mon Sep 17 00:00:00 2001 From: Jacky Zhao Date: Fri, 11 Aug 2023 23:40:06 -0700 Subject: [PATCH] fix scanning for tags in content --- content/features/upcoming features.md | 4 +--- quartz/plugins/transformers/links.ts | 3 ++- quartz/plugins/transformers/ofm.ts | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/content/features/upcoming features.md b/content/features/upcoming features.md index 424f028..718ae17 100644 --- a/content/features/upcoming features.md +++ b/content/features/upcoming features.md @@ -5,10 +5,8 @@ draft: true ## todo - wikilink to anchors in the same document -- folders, tags, and content emit overlapping (e.g. for tags/component) +- blockquote with link in first child broken - 404 using base url -- nested tags showing duplicate - - tag page markdown file for description not being rendered - back button with anchors / popovers + spa is broken - search should be fast for large repos - debounce cfg rebuild on large repos diff --git a/quartz/plugins/transformers/links.ts b/quartz/plugins/transformers/links.ts index 54bcce9..5b15725 100644 --- a/quartz/plugins/transformers/links.ts +++ b/quartz/plugins/transformers/links.ts @@ -86,7 +86,8 @@ export const CrawlLinks: QuartzTransformerPlugin | undefined> = if ( opts.prettyLinks && node.children.length === 1 && - node.children[0].type === "text" + node.children[0].type === "text" && + !node.children[0].value.startsWith("#") ) { node.children[0].value = path.basename(node.children[0].value) } diff --git a/quartz/plugins/transformers/ofm.ts b/quartz/plugins/transformers/ofm.ts index e7438aa..a371efb 100644 --- a/quartz/plugins/transformers/ofm.ts +++ b/quartz/plugins/transformers/ofm.ts @@ -115,7 +115,7 @@ const commentRegex = new RegExp(/%%(.+)%%/, "g") const calloutRegex = new RegExp(/^\[\!(\w+)\]([+-]?)/) // (?:^| ) -> non-capturing group, tag should start be separated by a space or be the start of the line // #(\w+) -> tag itself is # followed by a string of alpha-numeric characters -const tagRegex = new RegExp(/(?:^| )#(\w+)/, "g") +const tagRegex = new RegExp(/(?:^| )#([\w-_\/]+)/, "g") export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin | undefined> = ( userOpts,