diff --git a/crawl4ai/content_filter_strategy.py b/crawl4ai/content_filter_strategy.py index ab99a793c..40405e77f 100644 --- a/crawl4ai/content_filter_strategy.py +++ b/crawl4ai/content_filter_strategy.py @@ -712,6 +712,11 @@ def _prune_tree(self, node): if self._is_preserved(node): return + # Skip pruning for nodes inside
or — whitespace is significant there
+ # (matches the guard in content_scraping_strategy.remove_empty_elements_fast, fix for #1181)
+ if self._is_in_code_block(node):
+ return
+
text_len = len(node.get_text(strip=True))
tag_len = len(node.encode_contents().decode("utf-8"))
link_text_len = sum(