From 5ec61468d5e787b3c8ae32a2b4ef1595cf0bc3ee Mon Sep 17 00:00:00 2001 From: Emile Bangma Date: Sun, 31 Mar 2024 18:44:50 +0200 Subject: [PATCH] fix(wikilinks): proper escaping of pipe character in wikilinks inside tables (#1040) --- quartz/plugins/transformers/ofm.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/quartz/plugins/transformers/ofm.ts b/quartz/plugins/transformers/ofm.ts index 3ee6480ca..108f7f779 100644 --- a/quartz/plugins/transformers/ofm.ts +++ b/quartz/plugins/transformers/ofm.ts @@ -188,7 +188,8 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin const [raw]: (string | undefined)[] = capture let escaped = raw ?? "" escaped = escaped.replace("#", "\\#") - escaped = escaped.replace("|", "\\|") + // escape pipe characters if they are not already escaped + escaped = escaped.replace(/((^|[^\\])(\\\\)*)\|/g, "$1\\|") return escaped })