Current section
Files
Jump to
Current section
Files
lib/html_sanitize_ex/scrubber.ex
defmodule HtmlSanitizeEx.Scrubber do
def scrub("", _) do
""
end
def scrub(nil, _) do
""
end
def scrub(html, scrubber_module) do
html
|> before_scrub
|> scrubber_module.before_scrub
|> HtmlSanitizeEx.Parser.parse
|> HtmlSanitizeEx.Traverser.traverse(scrubber_module)
|> HtmlSanitizeEx.Parser.to_html
end
defp before_scrub(html) do
html
|> String.replace(~r/(>)(\ +)(<)/, "\\1 \\3")
end
end