fix(parser): preserve Markdown code fence boundaries - #356
Open
er-s-an wants to merge 1 commit into
Open
Conversation
Signed-off-by: er-s-an <3137612974@qq.com>
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.
Description
Keep Markdown code examples literal until a matching closing fence is reached.
After #352, the direct Markdown parser records every opening fence as only three characters. A triple-backtick line inside a four-backtick code block therefore ends the block early. A fence-like line with trailing text (for example, three backticks followed by
python) also incorrectly closes it.As a result, headings and local image references inside the example become document heading/image blocks, while the actual closing fence can hide real headings/images that follow it. This breaks the existing promise that fenced content is not interpreted; it is not a request for broader Markdown support.
Changes Made
Validation
tests/test_plain_text_direct.py.python -m pytest tests/ -q— 406 passed on Python 3.12.13.--cov=raganything --cov-branch).--ignore=E402) and format check passed for both changed files;git diff --checkpassed.Related Issues and Limitations
Follow-up to the fenced-content behavior introduced in #352. I did not find an existing issue or PR for this edge case.
This is an offline parser regression, not a live OCR/VLM or ingestion-performance test. The image fixture only needs to exist because this parsing path resolves references without decoding images. No new dependency, public API, or other Markdown syntax handling is introduced. Python 3.10/3.11 are left to CI. An initial coverage invocation targeting the dotted module name triggered import-time errors; the directory-targeted invocation above completed successfully.
Prepared with AI assistance; the changed paths and local test results were checked before submission.