]> git.openstreetmap.org Git - rails.git/commitdiff
Detect <p> as richtext paragraph
authorAnton Khorev <tony29@yandex.ru>
Wed, 7 Aug 2024 03:09:38 +0000 (06:09 +0300)
committerAnton Khorev <tony29@yandex.ru>
Wed, 7 Aug 2024 05:01:48 +0000 (08:01 +0300)
lib/rich_text.rb
test/lib/rich_text_test.rb

index b720f33e700cfe75536dddf1a6440afcc49361d8..b0b83cf5a44df703bfaf61a9d8dedc0bbbcb2a1e 100644 (file)
@@ -158,7 +158,7 @@ module RichText
     end
 
     def paragraph?(element)
     end
 
     def paragraph?(element)
-      element.type == :p
+      element.type == :p || (element.type == :html_element && element.value == "p")
     end
   end
 
     end
   end
 
index 3536db3989e7ffde8a2f539cc00a051e55eb9c98..929abf8230c033f1109d6edb44bb4efcf5ba7c97 100644 (file)
@@ -350,6 +350,11 @@ class RichTextTest < ActiveSupport::TestCase
     assert_equal "Something important here.", r.description
   end
 
     assert_equal "Something important here.", r.description
   end
 
+  def test_markdown_html_description
+    r = RichText.new("markdown", "<p>Can use HTML tags.</p>")
+    assert_equal "Can use HTML tags.", r.description
+  end
+
   private
 
   def assert_html(richtext, &block)
   private
 
   def assert_html(richtext, &block)