MCPcopy Create free account
hub / github.com/ScrapeGraphAI/Scrapegraph-ai / minify_html

Function minify_html

scrapegraphai/utils/cleanup_html.py:104–121  ·  view source on GitHub ↗

minify_html function

(html)

Source from the content-addressed store, hash-verified

102
103
104def minify_html(html):
105 """
106 minify_html function
107 """
108 # Combine multiple regex operations into one for better performance
109 patterns = [
110 (r"<!--.*?-->", "", re.DOTALL),
111 (r">\s+<", "><", 0),
112 (r"\s+>", ">", 0),
113 (r"<\s+", "<", 0),
114 (r"\s+", " ", 0),
115 (r"\s*=\s*", "=", 0),
116 ]
117
118 for pattern, repl, flags in patterns:
119 html = re.sub(pattern, repl, html, flags=flags)
120
121 return html.strip()
122
123
124def reduce_html(html, reduction):

Callers 3

test_minify_htmlFunction · 0.90
reduce_htmlFunction · 0.85

Calls

no outgoing calls

Tested by 2

test_minify_htmlFunction · 0.72