Conversation
ExcelParser._table_to_markdown has its own cell formatter (src/agentscope/rag/_parser/_excel.py:428) that escapes only the pipe character. Two kinds of cell content therefore corrupt the rendered pipe-table: - A cell containing a line break. _extract_table_data normalises CRLF to LF and keeps it, so the row is emitted across two physical lines and the table row is truncated at the break. - A cell containing a backslash. "\|" is escaped to "\\|", which Markdown reads as a literal backslash followed by an unescaped column separator, so one cell becomes two. WordParser and PPTParser render through the shared _format_markdown_table_cell in _parser/_utils.py, which escapes backslashes and pipes and renders line breaks as <br>. The Excel path predates that helper and was never switched over. Render Excel cells through the same helper. The cell-coordinate prefix and the JSON table format are unchanged.
Inline the single-use XLSX builder into the test and drop the docstring additions unrelated to the fix. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019vGQfv7bHuvpthdkdmmBAg
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.
AgentScope Version
2.0.8 (
main, base commit41ba021)Description
ExcelParserrenders a sheet through its own cell formatter,_fmtatsrc/agentscope/rag/_parser/_excel.py:419, which escapes the pipe character and nothing else. Two ordinary kinds of spreadsheet cell corrupt the table it produces.A cell containing a line break (alt+enter in Excel) ends the Markdown row early.
_extract_table_datanormalises CRLF to LF at_excel.py:74and keeps the break, so the text after it lands on its own physical line and the row is cut short there.A cell containing a backslash in front of a pipe loses a column.
Path \| labelis escaped toPath \\| label, and Markdown reads\\as a literal backslash and the|after it as an unescaped column separator, so one cell renders as two.WordParserandPPTParserare not affected: both render through the shared_format_markdown_table_cellinsrc/agentscope/rag/_parser/_utils.py:50, which escapes backslashes and pipes and turns line breaks into<br>. The Excel path predates that helper and was never switched over to it.Repro on
main, with a sheet whose cells areA|B,Path \| label,1|2andLine 1\nLine 2:After this change:
Change
_fmtcalls_format_markdown_table_cellinstead of its own singlereplace. The[A1]cell-coordinate prefix and thetable_format="json"path are untouched, and cells with no pipe, backslash or line break render exactly as before.Tests
Added
ExcelParserTest.test_markdown_table_escapes_special_cells, which mirrors the Word and PPT tests of the same name and asserts the whole parsedSectiondump. It fails onmain(Path \\| labeland the split row) and passes with the change.Run on macOS with Python 3.11, pandas 3.0.5 and openpyxl 3.1.5. The new test uses only
_make_xlsx_simple, the helper the existing Excel tests already build workbooks with, so it needs nothing that CI does not already install.Checklist
Please check the following items before code is ready to be reviewed.