Conversation
Signed-off-by: alan <erenyu@163.com>
Contributor
|
✅ DCO Check Passed Thanks @eren-YU, all your commits are properly signed off. 🎉 |
Contributor
Merge Protections🔴 1 of 2 protections blocking · waiting on 👀 reviews
🔴 Require two reviewer for test updatesWaiting for
This rule is failing.When test data is updated, we require two reviewers
Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
Signed-off-by: alan <erenyu@163.com> # Conflicts: # tests/test_serialization.py
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 docling-project/docling#4220.
What changed
TextItem.hyperlinkis typedAnyUrl | Path. APathhyperlink read out of a document is a native path, so on Windowsstr()yields backslash separators and every serializer that stringified it emitted a non-portable destination:[next page](sub\next.html)<a href="sub\next.html">\href{sub\textbackslash{}next.html}<href uri="sub\next.html"/>and
save_as_jsonwrote"sub\\next.html", so a document converted on Windows loaded on POSIX as a single path component containing a backslash.A shared
hyperlink_uri()helper now renders aPathdestination withas_posix(), and the four serializers that write a hyperlink destination use it.Why not the existing image-path encoder
MarkdownPictureSerializer._escape_uri_path()is the obvious-looking reuse, but it percent-encodes URL delimiters because it assumes a filesystem path:sub/next.html#sectionbecomessub/next.html%23sectionandsub/next.html?x=1#sectionbecomessub/next.html%3Fx=1%23section. That changes the link target rather than just its separator, so the fragment/query delimiters would stop working.as_posix()only swaps the separator and leaves everything else —?,#,%escapes and spaces — untouched.How I checked
Exported a document with
PathandAnyUrlhyperlinks on Windows:Path("sub/next.html")sub\next.htmlsub/next.htmlPath("sub/next.html#section")sub\next.html#sectionsub/next.html#sectionPath("sub/next.html?x=1#section")sub\next.html?x=1#sectionsub/next.html?x=1#sectionPath("a%20b/x.html")a%20b\x.htmla%20b/x.htmlPath("dir with space/x.html")dir with space\x.htmldir with space/x.htmlAnyUrl("https://example.com/a/b?q=1#f")11 tests added to
tests/test_serialization.pycovering the helper, Markdown and HTML export, the fragment/query cases from the issue discussion, and a JSON round trip. All 11 fail before the change and pass after.→
119 passed. No new failures elsewhere in the suite.ruff checkandruff format --checkare clean.