Emile Bangma
2025-05-19 fec0a62b74e45acfe28861ee6eddf493a2be5f74
fix(ofm): allow wikilink alias to be empty (#1984)

This is in line with Obsidian's behavior.
1 files modified
4 ■■■■ changed files
quartz/plugins/transformers/ofm.ts 4 ●●●● patch | view | raw | blame | history
quartz/plugins/transformers/ofm.ts
@@ -113,9 +113,9 @@
// \[\[               -> open brace
// ([^\[\]\|\#]+)     -> one or more non-special characters ([,],|, or #) (name)
// (#[^\[\]\|\#]+)?   -> # then one or more non-special characters (heading link)
// (\\?\|[^\[\]\#]+)? -> optional escape \ then | then one or more non-special characters (alias)
// (\\?\|[^\[\]\#]+)? -> optional escape \ then | then zero or more non-special characters (alias)
export const wikilinkRegex = new RegExp(
  /!?\[\[([^\[\]\|\#\\]+)?(#+[^\[\]\|\#\\]+)?(\\?\|[^\[\]\#]+)?\]\]/g,
  /!?\[\[([^\[\]\|\#\\]+)?(#+[^\[\]\|\#\\]+)?(\\?\|[^\[\]\#]*)?\]\]/g,
)
// ^\|([^\n])+\|\n(\|) -> matches the header row