Skip to content

fix(import): 清理 QuoteContainer 自动生成的空子块#87

Merged
riba2534 merged 1 commit intoriba2534:mainfrom
nengqi:fix/quote-container-empty-child
Apr 6, 2026
Merged

fix(import): 清理 QuoteContainer 自动生成的空子块#87
riba2534 merged 1 commit intoriba2534:mainfrom
nengqi:fix/quote-container-empty-child

Conversation

@nengqi
Copy link
Copy Markdown

@nengqi nengqi commented Apr 3, 2026

Summary

  • 飞书 API 创建 QuoteContainer 块时会自动在 index 0 生成空文本子块,导致引用块(blockquote)顶部多出一个空行
  • 此前仅对 Callout 容器做了清理,QuoteContainer 遗漏了
  • 将空子块清理逻辑扩展到 QuoteContainer,复用同一套"检查 index 0 是否为空文本块 → 删除"的防御性逻辑

Test plan

  • go test ./... 全量通过
  • 实际导入含 > 2026-04-03 对齐 的 markdown,导出验证无多余空行
  • Callout 块行为不受影响

飞书 API 创建 QuoteContainer 时会自动在 index 0 生成空文本子块,
导致引用块顶部多出一个空行。此前仅对 Callout 做了清理,现扩展到
QuoteContainer 复用同一逻辑。
@nengqi
Copy link
Copy Markdown
Author

nengqi commented Apr 6, 2026

@riba2534 Hi,方便时帮 review 一下这个 PR 吗?修复比较简单,QuoteContainer 和 Callout 复用同一套空子块清理逻辑。谢谢!

Copy link
Copy Markdown
Owner

@riba2534 riba2534 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 修复了 QuoteContainer 自动生成空子块导致引用块顶部多余空行的问题,改动精确,复用已有的 Callout 清理逻辑。

几个小建议供参考(不阻塞合并)

  • blockTypeName 可用项目已有的 converter.BlockTypeName() 替代手写 if/else,减少硬编码
  • 条件表达式较长,可提取局部变量 isContainer 提升可读性
  • 后续可考虑补充自动化测试用例

感谢贡献!

@riba2534 riba2534 merged commit 75ce257 into riba2534:main Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants