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