Repository navigation
Keep hard line breaks that the output normalization strips - #2643
Open
Patrick Creighton (patrick-5546) wants to merge 1 commit into
Open
Patrick Creighton (patrick-5546) wants to merge 1 commit into
Patrick Creighton (patrick-5546) wants to merge 1 commit into
Conversation
markdownify writes <br> as two trailing spaces, which MarkItDown.convert() then strips from every output line, so Word line breaks and HTML <br> became soft breaks that render as a space. A break with text or an image on both sides of it in its parent element is now written as a backslash hard break, which survives the normalization. Other breaks, and those in table cells, headings, and preformatted text, keep markdownify's handling. Tests that recorded the old converter output, including the OCR plugin's, now expect the backslash. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Author
|
@microsoft-github-policy-service agree |
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.
Fixes #2642.
markdownify writes
<br>as two trailing spaces, andMarkItDown.convert()strips them from every output line, so hard line breaks became soft breaks._CustomMarkdownify.convert_brnow writes a backslash hard break when the<br>has text or an image on both sides of it in its parent element. A backslash break survives the normalization:Line one\ Line twoOther breaks keep markdownify's handling, so their output is unchanged. These are breaks at the start or end of an element, and breaks in table cells, headings and preformatted text.
#2559 takes the other approach: it keeps two-space breaks in the normalization. That leaves converter output unchanged. However, it also keeps trailing double spaces that come from the input rather than from markdownify, such as those in plain-text files, and it changes the same lines as #2529 and #2633.
Tests:
Checks:
packages/markitdown: 1107 passed, 11 skipped.markitdown-ocr: 108 passed.markitdown-mcp: 21 passed.