Skip to content

Commit

Permalink
fix(wikilinks): pdf page linking (#1207)
Browse files Browse the repository at this point in the history
  • Loading branch information
saberzero1 authored Jun 14, 2024
1 parent 81d00fc commit 3e14b2b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions quartz/plugins/transformers/ofm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { slug as slugAnchor } from "github-slugger"
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"
Expand Down Expand Up @@ -199,10 +200,9 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options>
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("!") ? "!" : ""

Expand Down

0 comments on commit 3e14b2b

Please sign in to comment.