Include media elements in content_html and markdown exports - #4
Open
gorango wants to merge 3 commits into
Open
Conversation
Resolves build error where icu_collections@2.2.0, icu_locale_core@2.2.0, icu_normalizer@2.2.0, icu_properties@2.2.0, icu_provider@2.2.0, and idna_adapter@1.2.2 require rustc 1.86.
Add img, figure, figcaption, picture, and source tags to the HTML extraction output in push_filtered_html_children(). Images were previously extracted to result.images but stripped from content_html, making them unavailable in inline HTML and markdown exports. Also preserve original content_html during fallback extraction when it contains <img> tags but the fallback result doesn't. The baseline fallback creates text-only <p> elements that lose image tags. Add tests verifying images appear in both content_html and content_markdown when include_images is enabled.
Add include_videos and include_audio options to control extraction of <video>, <audio>, <source>, and <track> elements. These were previously stripped during document cleaning (video/audio/source/track are in TAGS_TO_CLEAN) and not handled in push_filtered_html_children(). Changes mirror the image extraction pattern from commit 3b13f06: - src/options.rs: Add include_videos and include_audio fields (default: false) - src/result.rs: Add VideoData and AudioData structs with src, filename, poster/caption, and is_hero fields - src/html_processing.rs: Preserve video/audio/figure/source/track tags during cleaning when respective options are enabled - src/extract.rs: Add video/audio/track handlers to push_filtered_html_children(), add extract_videos() and extract_audio() functions, extend fallback protection to preserve <video> and <audio> - src/lib.rs: Re-export VideoData and AudioData - tests/video_audio_toggle_test.rs: 22 tests covering toggle behavior, HTML/Markdown output, figure-wrapped media, multiple sources, track subtitles, deduplication, poster preservation, and fallback Markdown output: quick_html2md strips unknown tags, so video/audio appear as text-only in markdown but are fully preserved in content_html and extracted to result.videos/result.audio with metadata.
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.
This PR adds the ability to include images, video, and audio elements in
content_htmlandcontent_markdownexports.include_images): Preservesimg,figure,figcaption,picture, andsourcetags in HTML/markdown outputinclude_videos): Preservesvideo,source, andtrackelementsinclude_audio): PreservesaudioandsourceelementsChanges
src/options.rsinclude_videos: boolandinclude_audio: boolfields (default:false)src/result.rsVideoDatastruct withsrc,filename,poster,caption,is_herofieldsAudioDatastruct withsrc,filename,captionfieldssrc/extract.rspush_filtered_html_children()to handle video/audio elementsextract_videos()andextract_audio()functions<video>and<audio>tags in fallback extractionsrc/html_processing.rsTesting
New tests in
tests/video_audio_toggle_test.rscover:Image tests in
tests/image_link_toggle_test.rsverify images appear in bothcontent_htmlandcontent_markdown.Closes #5