The Trans Directory
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: wikilinks should allow external links (closes #639)

+9 -1
+9 -1
quartz/plugins/transformers/ofm.ts
··· 105 105 return calloutMapping[callout] ?? "note" 106 106 } 107 107 108 + export const externalLinkRegex = /^https?:\/\//i 109 + 108 110 // !? -> optional embedding 109 111 // \[\[ -> open brace 110 112 // ([^\[\]\|\#]+) -> one or more non-special characters ([,],|, or #) (name) ··· 158 160 } 159 161 160 162 src = src.replaceAll(wikilinkRegex, (value, ...capture) => { 161 - const [rawFp, rawHeader, rawAlias] = capture 163 + const [rawFp, rawHeader, rawAlias]: (string | undefined)[] = capture 164 + 162 165 const fp = rawFp ?? "" 163 166 const anchor = rawHeader?.trim().replace(/^#+/, "") 164 167 const blockRef = Boolean(anchor?.startsWith("^")) ? "^" : "" 165 168 const displayAnchor = anchor ? `#${blockRef}${slugAnchor(anchor)}` : "" 166 169 const displayAlias = rawAlias ?? rawHeader?.replace("#", "|") ?? "" 167 170 const embedDisplay = value.startsWith("!") ? "!" : "" 171 + 172 + if (rawFp?.match(externalLinkRegex)) { 173 + return `${embedDisplay}[${displayAlias.replace(/^\|/, "")}](${rawFp})` 174 + } 175 + 168 176 return `${embedDisplay}[[${fp}${displayAnchor}${displayAlias}]]` 169 177 }) 170 178 }