Merge remote-tracking branch 'upstream/pull/3149'
This commit is contained in:
commit
580b7bfc0c
2 changed files with 33 additions and 8 deletions
|
@ -1,8 +1,10 @@
|
|||
Sanitize::Config::OSM = Sanitize::Config::RELAXED.dup
|
||||
|
||||
Sanitize::Config::OSM[:elements] -= %w[div style]
|
||||
Sanitize::Config::OSM[:add_attributes] = { "a" => { "rel" => "nofollow noopener noreferrer" } }
|
||||
Sanitize::Config::OSM[:remove_contents] = %w[script style]
|
||||
Sanitize::Config::OSM[:transformers] = lambda do |env|
|
||||
env[:node].add_class("table table-sm w-auto") if env[:node_name] == "table"
|
||||
end
|
||||
Sanitize::Config::OSM = Sanitize::Config.merge(
|
||||
Sanitize::Config::RELAXED,
|
||||
:elements => Sanitize::Config::RELAXED[:elements] - %w[div style],
|
||||
:add_attributes => { "a" => { "rel" => "nofollow noopener noreferrer" } },
|
||||
:remove_contents => %w[script style],
|
||||
:transformers => lambda do |env|
|
||||
env[:node].remove_class
|
||||
env[:node].add_class("table table-sm w-auto") if env[:node_name] == "table"
|
||||
end
|
||||
)
|
||||
|
|
|
@ -47,6 +47,17 @@ class RichTextTest < ActiveSupport::TestCase
|
|||
assert_select "style", false
|
||||
assert_select "p", /^foo *baz$/
|
||||
end
|
||||
|
||||
r = RichText.new("html", "<table><tr><td>column</td></tr></table>")
|
||||
assert_html r do
|
||||
assert_select "table[class='table table-sm w-auto']"
|
||||
end
|
||||
|
||||
r = RichText.new("html", "<p class='btn btn-warning'>Click Me</p>")
|
||||
assert_html r do
|
||||
assert_select "p[class='btn btn-warning']", false
|
||||
assert_select "p", /^Click Me$/
|
||||
end
|
||||
end
|
||||
|
||||
def test_html_to_text
|
||||
|
@ -145,6 +156,18 @@ class RichTextTest < ActiveSupport::TestCase
|
|||
assert_html r do
|
||||
assert_select "pre", /^\s*foo bar baz\s*$/
|
||||
end
|
||||
|
||||
r = RichText.new("markdown", "|column|column")
|
||||
assert_html r do
|
||||
assert_select "table[class='table table-sm w-auto']"
|
||||
end
|
||||
|
||||
r = RichText.new("markdown", "Click Me\n{:.btn.btn-warning}")
|
||||
# raise r.to_html
|
||||
assert_html r do
|
||||
assert_select "p[class='btn btn-warning']", false
|
||||
assert_select "p", /^Click Me$/
|
||||
end
|
||||
end
|
||||
|
||||
def test_markdown_to_text
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue