aozora2html 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2d5866db44c93055109ebd1523d14adbc54430b4
4
- data.tar.gz: 024cf855007a18c9b4592fa1576cc50394b52f3b
3
+ metadata.gz: f5986973cf323ca85a48b74c8537a0c43ff4c9b5
4
+ data.tar.gz: ed11bf0bffd8773090e0c336e9d25818156e42ff
5
5
  SHA512:
6
- metadata.gz: d022e52edd4ad4d8d329e6b9aa3421505e60942bdc80b558bf2691a1e871b7053b10fae60b1b6493d5d6670ff4554822f2996056e86de695e4cb0430a01b4d60
7
- data.tar.gz: 67f47a64d1df309ffcef401e9faef8b466a56fbb00a26d8b17afcac0bdc78d95264167af01b6d249f58f3661279262fe3ab849bc4b8e47c88277d29762c8204e
6
+ metadata.gz: 303a38cddb21e188905acc4e2e537582d9f621415ffa460964dfd775484113b435a1cba103d7c9612c5a5773e3cdd48bd8162c1ca3d7a25b7e9436a09d4e6dc3
7
+ data.tar.gz: 0b5ce96681fb726ad975d7926e78c203b5dc9001f652b3f43fa09ea9b9b590143f55438fd038ce3bdc96800501a7c02de83a01f603aee86fc9b3a15005608abd
data/CHANGELOG.md CHANGED
@@ -1,10 +1,22 @@
1
+ <a name="0.5.0"></a>
2
+ ## 0.5.0
3
+
4
+ ### Bug Fixes
5
+
6
+ * Windowsで動かなかったのを修正した (#10)
7
+ * Aozora2HtmlTestでAozora2Htmlインスタンスを必ずcloseするように修正した
8
+
9
+ ### Features
10
+
11
+ * `--use-jisx0213`オプションでアクセント文字も数値実体参照として表示できるようにした
12
+
1
13
  <a name="0.4.0"></a>
2
14
  ## 0.4.0
3
15
 
4
16
  ### Features
5
17
 
6
18
  * 第1引数にファイル名ではなく`http://...`といったURLを与えた場合、そのURLのファイルをダウンロードしHTMLに変換するようにした
7
- * 第1引数が省略された場合、結果をファイルではなく標準出力に出力するようにした
19
+ * 第2引数が省略された場合、結果をファイルではなく標準出力に出力するようにした
8
20
 
9
21
  <a name="0.3.0"></a>
10
22
  ## 0.3.0
data/bin/aozora2html CHANGED
@@ -40,6 +40,7 @@ end
40
40
 
41
41
  if options["use-jisx0213"]
42
42
  Embed_Gaiji_tag.use_jisx0213 = true
43
+ Accent_tag.use_jisx0213 = true
43
44
  end
44
45
 
45
46
  if ARGV.size < 1 || ARGV.size > 2
data/lib/accent_tag.rb ADDED
@@ -0,0 +1,23 @@
1
+ class Accent_tag
2
+ alias_method :to_s_orig, :to_s
3
+
4
+ def self.use_jisx0213=(val)
5
+ @use_jisx0213 = val
6
+ end
7
+
8
+ def self.use_jisx0213
9
+ @use_jisx0213
10
+ end
11
+
12
+ def jisx0213_to_unicode(code)
13
+ Aozora2Html::JIS2UCS[code]
14
+ end
15
+
16
+ def to_s
17
+ if Accent_tag.use_jisx0213
18
+ jisx0213_to_unicode(@code.sub(%r|.*/|,"").to_sym)
19
+ else
20
+ to_s_orig
21
+ end
22
+ end
23
+ end
data/lib/aozora2html.rb CHANGED
@@ -3,6 +3,7 @@ require "aozora2html/zip"
3
3
  require "aozora2html/jis2ucs"
4
4
  require 't2hs'
5
5
  require 'embed_gaiji_tag'
6
+ require 'accent_tag'
6
7
 
7
8
  ## already defined in t2hs.rb
8
9
  class Aozora2Html
@@ -1,3 +1,3 @@
1
1
  class Aozora2Html
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
data/lib/t2hs.rb CHANGED
@@ -810,7 +810,7 @@ class Aozora2Html
810
810
  "�s��������"=>["subscript","sub"]
811
811
  }
812
812
  def initialize (input, output)
813
- @stream = Jstream.new(File.open(input,"r:Shift_JIS"))
813
+ @stream = Jstream.new(File.open(input,"rb:Shift_JIS"))
814
814
  @buffer = []; @ruby_buf = [""]; @ruby_char_type = nil
815
815
  @out = File.open(output,"w"); @section = :head; @header = []; @style_stack = []
816
816
  @chuuki_table = {}; @images = []; @indent_stack = []; @tag_stack = []
@@ -12,10 +12,13 @@ class Aozora2HtmlTest < Test::Unit::TestCase
12
12
  Dir.mktmpdir do |dir|
13
13
  input = File.join(dir,'dummy.txt')
14
14
  output = File.join(dir,'dummy2.txt')
15
- File.write(input, "テスト\r\n")
15
+ File.binwrite(input, "テスト\r\n")
16
16
  parser = Aozora2Html.new(input, output)
17
-
18
- assert_equal Aozora2Html, parser.class
17
+ begin
18
+ assert_equal Aozora2Html, parser.class
19
+ ensure
20
+ parser.close
21
+ end
19
22
  end
20
23
  end
21
24
 
@@ -23,25 +26,29 @@ class Aozora2HtmlTest < Test::Unit::TestCase
23
26
  Dir.mktmpdir do |dir|
24
27
  input = File.join(dir,'dummy.txt')
25
28
  output = File.join(dir,'dummy2.txt')
26
- File.write(input, "a\r\nb\r\nc\r\n")
29
+ File.binwrite(input, "a\r\nb\r\nc\r\n")
27
30
  parser = Aozora2Html.new(input, output)
28
31
 
29
- assert_equal 0, parser.scount
30
- ch = parser.read_char
31
- assert_equal "a",ch
32
- assert_equal 1, parser.scount
33
- ch = parser.read_char
34
- assert_equal "\r\n",ch
35
- assert_equal 1, parser.scount
36
- ch = parser.read_char
37
- assert_equal "b",ch
38
- assert_equal 2, parser.scount
39
- ch = parser.read_char
40
- assert_equal "\r\n",ch
41
- assert_equal 2, parser.scount
42
- ch = parser.read_char
43
- assert_equal "c",ch
44
- assert_equal 3, parser.scount
32
+ begin
33
+ assert_equal 0, parser.scount
34
+ ch = parser.read_char
35
+ assert_equal "a",ch
36
+ assert_equal 1, parser.scount
37
+ ch = parser.read_char
38
+ assert_equal "\r\n",ch
39
+ assert_equal 1, parser.scount
40
+ ch = parser.read_char
41
+ assert_equal "b",ch
42
+ assert_equal 2, parser.scount
43
+ ch = parser.read_char
44
+ assert_equal "\r\n",ch
45
+ assert_equal 2, parser.scount
46
+ ch = parser.read_char
47
+ assert_equal "c",ch
48
+ assert_equal 3, parser.scount
49
+ ensure
50
+ parser.close
51
+ end
45
52
  end
46
53
  end
47
54
 
@@ -49,11 +56,14 @@ class Aozora2HtmlTest < Test::Unit::TestCase
49
56
  Dir.mktmpdir do |dir|
50
57
  input = File.join(dir,'dummy.txt')
51
58
  output = File.join(dir,'dummy2.txt')
52
- File.write(input, "ab\r\nc\r\n")
59
+ File.binwrite(input, "ab\r\nc\r\n")
53
60
  parser = Aozora2Html.new(input, output)
54
-
55
- parsed = parser.read_line
56
- assert_equal "ab", parsed
61
+ begin
62
+ parsed = parser.read_line
63
+ assert_equal "ab", parsed
64
+ ensure
65
+ parser.close
66
+ end
57
67
  end
58
68
  end
59
69
 
@@ -61,25 +71,29 @@ class Aozora2HtmlTest < Test::Unit::TestCase
61
71
  Dir.mktmpdir do |dir|
62
72
  input = File.join(dir,'dummy.txt')
63
73
  output = File.join(dir,'dummy2.txt')
64
- File.write(input, "ab\r\nc\r\n")
74
+ File.binwrite(input, "ab\r\nc\r\n")
65
75
  parser = Aozora2Html.new(input, output)
66
76
 
67
- assert_equal :kanji, parser.char_type(Embed_Gaiji_tag.new(nil,"foo","1-2-3","name"))
68
- assert_equal :kanji, parser.char_type(UnEmbed_Gaiji_tag.new(nil,"foo"))
69
- assert_equal :hankaku, parser.char_type(Accent_tag.new(nil,123,"abc"))
70
- assert_equal :else, parser.char_type(Okurigana_tag.new(nil,"abc"))
71
- assert_equal :else, parser.char_type(Inline_keigakomi_tag.new(nil,"abc"))
72
- assert_equal :katakana, parser.char_type(Dakuten_katakana_tag.new(nil,1,"abc"))
77
+ begin
78
+ assert_equal :kanji, parser.char_type(Embed_Gaiji_tag.new(nil,"foo","1-2-3","name"))
79
+ assert_equal :kanji, parser.char_type(UnEmbed_Gaiji_tag.new(nil,"foo"))
80
+ assert_equal :hankaku, parser.char_type(Accent_tag.new(nil,123,"abc"))
81
+ assert_equal :else, parser.char_type(Okurigana_tag.new(nil,"abc"))
82
+ assert_equal :else, parser.char_type(Inline_keigakomi_tag.new(nil,"abc"))
83
+ assert_equal :katakana, parser.char_type(Dakuten_katakana_tag.new(nil,1,"abc"))
73
84
 
74
- assert_equal :hiragana, parser.char_type("あ".encode("shift_jis"))
75
- assert_equal :hiragana, parser.char_type("っ".encode("shift_jis"))
76
- assert_equal :katakana, parser.char_type("ヴ".encode("shift_jis"))
77
- assert_equal :katakana, parser.char_type("ー".encode("shift_jis"))
78
- assert_equal :zenkaku, parser.char_type("w".encode("shift_jis"))
79
- assert_equal :hankaku, parser.char_type("z".encode("shift_jis"))
80
- assert_equal :kanji, parser.char_type("漢".encode("shift_jis"))
81
- assert_equal :hankaku_terminate, parser.char_type("!".encode("shift_jis"))
82
- assert_equal :else, parser.char_type("?".encode("shift_jis"))
85
+ assert_equal :hiragana, parser.char_type("あ".encode("shift_jis"))
86
+ assert_equal :hiragana, parser.char_type("っ".encode("shift_jis"))
87
+ assert_equal :katakana, parser.char_type("ヴ".encode("shift_jis"))
88
+ assert_equal :katakana, parser.char_type("ー".encode("shift_jis"))
89
+ assert_equal :zenkaku, parser.char_type("w".encode("shift_jis"))
90
+ assert_equal :hankaku, parser.char_type("z".encode("shift_jis"))
91
+ assert_equal :kanji, parser.char_type("漢".encode("shift_jis"))
92
+ assert_equal :hankaku_terminate, parser.char_type("!".encode("shift_jis"))
93
+ assert_equal :else, parser.char_type("?".encode("shift_jis"))
94
+ ensure
95
+ parser.close
96
+ end
83
97
  end
84
98
  end
85
99
 
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.4.0
4
+ version: 0.5.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: 2015-11-06 00:00:00.000000000 Z
11
+ date: 2015-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -126,6 +126,7 @@ files:
126
126
  - Rakefile
127
127
  - aozora2html.gemspec
128
128
  - bin/aozora2html
129
+ - lib/accent_tag.rb
129
130
  - lib/aozora2html.rb
130
131
  - lib/aozora2html/jis2ucs.rb
131
132
  - lib/aozora2html/version.rb