Skip to content

Commit

Permalink
fix footnote link reged
Browse files Browse the repository at this point in the history
  • Loading branch information
jparkerweb committed Dec 2, 2024
1 parent b40aa6c commit a547b09
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 24 deletions.
Binary file modified example-vault.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@ var RichFootPlugin = class extends import_obsidian3.Plugin {
}
}
const fileContent = await this.app.vault.read(file);
const inlineFootnoteRegex = /\^\[((?:[^\[\]]|\[(?:[^\[\]]|\[[^\[\]]*\])*)*)\]/g;
const inlineFootnoteRegex = /\^\[((?:[^\[\]]|\[(?:[^\[\]]|\[[^\[\]]*\])*\])*)\]/g;
const refFootnoteRegex = /\[\^[^\]]+\]:\s*((?:[^\[\]]|\[(?:[^\[\]]|\[[^\[\]]*\])*\])*)/g;
let match;
while ((match = inlineFootnoteRegex.exec(fileContent)) !== null) {
Expand Down
46 changes: 25 additions & 21 deletions example-vault/rich-foot-example/.obsidian/workspace.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,8 @@
"icon": "lucide-file",
"title": "🦶 Rich Foot"
}
},
{
"id": "930061c455a4487c",
"type": "leaf",
"state": {
"type": "markdown",
"state": {
"file": "🦶 Rich Foot.md",
"mode": "preview",
"backlinks": false,
"source": false
},
"icon": "lucide-file",
"title": "🦶 Rich Foot"
}
}
],
"currentTab": 1
]
}
],
"direction": "vertical"
Expand Down Expand Up @@ -3024,6 +3008,26 @@
{
"id": "e7ee6ca0a6279e30",
"type": "leaf",
"state": {
"type": "empty",
"state": {},
"icon": "lucide-file",
"title": "New tab"
}
},
{
"id": "52068618fa3e04b4",
"type": "leaf",
"state": {
"type": "empty",
"state": {},
"icon": "lucide-file",
"title": "New tab"
}
},
{
"id": "5ee8ef35ab61bc8c",
"type": "leaf",
"state": {
"type": "Saved Queries View",
"state": {},
Expand All @@ -3032,7 +3036,7 @@
}
}
],
"currentTab": 291
"currentTab": 293
}
],
"direction": "horizontal",
Expand All @@ -3051,17 +3055,17 @@
"canvas:Create new canvas": false
}
},
"active": "930061c455a4487c",
"active": "5173ce34fa31fa9f",
"lastOpenFiles": [
"misc-notes/link test.md",
"test.md",
"misc-notes/three.md",
"misc-notes/link test 2.md",
"🦶 Rich Foot.md",
"test.md",
"releases/v1.9.0 - 🥙 Stuffed Links.md",
"releases/v1.8.0 - 🫣 Page Preview Support.md",
"releases/v1.7.0 - 📆 Dates Your Way.md",
"misc-notes/two.md",
"misc-notes/three.md",
"misc-notes/one.md",
"exclude/no rich-feet here.md",
"exclude/me too/no rich-feet here either.md",
Expand Down
4 changes: 2 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -714,8 +714,8 @@ class RichFootPlugin extends Plugin {
// Handle inline footnotes by reading the file content
const fileContent = await this.app.vault.read(file);

// Match inline footnotes with improved regex for nested brackets
const inlineFootnoteRegex = /\^\[((?:[^\[\]]|\[(?:[^\[\]]|\[[^\[\]]*\])*)*)\]/g;
// Match inline footnotes (nested brackets)
const inlineFootnoteRegex = /\^\[((?:[^\[\]]|\[(?:[^\[\]]|\[[^\[\]]*\])*\])*)\]/g; // altering this will break link detection
const refFootnoteRegex = /\[\^[^\]]+\]:\s*((?:[^\[\]]|\[(?:[^\[\]]|\[[^\[\]]*\])*\])*)/g;

let match;
Expand Down

0 comments on commit a547b09

Please sign in to comment.