Skip to content

fix: skip pruning for pre/code tags to preserve whitespace in code blocks - #2173

Closed
Battleplus wants to merge 2 commits into
unclecode:mainfrom
Battleplus:fix/2110-pruning-pre-code
Closed

fix: skip pruning for pre/code tags to preserve whitespace in code blocks#2173
Battleplus wants to merge 2 commits into
unclecode:mainfrom
Battleplus:fix/2110-pruning-pre-code

Conversation

@Battleplus

Copy link
Copy Markdown

Fixes #2110. PruningContentFilter prunes whitespace-only spans inside pre/code tags, corrupting code blocks. Fix: skip pruning for pre and code tags where whitespace is significant.

Battleplus and others added 2 commits August 21, 2026 10:58
@Battleplus

Copy link
Copy Markdown
Author

Added a focused regression test that uses min_word_threshold to reproduce the prior removal of a whitespace-only syntax-highlighting span and asserts the span remains inside the code block. The new test passes. The existing full test_content_filter_prune.py file still has one unrelated baseline failure in test_threshold_types (fixed and dynamic currently both produce one block); the added regression itself is green. Commit: ee66b90.

@Battleplus

Copy link
Copy Markdown
Author

Closing as a duplicate after the full audit. Earlier PR #2111 implements the same pre/code subtree guard and already includes substantially broader regression coverage for code whitespace preservation. The focused test added here passed, but consolidating review on #2111 is preferable.

@Battleplus Battleplus closed this Aug 22, 2026
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.

PruningContentFilter drops whitespace-only spans in <pre>/<code> — #1181's bug, still present on the fit_markdown path

1 participant