Skip to content

Commit

Permalink
update markmap: remove footnote
Browse files Browse the repository at this point in the history
  • Loading branch information
obgnail committed Oct 2, 2024
1 parent 8570de7 commit f68269f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 5 additions & 1 deletion plugin/custom/plugins/toc.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,11 @@ class tocPlugin extends BaseCustomPlugin {
const { outline } = File.editor.library;
const toc = this.config.escape_header
? outline.getHeaderMatrix(true).map(([depth, text, cid]) => ({ depth, text, cid, children: [] }))
: headers.map(({ attributes: { depth, text }, cid }) => ({ depth, text, cid, children: [] }))
: headers.map(({ attributes, cid }) => {
let { depth, text } = attributes || {};
text = text.replace(/\[\^([^\]]+)\]/g, ""); // 去掉脚注
return { depth, text, cid, children: [] }
})

toc.forEach((node, idx) => {
const parent = findParent(toc, idx - 1, node.depth) || root;
Expand Down
5 changes: 3 additions & 2 deletions plugin/markmap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ class markmapPlugin extends BasePlugin {
const result = [];
for (const header of headers) {
const { pattern, depth, text = "" } = (header && header.attributes) || {};
const head = text.replace(/\[\^([^\]]+)\]/g, ""); // 去掉脚注
if (pattern) {
result.push(pattern.replace("{0}", text));
result.push(pattern.replace("{0}", head));
} else if (depth) {
result.push("#".repeat(parseInt(depth)) + " " + text);
result.push("#".repeat(parseInt(depth)) + " " + head);
}
}
return result.join("\n")
Expand Down

0 comments on commit f68269f

Please sign in to comment.