aozora2html 0.7.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/rubocop.yml +19 -0
  3. data/.github/workflows/ruby.yml +37 -0
  4. data/.gitignore +8 -3
  5. data/.rubocop.yml +111 -0
  6. data/.rubocop_todo.yml +7 -0
  7. data/CHANGELOG.md +59 -0
  8. data/Gemfile +2 -0
  9. data/Guardfile +3 -1
  10. data/HACKING.md +45 -0
  11. data/LICENSE +116 -0
  12. data/README.md +29 -16
  13. data/Rakefile +12 -5
  14. data/aozora2html.gemspec +24 -24
  15. data/bin/aozora2html +25 -71
  16. data/lib/aozora2html/accent_parser.rb +99 -0
  17. data/lib/aozora2html/error.rb +17 -0
  18. data/lib/aozora2html/header.rb +141 -0
  19. data/lib/aozora2html/i18n.rb +48 -0
  20. data/lib/aozora2html/ruby_buffer.rb +116 -0
  21. data/lib/aozora2html/string_refinements.rb +36 -0
  22. data/lib/aozora2html/style_stack.rb +33 -0
  23. data/lib/aozora2html/tag/accent.rb +37 -0
  24. data/lib/aozora2html/tag/block.rb +21 -0
  25. data/lib/aozora2html/tag/chitsuki.rb +19 -0
  26. data/lib/aozora2html/tag/dakuten_katakana.rb +25 -0
  27. data/lib/aozora2html/tag/decorate.rb +19 -0
  28. data/lib/aozora2html/tag/dir.rb +17 -0
  29. data/lib/aozora2html/tag/editor_note.rb +19 -0
  30. data/lib/aozora2html/tag/embed_gaiji.rb +52 -0
  31. data/lib/aozora2html/tag/font_size.rb +20 -0
  32. data/lib/aozora2html/tag/gaiji.rb +12 -0
  33. data/lib/aozora2html/tag/img.rb +21 -0
  34. data/lib/aozora2html/tag/indent.rb +8 -0
  35. data/lib/aozora2html/tag/inline.rb +16 -0
  36. data/lib/aozora2html/tag/inline_caption.rb +17 -0
  37. data/lib/aozora2html/tag/inline_font_size.rb +19 -0
  38. data/lib/aozora2html/tag/inline_keigakomi.rb +17 -0
  39. data/lib/aozora2html/tag/inline_yokogumi.rb +17 -0
  40. data/lib/aozora2html/tag/jisage.rb +17 -0
  41. data/lib/aozora2html/tag/jizume.rb +19 -0
  42. data/lib/aozora2html/tag/kaeriten.rb +17 -0
  43. data/lib/aozora2html/tag/keigakomi.rb +19 -0
  44. data/lib/aozora2html/tag/kunten.rb +12 -0
  45. data/lib/aozora2html/tag/midashi.rb +20 -0
  46. data/lib/aozora2html/tag/multiline.rb +9 -0
  47. data/lib/aozora2html/tag/multiline_caption.rb +13 -0
  48. data/lib/aozora2html/tag/multiline_chitsuki.rb +10 -0
  49. data/lib/aozora2html/tag/multiline_jisage.rb +10 -0
  50. data/lib/aozora2html/tag/multiline_midashi.rb +25 -0
  51. data/lib/aozora2html/tag/multiline_style.rb +19 -0
  52. data/lib/aozora2html/tag/multiline_yokogumi.rb +14 -0
  53. data/lib/aozora2html/tag/okurigana.rb +17 -0
  54. data/lib/aozora2html/tag/oneline_chitsuki.rb +10 -0
  55. data/lib/aozora2html/tag/oneline_indent.rb +9 -0
  56. data/lib/aozora2html/tag/oneline_jisage.rb +10 -0
  57. data/lib/aozora2html/tag/reference_mentioned.rb +47 -0
  58. data/lib/aozora2html/tag/ruby.rb +202 -0
  59. data/lib/aozora2html/tag/un_embed_gaiji.rb +30 -0
  60. data/lib/aozora2html/tag.rb +57 -0
  61. data/lib/aozora2html/tag_parser.rb +60 -0
  62. data/lib/aozora2html/text_buffer.rb +50 -0
  63. data/lib/aozora2html/utils.rb +156 -0
  64. data/lib/aozora2html/version.rb +3 -1
  65. data/lib/aozora2html/yaml_loader.rb +37 -0
  66. data/lib/aozora2html/zip.rb +4 -0
  67. data/lib/aozora2html.rb +1359 -8
  68. data/lib/extensions.rb +12 -0
  69. data/lib/jstream.rb +139 -0
  70. data/sample/chukiichiran_kinyurei.html +15 -2
  71. data/sample/chukiichiran_kinyurei.txt +15 -2
  72. data/test/test_aozora2html.rb +323 -73
  73. data/test/test_aozora_accent_parser.rb +34 -6
  74. data/test/test_command_parse.rb +216 -0
  75. data/test/test_compat.rb +3 -4
  76. data/test/test_dakuten_katakana_tag.rb +12 -13
  77. data/test/test_decorate_tag.rb +11 -7
  78. data/test/test_dir_tag.rb +11 -7
  79. data/test/test_editor_note_tag.rb +9 -6
  80. data/test/test_exception.rb +11 -9
  81. data/test/test_font_size_tag.rb +22 -11
  82. data/test/test_gaiji_tag.rb +22 -14
  83. data/test/test_header.rb +45 -0
  84. data/test/test_helper.rb +3 -1
  85. data/test/test_i18n.rb +39 -0
  86. data/test/test_img_tag.rb +11 -6
  87. data/test/test_inline_caption_tag.rb +11 -7
  88. data/test/test_inline_font_size_tag.rb +15 -11
  89. data/test/test_inline_keigakomi_tag.rb +11 -7
  90. data/test/test_inline_yokogumi_tag.rb +11 -7
  91. data/test/test_jizume_tag.rb +11 -8
  92. data/test/test_jstream.rb +33 -30
  93. data/test/test_kaeriten_tag.rb +11 -7
  94. data/test/test_keigakomi_tag.rb +14 -11
  95. data/test/test_midashi_tag.rb +39 -0
  96. data/test/test_multiline_caption_tag.rb +11 -8
  97. data/test/test_multiline_midashi_tag.rb +26 -26
  98. data/test/test_multiline_style_tag.rb +11 -8
  99. data/test/test_multiline_yokogumi_tag.rb +11 -8
  100. data/test/test_okurigana_tag.rb +11 -7
  101. data/test/test_ruby_parse.rb +130 -0
  102. data/test/test_ruby_tag.rb +11 -7
  103. data/test/test_tag_parser.rb +31 -29
  104. data/vendor/jis2ucs/README.md +3 -6
  105. data/yml/accent_table.yml +240 -0
  106. data/yml/command_table.yml +61 -0
  107. data/yml/jis2ucs.yml +11234 -0
  108. metadata +99 -21
  109. data/.travis.yml +0 -12
  110. data/appveyor.yml +0 -23
  111. data/lib/accent_tag.rb +0 -23
  112. data/lib/aozora2html/jis2ucs.rb +0 -11237
  113. data/lib/embed_gaiji_tag.rb +0 -34
  114. data/lib/t2hs.rb +0 -2535
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 69f585eb774610409f4a56b1645bc2ebdf71ce35
4
- data.tar.gz: c2c28ed11b58ca3d6df952f3b5709d14184e48f4
2
+ SHA256:
3
+ metadata.gz: 5a2a25b5bae94f8cd3f95db62357eb5de12a99fafe7681132ca045067f72dadc
4
+ data.tar.gz: 8e4474f765260485a1f4917de8cf8b81438f6a6863b2614b9e5d3f9d50abca29
5
5
  SHA512:
6
- metadata.gz: 9291546c4ff8e76d64e0e1eaa32474efcea5c6d952e8215841d2a0d1da0beccae37d01a4dd8d1689ebd9ff962b6511d1811e6e3b4d3b381be8d102ccd63356b4
7
- data.tar.gz: 23235e3da67c52b05cfb648275888ee82239f94e1f47d3a78261188ae4eaa110e1ca18dc5d9b8af1113e054e00f56586976fb5fb7fb99628175c2f0c2625d4ce
6
+ metadata.gz: b61e229c27b0b90fca3982e566b7fd51683ee9cabc0c1b77988c46d994ac5fb20d295ad5916da8b7a70947337bad034f45780ad335b9f9993562cf655e6b056f
7
+ data.tar.gz: 4c693c649646c27596545ae7f0577b1336d9afdb21d6380f63f9e2558253796b1c37d54818a9cc90414a01cf0fdcf5e1e01b2997a31fc86a1c770d9d42e3b5ac
@@ -0,0 +1,19 @@
1
+ name: rubocop
2
+ on: [pull_request]
3
+ jobs:
4
+ rubocop:
5
+ name: runner / rubocop
6
+ runs-on: ubuntu-latest
7
+ steps:
8
+ - name: Check out code
9
+ uses: actions/checkout@v2
10
+ - name: Setup Ruby
11
+ uses: ruby/setup-ruby@v1
12
+ with:
13
+ ruby-version: 3.0.3
14
+ bundler-cache: true
15
+ - name: Run rubocop
16
+ run: |
17
+ gem install bundler --no-document
18
+ bundle install --retry 3
19
+ bundle exec rubocop -P
@@ -0,0 +1,37 @@
1
+ # Check if Ruby codes pass tests.
2
+ #
3
+ # Reference:
4
+ # - https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
5
+
6
+ name: Test
7
+
8
+ on:
9
+ push:
10
+ branches:
11
+ - master
12
+ pull_request:
13
+
14
+ jobs:
15
+ build:
16
+
17
+ runs-on: ${{ matrix.os }}
18
+ strategy:
19
+ fail-fast: false
20
+ matrix:
21
+ ruby: [ '3.1', '3.0', '2.7' ]
22
+ os: [ubuntu-latest, macos-latest, windows-latest]
23
+ exclude:
24
+ - os: windows-latest
25
+ ruby: '3.1'
26
+ steps:
27
+ - uses: actions/checkout@v1
28
+ - name: Set up Ruby
29
+ uses: ruby/setup-ruby@v1
30
+ with:
31
+ ruby-version: ${{ matrix.ruby }}
32
+ - name: Build and test with Rake
33
+ shell: bash
34
+ run: |
35
+ gem install bundler --no-document
36
+ bundle install --jobs 4 --retry 3
37
+ bundle exec 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/.rubocop.yml ADDED
@@ -0,0 +1,111 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ # inherit_from: .rubocop_todo.yml
4
+
5
+ require:
6
+ - rubocop-performance
7
+ - rubocop-rake
8
+
9
+ AllCops:
10
+ TargetRubyVersion: 2.7
11
+ NewCops: enable
12
+
13
+ Style/BarePercentLiterals:
14
+ EnforcedStyle: percent_q
15
+
16
+ Style/Documentation:
17
+ Exclude:
18
+ - 'test/**/*'
19
+
20
+ Style/EmptyMethod:
21
+ EnforcedStyle: expanded
22
+ Enabled: true
23
+
24
+ Style/FormatString:
25
+ EnforcedStyle: sprintf
26
+
27
+ Style/FormatStringToken:
28
+ EnforcedStyle: unannotated
29
+
30
+ Style/FrozenStringLiteralComment:
31
+ Exclude:
32
+ - 'lib/aozora2html.rb'
33
+
34
+ Style/RedundantPercentQ:
35
+ Enabled: false
36
+
37
+ Style/PercentQLiterals:
38
+ Enabled: false
39
+
40
+ Style/ParallelAssignment:
41
+ Enabled: false
42
+
43
+ Style/AsciiComments:
44
+ Enabled: false
45
+
46
+ Style/LineEndConcatenation:
47
+ Enabled: false
48
+
49
+ Style/IfUnlessModifier:
50
+ Enabled: false
51
+
52
+ Style/NumericPredicate:
53
+ Enabled: false
54
+
55
+ Style/PerlBackrefs:
56
+ Enabled: false
57
+
58
+ Style/SpecialGlobalVars:
59
+ Enabled: false
60
+
61
+ Style/SymbolArray:
62
+ EnforcedStyle: brackets
63
+
64
+ Style/WordArray:
65
+ EnforcedStyle: brackets
66
+
67
+ Style/ZeroLengthPredicate:
68
+ Enabled: false
69
+
70
+ Layout/LineLength:
71
+ Enabled: true
72
+ Max: 500
73
+
74
+ Lint/EmptyClass:
75
+ AllowComments: true
76
+
77
+ Metrics/AbcSize:
78
+ Enabled: true
79
+ Max: 260.05
80
+
81
+ Metrics/BlockLength:
82
+ Enabled: true
83
+ Max: 150
84
+
85
+ Metrics/BlockNesting:
86
+ Enabled: true
87
+ Max: 10
88
+
89
+ Metrics/ClassLength:
90
+ Enabled: true
91
+ Max: 2000
92
+
93
+ Metrics/CyclomaticComplexity:
94
+ Enabled: true
95
+ Max: 100
96
+
97
+ Metrics/MethodLength:
98
+ Enabled: true
99
+ Max: 200
100
+
101
+ Metrics/ModuleLength:
102
+ Enabled: true
103
+ Max: 200
104
+
105
+ Metrics/ParameterLists:
106
+ Enabled: true
107
+ Max: 10
108
+
109
+ Metrics/PerceivedComplexity:
110
+ Enabled: true
111
+ Max: 100
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,7 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config --exclude-limit 99999 --no-offense-counts --no-auto-gen-timestamp`
3
+ # using RuboCop version 1.23.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,62 @@
1
+ <a name="3.0.0"></a>
2
+ ## 3.0.0
3
+
4
+ ### Breaking Changes
5
+
6
+ * Ruby 2.7未満をサポート対象外にしました。Ruby 3.0以降を推奨します。それ以前のRubyを使われる場合はv2.0.0をご利用ください https://github.com/aozorahack/aozora2html/pull/49
7
+ * t2hs.rbを廃止し、bin/aozora2html以外からは実行できなくしました https://github.com/aozorahack/aozora2html/pull/65 
8
+ * t2hs.rbにあったメソッドのうち、通常外部から使われないメソッドをprivateにしました https://github.com/aozorahack/aozora2html/pull/93
9
+
10
+ ### Bug Fixes
11
+
12
+ * 以前は全角空白であったところが半角空白になっていたので修正しました https://github.com/aozorahack/aozora2html/pull/62
13
+
14
+ ### Features
15
+
16
+ * エラーメッセージがUTF-8になる `--error-utf8` オプションを追加しました https://github.com/aozorahack/aozora2html/pull/72
17
+ * `sample/chukiichiran_kinyurei.txt`に他の例を追加しました https://github.com/aozorahack/aozora2html/pull/78
18
+ * `rake chuuki`で`sample/chukiichiran_kinyurei.txt`を`sample/chukiichiran_kinyurei.html`に変換できるrakeタスクを追加しました https://github.com/aozorahack/aozora2html/pull/95
19
+
20
+ <a name="2.0.0"></a>
21
+ ## 2.0.0
22
+
23
+ ### Bug Fixes
24
+
25
+ * Ruby 3.0でエラーになる挙動を修正しました https://github.com/aozorahack/aozora2html/pull/36, https://github.com/aozorahack/aozora2html/pull/41
26
+
27
+ <a name="0.9.1"></a>
28
+ ## 0.9.1
29
+
30
+ ### Features
31
+
32
+ * 内部構造を改造した
33
+ * lib/t2hs.rbをUTF-8化した
34
+
35
+ <a name="0.9.0"></a>
36
+ ## 0.9.0
37
+
38
+ ### Features
39
+
40
+ * 内部構造を大改造した
41
+ * lib/t2hs.rb内で定義されているクラスをRubyの命名規則に合わせて変更し、外部ファイルにした
42
+ * `Aozora2Html.new(input, output)`の引数`input`,`output`でIOも受け取れるようにした
43
+ * `bin/aozora2html`にあったmonkey patchingも`lib/`以下に移動させた
44
+
45
+ <a name="0.7.1"></a>
46
+ ## 0.7.1
47
+
48
+ ### Bug Fixes
49
+
50
+ * `--use-unicode`オプションをつけていない時の外字処理を修正した
51
+ * くの字点が正しく処理されない場合があるのを修正した
52
+
53
+ <a name="0.7.0"></a>
54
+ ## 0.7.0
55
+
56
+ ### Features
57
+
58
+ * `--css-files`オプションを追加して、CSSを変更できるようにした
59
+
1
60
  <a name="0.6.1"></a>
2
61
  ## 0.6.1
3
62
 
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in aozora2html.gemspec
data/Guardfile CHANGED
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  guard :test do
2
4
  watch(%r{^test/test_.+\.rb$})
3
- watch('test/test_helper.rb') { 'test' }
5
+ watch('test/test_helper.rb') { 'test' }
4
6
 
5
7
  # Non-rails
6
8
  watch(%r{^lib/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
data/HACKING.md ADDED
@@ -0,0 +1,45 @@
1
+ # HACKING
2
+
3
+ aozora2htmlの技術的なnoteです。
4
+
5
+ ## `char_type`について
6
+
7
+ aozora2htmlでは、`String#char_type`というメソッドが追加されています。
8
+
9
+ `char_type`はルビの範囲を判別するために使われるメソッドです。
10
+
11
+ * ひらがな: :hiragana
12
+ * カタカナ: :katakana
13
+ * 全角英数(ギリシア文字含む): :zenkaku
14
+ * 半角英数(記号#-&',含む): :hankaku
15
+ * 漢字: :kanji
16
+ * 半角句読点等(.;"?!)): :hankaku_terminate
17
+ * その他: :else
18
+
19
+ 欧文アクセント文字は半角英数、濁点つきカタカナはカタカナ、外字は漢字、訓点はその他、ルビ付き文字はその他になります。
20
+
21
+ RubyBufferも`RubyBuffer#char_type`を持っています。これはRubyBufferの中身次第で変更されます。複数のchar_typeを内部で持つ場合、char_typeは:elseになります。
22
+
23
+
24
+ ## `Aozora2Html::TextBuffer`について
25
+
26
+ 古いRubyでは、`Array#to_s`はArrayの全要素が文字列だった場合、`join`と同じ挙動でした。
27
+
28
+ 現在のRubyでは、同様のことをするには`Array#join`を使わなければならなくなっており、`Array#to_s`をすると`[]`等が出力されます。これは埋め込み文字列に使った場合も同様です。
29
+ そのため、aozora2htmlでは`Array`の代わりに`Aozora2Html::TextBuffer`クラスを導入しています。`Aozora2Html::TextBuffer#to_s`は適切な文字列を返します。
30
+
31
+
32
+ ## `Jstream`について
33
+
34
+ `JStream`は`IO`の代わりとなるクラスです。
35
+
36
+ 主に、読み込み行の行数の管理と、任意の文字数の先読みを行うために使われています。
37
+
38
+ 先読みは同一行内のみ有効で、CRLFを超える先読みは動作が保証されません。
39
+
40
+
41
+ ## `Aozora2Html::Tag::Multiline`について
42
+
43
+ `Aozora2Html::Tag::Multiline`は、そのタグが複数行であることを表すマーカー用のモジュールです。
44
+
45
+ マーカーとして使われるため、メソッド等は特に持っていない、空のモジュールとして実装されています。実行中に追加されたりすることもありません。
data/LICENSE ADDED
@@ -0,0 +1,116 @@
1
+ CC0 1.0 Universal
2
+
3
+ Statement of Purpose
4
+
5
+ The laws of most jurisdictions throughout the world automatically confer
6
+ exclusive Copyright and Related Rights (defined below) upon the creator and
7
+ subsequent owner(s) (each and all, an "owner") of an original work of
8
+ authorship and/or a database (each, a "Work").
9
+
10
+ Certain owners wish to permanently relinquish those rights to a Work for the
11
+ purpose of contributing to a commons of creative, cultural and scientific
12
+ works ("Commons") that the public can reliably and without fear of later
13
+ claims of infringement build upon, modify, incorporate in other works, reuse
14
+ and redistribute as freely as possible in any form whatsoever and for any
15
+ purposes, including without limitation commercial purposes. These owners may
16
+ contribute to the Commons to promote the ideal of a free culture and the
17
+ further production of creative, cultural and scientific works, or to gain
18
+ reputation or greater distribution for their Work in part through the use and
19
+ efforts of others.
20
+
21
+ For these and/or other purposes and motivations, and without any expectation
22
+ of additional consideration or compensation, the person associating CC0 with a
23
+ Work (the "Affirmer"), to the extent that he or she is an owner of Copyright
24
+ and Related Rights in the Work, voluntarily elects to apply CC0 to the Work
25
+ and publicly distribute the Work under its terms, with knowledge of his or her
26
+ Copyright and Related Rights in the Work and the meaning and intended legal
27
+ effect of CC0 on those rights.
28
+
29
+ 1. Copyright and Related Rights. A Work made available under CC0 may be
30
+ protected by copyright and related or neighboring rights ("Copyright and
31
+ Related Rights"). Copyright and Related Rights include, but are not limited
32
+ to, the following:
33
+
34
+ i. the right to reproduce, adapt, distribute, perform, display, communicate,
35
+ and translate a Work;
36
+
37
+ ii. moral rights retained by the original author(s) and/or performer(s);
38
+
39
+ iii. publicity and privacy rights pertaining to a person's image or likeness
40
+ depicted in a Work;
41
+
42
+ iv. rights protecting against unfair competition in regards to a Work,
43
+ subject to the limitations in paragraph 4(a), below;
44
+
45
+ v. rights protecting the extraction, dissemination, use and reuse of data in
46
+ a Work;
47
+
48
+ vi. database rights (such as those arising under Directive 96/9/EC of the
49
+ European Parliament and of the Council of 11 March 1996 on the legal
50
+ protection of databases, and under any national implementation thereof,
51
+ including any amended or successor version of such directive); and
52
+
53
+ vii. other similar, equivalent or corresponding rights throughout the world
54
+ based on applicable law or treaty, and any national implementations thereof.
55
+
56
+ 2. Waiver. To the greatest extent permitted by, but not in contravention of,
57
+ applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and
58
+ unconditionally waives, abandons, and surrenders all of Affirmer's Copyright
59
+ and Related Rights and associated claims and causes of action, whether now
60
+ known or unknown (including existing as well as future claims and causes of
61
+ action), in the Work (i) in all territories worldwide, (ii) for the maximum
62
+ duration provided by applicable law or treaty (including future time
63
+ extensions), (iii) in any current or future medium and for any number of
64
+ copies, and (iv) for any purpose whatsoever, including without limitation
65
+ commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes
66
+ the Waiver for the benefit of each member of the public at large and to the
67
+ detriment of Affirmer's heirs and successors, fully intending that such Waiver
68
+ shall not be subject to revocation, rescission, cancellation, termination, or
69
+ any other legal or equitable action to disrupt the quiet enjoyment of the Work
70
+ by the public as contemplated by Affirmer's express Statement of Purpose.
71
+
72
+ 3. Public License Fallback. Should any part of the Waiver for any reason be
73
+ judged legally invalid or ineffective under applicable law, then the Waiver
74
+ shall be preserved to the maximum extent permitted taking into account
75
+ Affirmer's express Statement of Purpose. In addition, to the extent the Waiver
76
+ is so judged Affirmer hereby grants to each affected person a royalty-free,
77
+ non transferable, non sublicensable, non exclusive, irrevocable and
78
+ unconditional license to exercise Affirmer's Copyright and Related Rights in
79
+ the Work (i) in all territories worldwide, (ii) for the maximum duration
80
+ provided by applicable law or treaty (including future time extensions), (iii)
81
+ in any current or future medium and for any number of copies, and (iv) for any
82
+ purpose whatsoever, including without limitation commercial, advertising or
83
+ promotional purposes (the "License"). The License shall be deemed effective as
84
+ of the date CC0 was applied by Affirmer to the Work. Should any part of the
85
+ License for any reason be judged legally invalid or ineffective under
86
+ applicable law, such partial invalidity or ineffectiveness shall not
87
+ invalidate the remainder of the License, and in such case Affirmer hereby
88
+ affirms that he or she will not (i) exercise any of his or her remaining
89
+ Copyright and Related Rights in the Work or (ii) assert any associated claims
90
+ and causes of action with respect to the Work, in either case contrary to
91
+ Affirmer's express Statement of Purpose.
92
+
93
+ 4. Limitations and Disclaimers.
94
+
95
+ a. No trademark or patent rights held by Affirmer are waived, abandoned,
96
+ surrendered, licensed or otherwise affected by this document.
97
+
98
+ b. Affirmer offers the Work as-is and makes no representations or warranties
99
+ of any kind concerning the Work, express, implied, statutory or otherwise,
100
+ including without limitation warranties of title, merchantability, fitness
101
+ for a particular purpose, non infringement, or the absence of latent or
102
+ other defects, accuracy, or the present or absence of errors, whether or not
103
+ discoverable, all to the greatest extent permissible under applicable law.
104
+
105
+ c. Affirmer disclaims responsibility for clearing rights of other persons
106
+ that may apply to the Work or any use thereof, including without limitation
107
+ any person's Copyright and Related Rights in the Work. Further, Affirmer
108
+ disclaims responsibility for obtaining any necessary consents, permissions
109
+ or other rights required for any use of the Work.
110
+
111
+ d. Affirmer understands and acknowledges that Creative Commons is not a
112
+ party to this document and has no duty or obligation with respect to this
113
+ CC0 or use of the Work.
114
+
115
+ For more information, please see
116
+ <http://creativecommons.org/publicdomain/zero/1.0/>
data/README.md CHANGED
@@ -1,24 +1,28 @@
1
1
  # Aozora2Html
2
2
 
3
- [![Build Status](https://travis-ci.org/aozorahack/aozora2html.svg?branch=master)](https://travis-ci.org/aozorahack/aozora2html) [![Gem Version](https://badge.fury.io/rb/aozora2html.svg)](https://badge.fury.io/rb/aozora2html) [![Build Status](https://ci.appveyor.com/api/projects/status/9ds6wksavm50ha9v/branch/master?svg=true)](https://ci.appveyor.com/project/takahashim/aozora2html/branch/master) [![Code Climate](https://codeclimate.com/github/aozorahack/aozora2html/badges/gpa.svg)](https://codeclimate.com/github/aozorahack/aozora2html)
3
+ [![Build Status](https://github.com/aozorahack/aozora2html/workflows/Test/badge.svg)](https://github.com/aozorahack/aozora2html/actions)
4
+ [![Gem Version](https://badge.fury.io/rb/aozora2html.svg)](https://badge.fury.io/rb/aozora2html)
5
+ [![Code Climate](https://codeclimate.com/github/aozorahack/aozora2html/badges/gpa.svg)](https://codeclimate.com/github/aozorahack/aozora2html)
4
6
 
5
- 青空文庫の「組版案内」( http://kumihan.aozora.gr.jp/ )で配布されているtxt2html内にあるt2hs.rbを改造するプロジェクトです。
7
+ 青空文庫の[「組版案内」](http://kumihan.aozora.gr.jp/)で配布されている `txt2html`内にある`t2hs.rb`を改造するプロジェクトです。
6
8
 
7
9
  ## 動作環境
8
10
 
9
- Ruby 2.0以上が推奨ですが、1.9でも動くはずです。
11
+ Ruby 3.0以上が推奨ですが、2.7.xでも動くはずです。
12
+
13
+ それ以前のRuby 2.xで利用する場合は、aozora2html-2.0.xをご利用ください。
10
14
 
11
15
  ## インストール
12
16
 
13
17
  RubyGemsとしてインストール可能になっています。
14
18
 
15
- ```
19
+ ```shell-session
16
20
  $ gem install aozora2html
17
21
  ```
18
22
 
19
23
  ソースからインストールするときは以下のようにします。
20
24
 
21
- ```
25
+ ```shell-session
22
26
  $ gem install bundler
23
27
  $ rake install
24
28
  ```
@@ -27,38 +31,41 @@ $ rake install
27
31
 
28
32
  コマンドは`aozora2html`です。以下のように実行します。
29
33
 
30
- ```
34
+ ```shell-session
31
35
  $ aozora2html foo.txt foo.html
32
36
  ```
33
37
 
34
- こうすると、青空文庫記法で書かれたfoo.txtfoo.htmlに変換します。
38
+ こうすると、青空文庫記法で書かれた`foo.txt`を`foo.html`に変換します。
35
39
 
36
40
  また、青空文庫サイトで配布している、中にテキストファイルが同梱されているzip形式のファイルも変換できます。
37
41
 
38
- ```
42
+ ```shell-session
39
43
  $ aozora2html foo.zip foo.html
40
44
  ```
41
45
 
42
46
  第1引数にURLを指定すると、そのURLのファイルをダウンロードして変換します。
43
47
 
44
- ```
48
+ ```shell-session
45
49
  $ aozora2html http://example.jp/foo/bar.zip foo.html
46
50
  ```
47
51
 
48
52
  第2引数を省略すると、ファイルではなく標準出力に変換結果を出力します。
49
53
 
50
- ```
54
+ ```shell-session
51
55
  $ aozora2html foo.txt
52
56
  ```
53
57
 
54
- コマンドラインオプションとして`--gaiji-dir`と`--use-jisx0213`、`--use-unicode`があります。
55
- `--gaiji-dir`は外字画像のパスを指定します。
56
- `--use-jisx0213`はJIS X 0213の外字画像を使わず、数値実体参照として表示します。
57
- `--use-unicode`はUnicodeのコードポイントが指定されている外字を数値実体参照として表示します。
58
+ コマンドラインオプションとして`--gaiji-dir`と`--css-files`、`--use-jisx0213`、`--use-unicode`、`--error-utf8`があります。
59
+
60
+ * `--gaiji-dir`は外字画像のパスを指定します。
61
+ * `--css-files`はCSSファイルを`,`区切りで指定します。
62
+ * `--use-jisx0213`はJIS X 0213の外字画像を使わず、数値実体参照として表示します。
63
+ * `--use-unicode`はUnicodeのコードポイントが指定されている外字を数値実体参照として表示します。
64
+ * `--error-utf8`はエラーメッセージをUTF-8で出力するようにします。
58
65
 
59
66
  可能な限り数値実体参照を使って表示するには、以下のようにオプションを指定します。
60
67
 
61
- ```
68
+ ```shell-session
62
69
  $ aozora2html --use-jisx0213 --use-unicode foo.txt
63
70
  ```
64
71
 
@@ -66,7 +73,7 @@ $ aozora2html --use-jisx0213 --use-unicode foo.txt
66
73
 
67
74
  テストも追加しています。テストは以下のように実行します。
68
75
 
69
- ```
76
+ ```shell-session
70
77
  $ bundle install
71
78
  $ rake test
72
79
  ```
@@ -75,8 +82,14 @@ $ rake test
75
82
 
76
83
  主な更新履歴は[CHANGELOG.md](CHANGELOG.md)にあります。
77
84
 
85
+ ## コードについて
86
+
87
+ コードに関する技術的なnoteは[HACKING.md](HACKING.md)にあります。
88
+
78
89
  ## License
79
90
 
80
91
  CC0
81
92
 
93
+ [![CC0](http://i.creativecommons.org/p/zero/1.0/88x31.png "CC0")](http://creativecommons.org/publicdomain/zero/1.0/deed.ja)
94
+
82
95
  To the extent possible under law, 青空文庫 has waived all copyright and related or neighboring rights to txt2xhtml. This work is published from Japan.
data/Rakefile CHANGED
@@ -1,12 +1,19 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rubygems'
2
- require "bundler/gem_tasks"
4
+ require 'bundler/gem_tasks'
3
5
  require 'rake/testtask'
4
6
  require 'rake/clean'
5
7
 
6
- task :default => [:test]
8
+ task default: [:test]
7
9
 
8
- Rake::TestTask.new("test") do |t|
9
- t.libs << "test"
10
- t.test_files = Dir.glob("test/**/test_*.rb")
10
+ Rake::TestTask.new('test') do |t|
11
+ t.libs << 'test'
12
+ t.test_files = Dir.glob('test/**/test_*.rb')
11
13
  t.verbose = true
12
14
  end
15
+
16
+ desc 'convert sample/chukiichiran_kinyurei.txt'
17
+ task :chuuki do
18
+ sh 'bundle exec aozora2html --error-utf8 sample/chukiichiran_kinyurei.txt sample/chukiichiran_kinyurei.html'
19
+ end
data/aozora2html.gemspec CHANGED
@@ -1,35 +1,35 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'aozora2html/version'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/aozora2html/version'
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = "aozora2html"
6
+ spec.name = 'aozora2html'
8
7
  spec.version = Aozora2Html::VERSION
9
8
  spec.platform = Gem::Platform::RUBY
10
- spec.license = "CC0"
11
- spec.authors = ["aozorahack team"]
12
- spec.email = ["takahashimm@gmail.com"]
9
+ spec.license = 'CC0'
10
+ spec.authors = ['aozorahack team']
11
+ spec.email = ['takahashimm@gmail.com']
13
12
 
14
- spec.summary = %q{converter from Aozora Bunko format into xhtml. It's based of t2hs.rb from kumihan.aozora.gr.jp.}
15
- spec.description = %q{converter from Aozora Bunko format into xhtml. It's based of t2hs.rb from kumihan.aozora.gr.jp.}
16
- spec.homepage = "https://github.com/aozorahack/aozora2html"
13
+ spec.summary = %q(converter from Aozora Bunko format into xhtml. It's based of t2hs.rb from kumihan.aozora.gr.jp.)
14
+ spec.description = %q(converter from Aozora Bunko format into xhtml. It's based of t2hs.rb from kumihan.aozora.gr.jp.)
15
+ spec.homepage = 'https://github.com/aozorahack/aozora2html'
17
16
 
17
+ spec.required_ruby_version = '>= 2.7.0'
18
18
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
- spec.bindir = "bin"
19
+ spec.bindir = 'bin'
20
20
  spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
21
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
22
- spec.require_paths = ["lib"]
22
+ spec.require_paths = ['lib']
23
23
 
24
- spec.add_dependency "rubyzip"
25
- spec.add_development_dependency "bundler"
26
- spec.add_development_dependency "rake", "~> 10.0"
27
- spec.add_development_dependency "test-unit"
28
- spec.add_development_dependency "test-unit-rr"
29
- # spec.add_development_dependency "test-unit-notify"
30
- # spec.add_development_dependency "terminal-notifier"
31
- if RUBY_VERSION > "2.2.0"
32
- spec.add_development_dependency "guard"
33
- spec.add_development_dependency "guard-test"
34
- end
24
+ spec.add_dependency 'rubyzip'
25
+ spec.add_development_dependency 'bundler'
26
+ spec.add_development_dependency 'rake', '~> 12.0'
27
+ spec.add_development_dependency 'rubocop'
28
+ spec.add_development_dependency 'rubocop-performance'
29
+ spec.add_development_dependency 'rubocop-rake'
30
+ spec.add_development_dependency 'test-unit'
31
+ spec.add_development_dependency 'test-unit-rr'
32
+ spec.metadata = {
33
+ 'rubygems_mfa_required' => 'true'
34
+ }
35
35
  end