aozora2html 0.9.1 → 2.0.0

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: '0118a31e8b655b7a280b0c2e110c30547c391d3bb1d02a7d7ca354d1b12c2888'
4
- data.tar.gz: 6cc350ae9b8ee45b12e49f3b82d769814c1434b36500a827cf49690fdb242e6e
3
+ metadata.gz: 635bbe67e2511af4a4f8ccc8a820bdb87991d75d88fa9aa7ca9a90f2f67d7785
4
+ data.tar.gz: ac7c5d1f77f0c4b89d24f93e6117107d3ee4ac5890aef5e082368f0fa7e8e318
5
5
  SHA512:
6
- metadata.gz: b4061b71525025ec18e70d9df678e68d69f40790c30390f952d8b1e0c2b236df52136bbe003d718405da1d617b2b915a3c29c5af25ee82e4d1a25548c3eae3de
7
- data.tar.gz: c533d39bedd615022ee04dd58bcdd36849423f7735938e60bafead04cf8a1302549885785b6eadac802981e0046517e7ea3473e34dd5f757989ff7a25bd1957f
6
+ metadata.gz: a939ef551dd506ae1f7ca4d608fbbe747aa7b4ada56a07fd83385c330fade541353d80f66fa8f4ed5d1342cd01d65af74c6c973ed2979c1dce12dcc7b10830a2
7
+ data.tar.gz: 5c982a53cdffc60bad3c98406b74f640af4c1896fed6b42398a91025788962b4d2377950d40a0b25e4553fd92f94ac69c4ed8ac34fa21918cd0cb2148a1b0def
@@ -1,6 +1,15 @@
1
+ # Check if Ruby codes pass tests.
2
+ #
3
+ # Reference:
4
+ # - https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
5
+
1
6
  name: Test
2
7
 
3
- on: [push]
8
+ on:
9
+ push:
10
+ branches:
11
+ - master
12
+ pull_request:
4
13
 
5
14
  jobs:
6
15
  build:
@@ -9,12 +18,12 @@ jobs:
9
18
  strategy:
10
19
  fail-fast: false
11
20
  matrix:
12
- ruby: [ '2.6.x', '2.5.x', '2.4.x' ]
13
- os: [ubuntu-latest, macOS-latest, windows-latest]
21
+ ruby: [ '3.0', '2.7', '2.6', '2.5', '2.4' ]
22
+ os: [ubuntu-latest, macos-latest, windows-latest]
14
23
  steps:
15
24
  - uses: actions/checkout@v1
16
25
  - name: Set up Ruby
17
- uses: actions/setup-ruby@v1
26
+ uses: ruby/setup-ruby@v1
18
27
  with:
19
28
  ruby-version: ${{ matrix.ruby }}
20
29
  - name: Build and test with Rake
data/.gitignore CHANGED
@@ -1,4 +1,9 @@
1
- *~
2
- #*#
1
+ *#
3
2
  *.bak
4
- pkg
3
+ *~
4
+ /*.gem
5
+ /.ruby-version
6
+ /.yardoc/
7
+ /Gemfile.lock
8
+ /doc/
9
+ /pkg/
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  [![Gem Version](https://badge.fury.io/rb/aozora2html.svg)](https://badge.fury.io/rb/aozora2html)
6
6
  [![Code Climate](https://codeclimate.com/github/aozorahack/aozora2html/badges/gpa.svg)](https://codeclimate.com/github/aozorahack/aozora2html)
7
7
 
8
- 青空文庫の「組版案内」( http://kumihan.aozora.gr.jp/ )で配布されているtxt2html内にあるt2hs.rbを改造するプロジェクトです。
8
+ 青空文庫の[「組版案内」](http://kumihan.aozora.gr.jp/)で配布されている `txt2html`内にある`t2hs.rb`を改造するプロジェクトです。
9
9
 
10
10
  ## 動作環境
11
11
 
@@ -15,13 +15,13 @@ Ruby 2.0以上が推奨ですが、1.9でも動くはずです。
15
15
 
16
16
  RubyGemsとしてインストール可能になっています。
17
17
 
18
- ```
18
+ ```shell-session
19
19
  $ gem install aozora2html
20
20
  ```
21
21
 
22
22
  ソースからインストールするときは以下のようにします。
23
23
 
24
- ```
24
+ ```shell-session
25
25
  $ gem install bundler
26
26
  $ rake install
27
27
  ```
@@ -30,27 +30,27 @@ $ rake install
30
30
 
31
31
  コマンドは`aozora2html`です。以下のように実行します。
32
32
 
33
- ```
33
+ ```shell-session
34
34
  $ aozora2html foo.txt foo.html
35
35
  ```
36
36
 
37
- こうすると、青空文庫記法で書かれたfoo.txtfoo.htmlに変換します。
37
+ こうすると、青空文庫記法で書かれた`foo.txt`を`foo.html`に変換します。
38
38
 
39
39
  また、青空文庫サイトで配布している、中にテキストファイルが同梱されているzip形式のファイルも変換できます。
40
40
 
41
- ```
41
+ ```shell-session
42
42
  $ aozora2html foo.zip foo.html
43
43
  ```
44
44
 
45
45
  第1引数にURLを指定すると、そのURLのファイルをダウンロードして変換します。
46
46
 
47
- ```
47
+ ```shell-session
48
48
  $ aozora2html http://example.jp/foo/bar.zip foo.html
49
49
  ```
50
50
 
51
51
  第2引数を省略すると、ファイルではなく標準出力に変換結果を出力します。
52
52
 
53
- ```
53
+ ```shell-session
54
54
  $ aozora2html foo.txt
55
55
  ```
56
56
 
@@ -61,7 +61,7 @@ $ aozora2html foo.txt
61
61
 
62
62
  可能な限り数値実体参照を使って表示するには、以下のようにオプションを指定します。
63
63
 
64
- ```
64
+ ```shell-session
65
65
  $ aozora2html --use-jisx0213 --use-unicode foo.txt
66
66
  ```
67
67
 
@@ -69,7 +69,7 @@ $ aozora2html --use-jisx0213 --use-unicode foo.txt
69
69
 
70
70
  テストも追加しています。テストは以下のように実行します。
71
71
 
72
- ```
72
+ ```shell-session
73
73
  $ bundle install
74
74
  $ rake test
75
75
  ```
data/bin/aozora2html CHANGED
@@ -3,6 +3,7 @@
3
3
  require 'aozora2html'
4
4
  require 'optparse'
5
5
  require "tempfile"
6
+ require 'open-uri'
6
7
 
7
8
  opt = OptionParser.new("Usage: aozora2html [options] <text file> [<html file>]\n")
8
9
  opt.on('--gaiji-dir DIR', 'setting gaiji directory')
@@ -41,12 +42,9 @@ Dir.mktmpdir do |dir|
41
42
  dest_file = File.join(dir, "output.html")
42
43
  end
43
44
  if src_file =~ /\Ahttps?:/
44
- require 'open-uri'
45
45
  down_file = File.join(dir, File.basename(src_file))
46
46
  begin
47
- open(down_file, "wb") do |f0|
48
- open(src_file){|f1| f0.write(f1.read)}
49
- end
47
+ File.write(down_file, URI.parse(src_file).read)
50
48
  src_file = down_file
51
49
  rescue
52
50
  $stderr.print "file not found: #{src_file}\n"
@@ -1,3 +1,3 @@
1
1
  class Aozora2Html
2
- VERSION = "0.9.1"
2
+ VERSION = "2.0.0"
3
3
  end
data/lib/extensions.rb CHANGED
@@ -33,3 +33,12 @@ class String
33
33
  end
34
34
  end
35
35
 
36
+ module Kernel
37
+ alias original_kernel_puts puts
38
+
39
+ def puts(*args)
40
+ original_kernel_puts(args)
41
+ rescue Encoding::CompatibilityError
42
+ original_kernel_puts(args.map { |arg| arg.force_encoding('utf-8') })
43
+ end
44
+ end
data/test/test_i18n.rb ADDED
@@ -0,0 +1,23 @@
1
+ # encoding: utf-8
2
+ require 'test_helper'
3
+ require 'aozora2html'
4
+
5
+ class I18nTest < Test::Unit::TestCase
6
+ def test_t
7
+ assert_equal "警告(123行目):JIS外字「①」が使われています",
8
+ Aozora2Html::I18n.t(:warn_jis_gaiji,
9
+ 123,
10
+ "①".encode("cp932").force_encoding("shift_jis"))
11
+ .force_encoding("cp932").encode("utf-8")
12
+ end
13
+
14
+ def test_ruby_puts_behavior
15
+ $stdout = StringIO.new
16
+ begin
17
+ puts "①".encode("cp932").force_encoding("shift_jis")
18
+ assert_equal "①\n", $stdout.string.force_encoding("cp932").encode("utf-8")
19
+ ensure
20
+ $stdout = STDOUT
21
+ end
22
+ end
23
+ end
@@ -4,7 +4,7 @@ JIS X 0213の面区点番号からUnicode(UCS)の数値文字参照に変換す
4
4
 
5
5
  元となる対応表は、下記URLのものを使っています。
6
6
 
7
- http://w3.kcua.ac.jp/~fujiwara/jis2000/jis2004/jisx0213-2004-mono.html
7
+ <http://w3.kcua.ac.jp/~fujiwara/jis2000/jis2004/jisx0213-2004-mono.html>
8
8
 
9
9
  ## 生成方法
10
10
 
@@ -12,15 +12,12 @@ http://w3.kcua.ac.jp/~fujiwara/jis2000/jis2004/jisx0213-2004-mono.html
12
12
 
13
13
  `jis2ucs.rb`を生成するには、コマンドラインで以下のように実行します。
14
14
 
15
- ```
15
+ ```shell-session
16
16
  $ ruby mkconv.rb > ../../lib/aozora2html/jis2ucs.rb
17
17
  ```
18
18
 
19
19
  ## License
20
20
 
21
- jis2ucs.rbLicenseはCC0とします。
22
-
21
+ `jis2ucs.rb`のLicenseはCC0とします。
23
22
 
24
23
  Masayoshi Takahashi
25
-
26
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aozora2html
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - aozorahack team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-07 00:00:00.000000000 Z
11
+ date: 2021-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -169,6 +169,7 @@ files:
169
169
  - test/test_gaiji_tag.rb
170
170
  - test/test_header.rb
171
171
  - test/test_helper.rb
172
+ - test/test_i18n.rb
172
173
  - test/test_img_tag.rb
173
174
  - test/test_inline_caption_tag.rb
174
175
  - test/test_inline_font_size_tag.rb
@@ -212,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
212
213
  - !ruby/object:Gem::Version
213
214
  version: '0'
214
215
  requirements: []
215
- rubygems_version: 3.1.2
216
+ rubygems_version: 3.0.3.1
216
217
  signing_key:
217
218
  specification_version: 4
218
219
  summary: converter from Aozora Bunko format into xhtml. It's based of t2hs.rb from
@@ -231,6 +232,7 @@ test_files:
231
232
  - test/test_gaiji_tag.rb
232
233
  - test/test_header.rb
233
234
  - test/test_helper.rb
235
+ - test/test_i18n.rb
234
236
  - test/test_img_tag.rb
235
237
  - test/test_inline_caption_tag.rb
236
238
  - test/test_inline_font_size_tag.rb