Skip to content

fix(ebook): keep the text of nested tables in TXT and Markdown - #2106

Open
RionHwang0 wants to merge 3 commits into
KnifeLemon:mainfrom
RionHwang0:fix/text-nested-tables
Open

RionHwang0 wants to merge 3 commits into
KnifeLemon:mainfrom
RionHwang0:fix/text-nested-tables

Conversation

@RionHwang0

Copy link
Copy Markdown
Contributor

What does this change?

PlainTextWriter and MarkdownWriter build a cell's text from its paragraphs only (cell.Blocks.OfType<HParagraph>()). A table nested in a cell is therefore dropped with all its text, on every route that ends in those writers: HTML → TXT, e-book → TXT / Markdown / TXTZ, and translated documents saved as TXT or Markdown.

The readers keep such tables: the HTML, DOCX and HWPX readers put them in HCell.Blocks, and Nesting.Limit caps the depth. The DOCX, HWPX and XHTML writers already write them. Only the two text writers dropped them.

Example: a schedule cell that holds 개요 and a small 2×2 table (1일차 | 개막식, 2일차 | 현장 견학) came out as 일정 개요 in TXT and | 일정 | 개요 | in Markdown.

The nested table's text now stays in its outer cell, in reading order. Its cells are separated by a space and its rows by /, because a tab or a line break would split the outer table's row in TXT, and a pipe table can't hold either:

  • TXT: 일정 개요 1일차 개막식 / 2일차 현장 견학
  • Markdown: | 일정 | 개요 1일차 개막식 / 2일차 현장 견학 |

Header cells of the nested table drop ** the same way outer header cells do. Empty paragraphs in a cell no longer add an extra space in Markdown, which TXT already did.

Type of change

  • Bug fix
  • New feature or improvement
  • New format or engine
  • Translation
  • Documentation
  • Build, CI or dependencies

How was it tested?

  • dotnet format --verify-no-changes
  • dotnet test, limited to the affected classes: HtmlReaderTests, EbookTests, KepubTests, NestingLimitTests, PdfReaderTests, ConversionBudgetTests, the translation tests and the Markdown tests. 259 passed, 8 skipped. Three PandocMarkupTests fail the same way on main here, because the local pandoc version differs.
  • New test HtmlReaderTests.Nested_table_text_reaches_text_and_markdown_from_html_and_epub covers HTML → TXT, HTML → EPUB → TXT and EPUB → MD. It fails on main and passes with this change.
  • Tried it in the app: ran on Linux through the engine test fixture only.

#2105 (table captions) touches the same two writers in a different place; the two merge cleanly in either order.

Checklist

  • New UI strings are in all src/Filee.App/Assets/i18n/*.json files (none added)
  • New third-party code or binaries are listed in THIRD-PARTY-NOTICES.md (none added)
  • The PR does one thing (unrelated changes go in a separate PR)

CHANGELOG lines (for your CHANGELOG PR):

- **Tables inside table cells kept in TXT and Markdown.** HTML → TXT and e-book → TXT / Markdown keep the text of a table nested in a cell, in that cell.
ko: HTML·전자책을 TXT·Markdown으로 바꿀 때 표 칸 안의 표 내용도 그 칸에 남겨요
en: HTML and e-book to TXT or Markdown keep the text of a table inside a table cell

PlainTextWriter and MarkdownWriter built a cell's text from its paragraphs only, so a
table nested in a cell (HTML, EPUB) vanished from HTML → TXT and e-book → TXT /
Markdown. The nested table's text now stays in its outer cell, in reading order:
cells separated by a space and rows by " / ".

@KnifeLemon KnifeLemon left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks. Keeping the nested table's text in its outer cell, with spaces between cells and / between rows, is a sensible single-line form for both writers, and Nesting.Limit already bounds the recursion. A nested table's own caption still isn't written inside the cell; that's fine to leave. Once #2105 is in, I'll merge main, add the CHANGELOG line under 2.6.0 Fixes and merge this after CI is green.

KnifeLemon and others added 2 commits December 6, 2026 15:09
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…on#2106)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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