chupa-text-decomposer-html 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d18136db785fa061ef0bea3f17f8826a1ff55ed5020a591926e1700b91b9df38
4
- data.tar.gz: 2c173149ac68d34756944ce98caa32f1dbc5bba4f86dab0461505bb90a5d406f
3
+ metadata.gz: 8011fcf3e4474139ed2b25cb2119ba4c1e2f757933ee2a9f2df6d50803d0ffb8
4
+ data.tar.gz: '0198e6902575d462b1384f98c75de279ba82b391a70ee58638788a4c302f142c'
5
5
  SHA512:
6
- metadata.gz: 692141e0ed3d3d92729de8c47d62fa78ad6bc571070d293cdd8a7865e2d2366d82d68ef83121300dd92a82193b3db3ca83b7865ad6e0212c7e1b26e698830b13
7
- data.tar.gz: 061e659f770c63f304cc7b697b6f3c512ea0c975eac35d55a9de9ad434820f056477275e4a240e058a42ace0187b1240290050bf83984049593003e309694411
6
+ metadata.gz: d891df99acd083ac16e6a03659317257e3bee19dda9b25bf6d0219f9c76a8b7504c1b786d2051fc2529b7c6318fba76b1a96b9b1788b034adc914223a0665e57
7
+ data.tar.gz: 0dc3fb7c8362f442d6b23763c94fc2dce72c8a88f754e6ed533558eda960a93b0d32de23878476f49e7a7d2bd90d86ecb598e88aed3367509d44ab00cf532336
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- # -*- mode: ruby; coding: utf-8 -*-
1
+ # -*- ruby -*-
2
2
  #
3
- # Copyright (C) 2013-2017 Kouhei Sutou <kou@clear-code.com>
3
+ # Copyright (C) 2013-2026 Sutou Kouhei <kou@clear-code.com>
4
4
  #
5
5
  # This library is free software; you can redistribute it and/or
6
6
  # modify it under the terms of the GNU Lesser General Public
@@ -46,3 +46,13 @@ desc "Run tests"
46
46
  task :test do
47
47
  ruby("test/run-test.rb")
48
48
  end
49
+
50
+ release_task = Rake.application["release"]
51
+ # We use Trusted Publishing.
52
+ release_task.prerequisites.delete("build")
53
+ release_task.prerequisites.delete("release:rubygem_push")
54
+ release_task_comment = release_task.comment
55
+ if release_task_comment
56
+ release_task.clear_comments
57
+ release_task.comment = release_task_comment.gsub(/ and build.*$/, "")
58
+ end
@@ -22,7 +22,7 @@ end
22
22
 
23
23
  Gem::Specification.new do |spec|
24
24
  spec.name = "chupa-text-decomposer-html"
25
- spec.version = "1.0.4"
25
+ spec.version = "1.0.6"
26
26
  spec.homepage = "https://github.com/ranguba/chupa-text-decomposer-html"
27
27
  spec.authors = ["Kouhei Sutou"]
28
28
  spec.email = ["kou@clear-code.com"]
data/doc/text/news.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # News
2
2
 
3
+ ## 1.0.6: 2026-11-12
4
+
5
+ ### Fixes
6
+
7
+ * Fixed a bug that `Encoding::CompatibilityError` is raised on
8
+ detecting target with ASCII incompatible encoding body such as
9
+ ISO-2022-JP.
10
+
11
+ ## 1.0.5: 2024-09-22
12
+
13
+ ### Fixes
14
+
15
+ * Fixed typos.
16
+
3
17
  ## 1.0.4: 2024-09-22
4
18
 
5
19
  ### Improvements
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2024 Sutou Kouhei <kou@clear-code.com>
1
+ # Copyright (C) 2013-2026 Sutou Kouhei <kou@clear-code.com>
2
2
  #
3
3
  # This library is free software; you can redistribute it and/or
4
4
  # modify it under the terms of the GNU Lesser General Public
@@ -37,8 +37,11 @@ module ChupaText
37
37
  body = data.body
38
38
  return false if body.nil?
39
39
 
40
- return true if body.start_with?("<!DOCTYPE html ")
41
- return true if body.start_with?("<html")
40
+ # Compare as bytes because body may use an ASCII incompatible
41
+ # encoding such as ISO-2022-JP.
42
+ head = body.byteslice(0, 15).b
43
+ return true if head.start_with?("<!DOCTYPE html ")
44
+ return true if head.start_with?("<html")
42
45
 
43
46
  false
44
47
  end
@@ -108,8 +111,8 @@ module ChupaText
108
111
  candidates = [
109
112
  Encoding::EUC_JP,
110
113
  Encoding::WINDOWS_31J,
111
- Encoding::UTF16_BE,
112
- Encoding::UTF16_LE,
114
+ Encoding::UTF_16BE,
115
+ Encoding::UTF_16LE,
113
116
  ]
114
117
  candidates.each do |candidate|
115
118
  begin
data/test/test-html.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2024 Sutou Kouhei <kou@clear-code.com>
1
+ # Copyright (C) 2013-2026 Sutou Kouhei <kou@clear-code.com>
2
2
  #
3
3
  # This library is free software; you can redistribute it and/or
4
4
  # modify it under the terms of the GNU Lesser General Public
@@ -121,6 +121,26 @@ class TestHTML < Test::Unit::TestCase
121
121
  @decomposer.target?(create_data("<html"))
122
122
  end
123
123
  end
124
+
125
+ def test_iso_2022_jp
126
+ body = "<html><body>こんにちは</body></html>".encode("ISO-2022-JP")
127
+ assert do
128
+ @decomposer.target?(create_data(body))
129
+ end
130
+ end
131
+
132
+ def test_utf_16le
133
+ body = "<html><body>Hello</body></html>".encode("UTF-16LE")
134
+ assert do
135
+ not @decomposer.target?(create_data(body))
136
+ end
137
+ end
138
+
139
+ def test_text
140
+ assert do
141
+ not @decomposer.target?(create_data("Hello"))
142
+ end
143
+ end
124
144
  end
125
145
  end
126
146
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chupa-text-decomposer-html
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2024-09-22 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: chupa-text
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
78
  requirements: []
79
- rubygems_version: 3.6.0.dev
79
+ rubygems_version: 4.0.20
80
80
  specification_version: 4
81
81
  summary: This is a ChupaText decomposer plugin for to extract text and meta-data from
82
82
  HTML.