From 3e14b2b89b60610eb3ae57603a451f1435ea45c0 Mon Sep 17 00:00:00 2001
From: Emile Bangma <ewjbangma@hotmail.com>
Date: Fri, 14 Jun 2024 16:17:46 +0000
Subject: [PATCH] fix(wikilinks): pdf page linking (#1207)
---
quartz/plugins/transformers/ofm.ts | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/quartz/plugins/transformers/ofm.ts b/quartz/plugins/transformers/ofm.ts
index 708fe5e..925d21e 100644
--- a/quartz/plugins/transformers/ofm.ts
+++ b/quartz/plugins/transformers/ofm.ts
@@ -6,6 +6,7 @@
import rehypeRaw from "rehype-raw"
import { SKIP, visit } from "unist-util-visit"
import path from "path"
+import { splitAnchor } from "../../util/path"
import { JSResource } from "../../util/resources"
// @ts-ignore
import calloutScript from "../../components/scripts/callout.inline.ts"
@@ -199,10 +200,9 @@
src = src.replace(wikilinkRegex, (value, ...capture) => {
const [rawFp, rawHeader, rawAlias]: (string | undefined)[] = capture
- const fp = rawFp ?? ""
- const anchor = rawHeader?.trim().replace(/^#+/, "")
+ const [fp, anchor] = splitAnchor(`${rawFp ?? ""}${rawHeader ?? ""}`)
const blockRef = Boolean(anchor?.startsWith("^")) ? "^" : ""
- const displayAnchor = anchor ? `#${blockRef}${slugAnchor(anchor)}` : ""
+ const displayAnchor = anchor ? `#${blockRef}${anchor.trim().replace(/^#+/, "")}` : ""
const displayAlias = rawAlias ?? rawHeader?.replace("#", "|") ?? ""
const embedDisplay = value.startsWith("!") ? "!" : ""
--
Gitblit v1.10.0