Skip to content

fix(parse): preserve pipes in AnyDoc table code spans - #7690

Open
123XieC wants to merge 1 commit into
volcengine:mainfrom
123XieC:fix/anydoc-preserve-table-code-pipes
Open

123XieC wants to merge 1 commit into
volcengine:mainfrom
123XieC:fix/anydoc-preserve-table-code-pipes

Conversation

@123XieC

@123XieC 123XieC commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Description

When AnyDoc converts an EPUB table containing code such as a|b, the generated Markdown table treats the pipe as a column separator. The cell after the code can disappear. Escape each pipe inside a code span emitted directly in a table cell, including a code block converted to a span. A source backslash is preserved because the table parser consumes the added escape.

Human Involvement

  • This PR was generated entirely by AI agents without human participation in the loop

Related Issue

Fixes #7689.

Type of Change

  • Bug fix

Testing

  • A generated EPUB goes through the real AnyDocConverter in test_epub_table_preserves_pipes_in_inline_and_block_code. The regression failed on the branch base.
  • Ran pytest -o addopts='' -q tests/parse/test_anydoc_table_code.py tests/parse/test_anydoc_note_anchor_links.py tests/parse/test_directory_parser_routing.py tests/parse/test_document_parser_threading.py (29 passed). Also rendered the fixture with cmark-gfm and markdown-it-py, checking both columns and the source backslash.
  • Ruff lint and mypy passed on both changed files. The new test passes Ruff format. The renderer has the same eight pre-existing format hunks on the base and after this patch.

@r266-tech

Copy link
Copy Markdown
Contributor

Independent check at 842f7b0a5f87761dfc08d1d0641cebd4b85c26ba: the fix preserves both columns and the exact code text for direct inline code, a direct code block, and code inside a link. I compared 20 generated EPUB rows through the real AnyDocConverter and markdown-it-py's table renderer: all 12 variants in those three shapes pass, including a source backslash and embedded backticks. The four test files listed in the PR also pass locally (29 passed).

A remaining pre-existing case is code nested in a list or quote within the cell:

<tr><td><ul><li><code>a|b</code></li></ul></td><td>choice</td></tr>
<tr><td><blockquote><p><code>a|b</code></p></blockquote></td><td>choice</td></tr>

AnyDoc retains these as list / block_quote blocks. On both the base and this head, the renderer emits:

| - `a|b` | choice |
| `a|b` | choice |

The table reader splits at the inner pipe and drops choice. The source-backslash variants also fail exact code preservation. _render_cell sends these two block kinds through _render_list / _render_blocks, which render their nested inlines with block context, so the new table_cell escaping does not reach them.

This could be covered here or in a follow-up by preserving table context through nested cell content; the direct-cell change itself fixes the reported reproduction. I found no regression in the 20-row comparison (base 0/20 exact-preservation checks, PR 12/20).

AI-only local verification on macOS arm64 / Python 3.14.10, firecrawl-anydoc==0.2.4 and markdown-it-py==4.0.0. No model calls, remote server, browser rendering or hosted CI run.

This branch has not been deployed

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

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

[Bug] AnyDoc code spans with pipes shift or discard table cells

2 participants