1 Sanitize::Config::OSM = Sanitize::Config.merge(
2 Sanitize::Config::RELAXED,
3 :elements => Sanitize::Config::RELAXED[:elements] - %w[div style],
4 :remove_contents => %w[script style],
5 :transformers => lambda do |env|
6 style = env[:node]["style"] || ""
8 env[:node].remove_class
9 env[:node].remove_attribute("style")
11 env[:node].add_class("table table-sm w-auto") if env[:node_name] == "table"
14 when /\btext-align:\s+left\b/
15 env[:node].add_class("text-start")
16 when /\btext-align:\s+center\b/
17 env[:node].add_class("text-center")
18 when /\btext-align:\s+right\b/
19 env[:node].add_class("text-end")
22 if env[:node_name] == "a"
23 rel = env[:node]["rel"] || ""
25 env[:node]["rel"] = rel.split.select { |r| r == "me" }.append("nofollow", "noopener", "noreferrer").sort.join(" ")