Skip to content

Commit eb71b9f

Browse files
committed
fix(memory-wiki): ignore wikilink-like text in code spans during lint
The wikilink extractor ran OBSIDIAN_LINK_PATTERN against raw markdown, so [[...]] inside fenced code blocks and inline code spans were reported as broken wikilinks. Strip fenced blocks (line-by-line, matching backtick and tilde fences of any length, including bare fences) and inline code spans before extraction. Fixes #97945
1 parent e4f9e83 commit eb71b9f

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

extensions/memory-wiki/src/lint.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,11 @@ describe("lintMemoryWikiVault", () => {
534534
"",
535535
"Inline with backticks: `` `[[multi-backtick]]` `` and `[[single-backtick]]`.",
536536
"",
537+
"Bare fence below (no info string):",
538+
"```",
539+
"[[inside-bare-fence]]",
540+
"```",
541+
"",
537542
"Unclosed fenced block below (malformed markdown):",
538543
"```scala",
539544
"val x = [[unclosed-code]]",

extensions/memory-wiki/src/markdown.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export type WikiPageSummary = {
112112
const FRONTMATTER_PATTERN = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/;
113113
const OBSIDIAN_LINK_PATTERN = /\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g;
114114
const MARKDOWN_LINK_PATTERN = /\[[^\]]+\]\(([^)]+)\)/g;
115-
const FENCED_CODE_BLOCK_START_PATTERN = /^(\s*)(`{3,}|~{3,})(?:\s+\S.*|\S.*)$/;
115+
const FENCED_CODE_BLOCK_START_PATTERN = /^(\s*)(`{3,}|~{3,})(?:\s.*|\S.*)?$/;
116116
const FENCED_CODE_BLOCK_END_PATTERN = /^(\s*)(`{3,}|~{3,})\s*$/;
117117
const INLINE_CODE_PATTERN = /(`+)([^`\r\n]|`(?!\1))*\1/g;
118118
const RELATED_BLOCK_PATTERN = new RegExp(

0 commit comments

Comments
 (0)