[Groonga-commit] ranguba/chupa-text-decomposer-html at d6abe41 [master] Ignore topic-path element

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Jul 10 11:40:36 JST 2017


Kouhei Sutou	2017-07-10 11:40:36 +0900 (Mon, 10 Jul 2017)

  New Revision: d6abe4168142924eba495436c65afd7f534aefc6
  https://github.com/ranguba/chupa-text-decomposer-html/commit/d6abe4168142924eba495436c65afd7f534aefc6

  Message:
    Ignore topic-path element

  Modified files:
    lib/chupa-text/decomposers/html.rb
    test/test-html.rb

  Modified: lib/chupa-text/decomposers/html.rb (+3 -3)
===================================================================
--- lib/chupa-text/decomposers/html.rb    2017-07-05 17:10:58 +0900 (9ccf9ed)
+++ lib/chupa-text/decomposers/html.rb    2017-07-10 11:40:36 +0900 (f92d6f5)
@@ -143,7 +143,7 @@ module ChupaText
 
       def header_element?(element, name, classes)
         case name
-        when "header", "nav"
+        when "header"
           return true
         end
 
@@ -191,13 +191,13 @@ module ChupaText
 
         classes.each do |klass|
           case klass
-          when "nav", "menu"
+          when "nav", "menu", /\Atopic[-_]?path\z/i
             return true
           end
         end
 
         case element["id"]
-        when "nav", "menu"
+        when "nav", "menu", /\Atopic[-_]?path\z/i
           return true
         end
 

  Modified: test/test-html.rb (+34 -0)
===================================================================
--- test/test-html.rb    2017-07-05 17:10:58 +0900 (6be657c)
+++ test/test-html.rb    2017-07-10 11:40:36 +0900 (217587a)
@@ -436,6 +436,23 @@ class TestHTML < Test::Unit::TestCase
                        decompose(@data))
         end
 
+        def test_topic_path_class
+          @data.body = <<-HTML
+<html>
+  <body>
+    Before
+    <div class="topic-path">topic-path</div>
+    <div class="topic_path">topic_path</div>
+    <div class="topicpath">topicpath</div>
+    <div class="TopicPath">TopicPath</div>
+    After
+  </body>
+</html>
+          HTML
+          assert_equal(["Before\nAfter"],
+                       decompose(@data))
+        end
+
         def test_nav_id
           @data.body = <<-HTML
 <html>
@@ -455,6 +472,23 @@ class TestHTML < Test::Unit::TestCase
           assert_equal(["BeforeAfter"],
                        decompose(@data))
         end
+
+        def test_topic_path_id
+          @data.body = <<-HTML
+<html>
+  <body>
+    Before
+    <div id="topic-path">topic-path</div>
+    <div id="topic_path">topic_path</div>
+    <div id="topicpath">topicpath</div>
+    <div id="TopicPath">TopicPath</div>
+    After
+  </body>
+</html>
+          HTML
+          assert_equal(["Before\nAfter"],
+                       decompose(@data))
+        end
       end
     end
   end
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index