feat: convert tables with merged cells to HTML with rowspan/colspan#126
Closed
vnixx wants to merge 3 commits intowhale4113:mainfrom
Closed
feat: convert tables with merged cells to HTML with rowspan/colspan#126vnixx wants to merge 3 commits intowhale4113:mainfrom
vnixx wants to merge 3 commits intowhale4113:mainfrom
Conversation
…/colspan HTML output GFM markdown tables cannot represent merged cells. When a Lark table contains rowspan/colspan merges, it is now converted to an HTML <table> with proper attributes instead. Merge info is resolved by reading rowspan/colspan from the rendered DOM <td> elements. For tables not in the viewport (virtual scrolling), the extension scrolls them into view via locateBlockWithRecordId before reading — following the same pattern as transformMentionUsers.
…ad of markdown Markdown syntax like **bold** inside <td> tags is not parsed by renderers. Convert cell content to HTML (e.g. <strong>) via the mdast-to-hast-to-html pipeline so formatting is preserved.
…yout When a merged table cell contains multiple consecutive images, wrap them in a <table><thead><tr><th> structure for horizontal display, matching the behavior of the original plugin's invalid table HTML output.
Author
|
hi, 感谢你这个优秀的插件, 这是我能找到的飞书文档转 Markdown 最好的工具. |
whale4113
added a commit
that referenced
this pull request
Mar 28, 2026
Owner
|
Hi @vnixx ,感谢你为这个项目贡献代码,也感谢你花时间研究合并单元格这个比较复杂的问题!从截图对比来看,功能效果非常好 👍 主要问题:对 DOM 的依赖 这个 PR 的核心逻辑是
更好的数据来源 其实飞书在 TableBlock 的 snapshot 中已经直接提供了 merge_info 信息(包含 row_span 和 col_span),这是数据层的信息,不依赖 DOM 渲染,也不需要等待滚屏。 再次感谢你发现并报告了这个问题,你的 PR 给了我很好的参考,尤其是对问题的分析和截图对比,很有帮助。如果你在使用过程中发现新的 bug 或有其他改进想法,欢迎继续提 issue 或 PR! |
Author
|
@whale4113 好的好的, 我也觉得我的实现有隐患, 但是又不太懂, 还是你实现的令人放心!! 感谢~ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
<table>instead of GFM markdown tables, which cannot represent cell merges.rowspan/colspanattributes anddisplay: nonestyle on<td>elements, with a fallback that scrolls off-screen tables into view vialocateBlockWithRecordId(same pattern astransformMentionUsers).