Skip to content

exportMdContent missing footnotes - #16953

Closed
TCOTC wants to merge 1 commit into
siyuan-note:devfrom
TCOTC:fix/exportMdContent
Closed

exportMdContent missing footnotes#16953
TCOTC wants to merge 1 commit into
siyuan-note:devfrom
TCOTC:fix/exportMdContent

Conversation

@TCOTC

@TCOTC TCOTC commented Jan 30, 2026

Copy link
Copy Markdown
Contributor

Note

这 PR 是 Cursor 慢吞吞(并且频繁报错) debug 了三个小时弄出来的,我没有看代码逻辑,仅供参考

https://ld246.com/article/1769784156993

001创世纪(创).sy_2-6jj14FU.zip

  • 调用接口导出的 Markdown 中缺少脚注 [^111] 之后的内容:

    PixPin_2026-01-31_01-32-49

     (async () => {
       const docId = "你的docId"; // 右键文档标题/文档树 -> 复制文档 ID
       const token = globalThis?.siyuan?.config?.api?.token || "";
       
       if (!token) {
         console.error("未获取到 Token,请确保在思源笔记桌面端 F12 控制台中运行。");
         return;
       }
     
       try {
         const resp = await fetch("/api/export/exportMdContent", {
           method: "POST",
           headers: {
             "Content-Type": "application/json",
             Authorization: `Token ${token}`,
           },
           body: JSON.stringify({ id: docId }),
         });
     
         const data = await resp.json();
         const md = data?.data?.content || "";
     
         if (!md) {
           console.warn("接口未返回内容,请检查 docId 是否正确。");
           return;
         }
     
         // 保存到桌面 (仅限桌面端环境)
         const fs = require("fs");
         const os = require("os");
         const path = require("path");
         const desktop = path.join(os.homedir(), "Desktop");
         const filePath = path.join(desktop, "export.md");
     
         fs.writeFileSync(filePath, md, "utf8");
         console.log("Markdown 已成功导出至桌面:", filePath);
       } catch (err) {
         console.error("导出过程中发生错误:", err);
       }
     })();
  • 导出 PDF 时超过 [^111] 的脚注全是 [^111]:

    PixPin_2026-01-31_01-34-52

本 PR 修改之后:

  • 接口能导出剩余的脚注:

    PixPin_2026-01-31_01-37-33

  • 导出 PDF 的脚注能超过 [^111] 了:

    PixPin_2026-01-31_01-29-37

@88250

88250 commented Feb 7, 2026

Copy link
Copy Markdown
Member

感谢,稍后我手动改一下吧,ai 的思路基本是对的。

@88250 88250 closed this Feb 7, 2026
88250 added a commit that referenced this pull request Feb 7, 2026
Signed-off-by: Daniel <845765@qq.com>
@88250 88250 added the Bug label Feb 7, 2026
@TCOTC

TCOTC commented Feb 7, 2026

Copy link
Copy Markdown
Contributor Author

@88250 找不到引用的内容块的时候还是会有序号 [^112] [^113],我感觉是不是应该不要序号?让后面的 [^114] 接着用 [^112]

PixPin_2026-02-07_21-52-52

p.s. 之前测这个问题的时候,接口导出一次文档的耗时要按分钟来算,现在竟然只要两秒了

@TCOTC
TCOTC deleted the fix/exportMdContent branch February 7, 2026 14:01
@88250

88250 commented Feb 7, 2026

Copy link
Copy Markdown
Member

编号不改变了,日志里面有丢失记录,还可以对应查一下。

性能优化 #16982

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jul 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants