Conversation
…output Co-Authored-By: tom mottes <tom.mottes@gmail.com>
Co-Authored-By: tom mottes <tom.mottes@gmail.com>
… tuples Co-Authored-By: tom mottes <tom.mottes@gmail.com>
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.
Strip elements by attribute rules
Summary
Extends the existing HTML stripping (which already removes
<script>,<style>,<head>, etc.) to also strip elements matching configurable(tag, attr, value)rules — currently<div id="secondary">and<div id="actionbar">.The new
_strip_tags_by_attrfunction tracks nesting depth of the specified tag type to find the correct closing tag. It handles the target attribute appearing in any position among other attributes (e.g.<div class="widget-area" id="secondary">). Default rules only matchdiv, but expanding to other tags is a one-line addition:Called in
process_html_fileright after the existingSKIP_TAG_PATTERN.subcall.Review & Testing Checklist for Human
class="ads"matches, butclass="ads sidebar"does not. If you plan to add class-based rules with multi-value class attributes, the regex will need adjustmentpython main.py twig_full.html --html -o output.htmland verify:grep -c 'id="secondary"' output.htmlreturns 0grep -c 'id="actionbar"' output.htmlreturns 0Notes