fix: preserve images when links are included#841
Open
rmarchei wants to merge 1 commit intoadbar:masterfrom
Open
fix: preserve images when links are included#841rmarchei wants to merge 1 commit intoadbar:masterfrom
rmarchei wants to merge 1 commit intoadbar:masterfrom
Conversation
Images inside container divs were deleted by link_density_test() when --links was enabled, because empty anchor refs (e.g. <ref target="#img-2"/>) made the divs appear link-heavy. Skip link density checks for elements containing graphic descendants. Also move graphic elements out of ref elements to prevent loss during paragraph processing, and clean up image-only refs. Graphics are lifted out in reverse order so addnext() preserves their original sequence.
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.
Summary
link_density_test()when--linkswas enabled, because empty anchor refs (e.g.<ref target="#img-2"/>) made the divs look link-heavy. Skip the link-density check when an element has any<graphic>descendant.<graphic>elements out of their enclosing<ref>inconvert_tags()to prevent loss during paragraph processing, and drop image-only refs whose leftover children would otherwise trigger the justext fallback path.addnext()preserves their original document sequence (matters for multi-image links like galleries).Test plan
test_htmlprocessingassertion covering multi-image link ordering.test_htmlprocessingsuite still passes.