+
+ 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}")
+ assert_html r do
+ assert_select "p[class='btn btn-warning']", false
+ assert_select "p", /^Click Me$/
+ end
+
+ r = RichText.new("markdown", "<p style='color:red'>Danger</p>")
+ assert_html r do
+ assert_select "p[style='color:red']", false
+ assert_select "p", /^Danger$/
+ end
+ end
+
+ def test_markdown_table_alignment
+ # Ensure that kramdown table alignment styles are converted to bootstrap classes
+ markdown_table = <<~MARKDOWN
+ | foo | bar |
+ |:----:|----:|
+ |center|right|
+ MARKDOWN
+ r = RichText.new("markdown", markdown_table)
+ assert_html r do
+ assert_select "td[style='text-align:center']", false
+ assert_select "td[class='text-center']", true
+ assert_select "td[style='text-align:right']", false
+ assert_select "td[class='text-end']", true
+ end
+ end
+
+ def test_markdown_to_text
+ r = RichText.new("markdown", "foo [bar](http://example.com/) baz")
+ assert_equal "foo [bar](http://example.com/) baz", r.to_text
+ end
+
+ def test_markdown_spam_score
+ r = RichText.new("markdown", "foo [bar](http://example.com/) baz")
+ assert_equal 50, r.spam_score.round