Skip to content

【Auto】fix(MarkdownRender): 修复 GFM 单列表格渲染丢失 cell 内容#3129

Open
SudoUserReal wants to merge 1 commit intomainfrom
solve/issue-3077-1770116572723
Open

【Auto】fix(MarkdownRender): 修复 GFM 单列表格渲染丢失 cell 内容#3129
SudoUserReal wants to merge 1 commit intomainfrom
solve/issue-3077-1770116572723

Conversation

@SudoUserReal
Copy link
Collaborator

关联 Issue: #3077

问题概述

MarkdownRender 在渲染 remark-gfm 生成的表格时,当表格只有 1 列(tr.props.children 为单个 ReactElement 而非数组)会导致行内单元格无法被遍历写入,最终表现为表格 cell 内容丢失。

解决方案说明

在表格渲染逻辑中统一使用 React.Children.toArray 归一化 children,避免对 forEach/map 的数组假设,从而兼容单列/多列以及不同 children 结构的表格节点。

主要变更点

  • 修复单列表格场景下 tr.props.children 非数组导致 cell 不写入的问题
    packages/semi-ui/markdownRender/components/table.tsx
  • 新增单列表格回归测试,并调整测试为等待 MarkdownRender 异步 evaluate 完成后再断言
    packages/semi-ui/markdownRender/__test__/markdown.test.js

测试说明

  • 运行并通过:packages/semi-ui/markdownRender/__test__/markdown.test.js(新增单列表格用例,覆盖 “| 标题 | ... | 内容 |” 场景)

This commit was automatically generated by Semi Issue Solver.
Closes #3077
@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 3, 2026

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 29dd765:

Sandbox Source
pr-story Configuration

@cypress
Copy link

cypress bot commented Feb 3, 2026

semi-design    Run #3450

Run Properties:  status check failed Failed #3450  •  git commit 81de75ce1f ℹ️: Merge 29dd765de7b79d5b35a07bc341c73d71653dd116 into d56dc3df4f84819caa7e98a49e9d...
Project semi-design
Branch Review solve/issue-3077-1770116572723
Run status status check failed Failed #3450
Run duration 08m 26s
Commit git commit 81de75ce1f ℹ️: Merge 29dd765de7b79d5b35a07bc341c73d71653dd116 into d56dc3df4f84819caa7e98a49e9d...
Committer SudoUser
View all properties for this run ↗︎

Test results
Tests that failed  Failures 1
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 13
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 290
⚠️ You've recorded test results over your free plan limit.
Upgrade your plan to view test results.
View all changes introduced in this branch ↗︎

Tests for review

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.

1 participant