Skip to content

Improve kernel API exportMdContent #14032

Closed
@frostime

Description

@frostime

API | 添加 API 以导出指定 ID 块的纯 Markdown 内容

In what scenarios do you need this feature?

目前,exportMdContent API (/api/export/exportMdContent) 可以导出文档的 markdown 内容。但是它导出的 Markdown 内容会受到用户设置的影响。导出的内容不一定是纯粹的 Markdown 文档,可能包含 YAML Frontmatter、引用的项目数据或其他超出核心 Markdown 内容的元素。

Describe the optimal solution

建议添加一个新的 API 端点,允许将指定的块导出为纯 Markdown。这个新的 API 应该:

  • 排除用户设置的影响:确保导出的 Markdown 内容不受任何用户设置、YAML Frontmatter、引用的项目数据或任何其他非 Markdown 元素的影响。输出应该是干净、标准的 Markdown 文档。(或许让用户输入参数来制定?)
  • 支持所有块类型: 确保 API 可以导出所有块类型的内容,包括:
    • 普通内容块
    • 容器块
    • 标题块: 特别关注标题块。 目前,只能访问标题块的内容,这个新的 API 应该能够导出这些内容。
    • 文档块
  • 可选:可以指定是标准 markdown 还是 kramdown 格式

Describe the candidate solution

No response

Other information

No response

Activity

self-assigned this
on Feb 9, 2025
88250

88250 commented on Feb 9, 2025

@88250
Member

在 exportMdContent 上加参数吧,稍后调整一下,还有问题的话麻烦继续跟帖。

frostime

frostime commented on Feb 9, 2025

@frostime
ContributorAuthor

在 exportMdContent 上加参数吧,稍后调整一下,还有问题的话麻烦继续跟帖。

也可以,目前和导出相关的设置选项有好几个(yaml,引用的处理等等),导致不同机器上运行同一个 API 会有不同效果。


另外还有一个问题:exportMdContent 是导出文档,那如果想要导出标题和下方所有的 markdown 有没有什么比较好的建议方案?

88250

88250 commented on Feb 9, 2025

@88250
Member

这次一起改进了,根据指定的 ID 定位到块级导出,类似聚焦导出的效果。

added a commit that references this issue on Feb 9, 2025
88250

88250 commented on Feb 9, 2025

@88250
Member

v3.1.21

frostime

frostime commented on Feb 9, 2025

@frostime
ContributorAuthor

🐂🍺

frostime

frostime commented on Feb 9, 2025

@frostime
ContributorAuthor

请问 refMode embedMode 这几个参数是怎么用的?有点没看明白。

88250

88250 commented on Feb 9, 2025

@88250
Member

Image

frostime

frostime commented on Feb 18, 2025

@frostime
ContributorAuthor

测试了一下好像有点奇怪,yfm 是生效的,但是如果加上另外两个参数就什么都不返回了?

Image

Image

Image

added this to the 3.1.23 milestone on Feb 18, 2025
changed the title [-]API | 添加 API 以导出指定 ID 块的纯 Markdown 内容[/-] [+]Improve kernel API `exportMdContent`[/+] on Feb 18, 2025
88250

88250 commented on Feb 18, 2025

@88250
Member

确实有点问题,下个版本继续改进,感谢反馈。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @88250@frostime

      Issue actions

        Improve kernel API `exportMdContent` · Issue #14032 · siyuan-note/siyuan