Skip to content

fix: preserve images when links are included#841

Open
rmarchei wants to merge 1 commit intoadbar:masterfrom
rmarchei:fix_links_images
Open

fix: preserve images when links are included#841
rmarchei wants to merge 1 commit intoadbar:masterfrom
rmarchei:fix_links_images

Conversation

@rmarchei
Copy link
Copy Markdown

Summary

  • Images inside container divs were being deleted by link_density_test() when --links was 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.
  • Move <graphic> elements out of their enclosing <ref> in convert_tags() to prevent loss during paragraph processing, and drop image-only refs whose leftover children would otherwise trigger the justext fallback path.
  • Graphics are lifted out in reverse order so addnext() preserves their original document sequence (matters for multi-image links like galleries).

Test plan

  • Added test_htmlprocessing assertion covering multi-image link ordering.
  • Existing test_htmlprocessing suite still passes.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant