aozora2html 0.4.0 → 0.5.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 +4 -4
 - data/CHANGELOG.md +13 -1
 - data/bin/aozora2html +1 -0
 - data/lib/accent_tag.rb +23 -0
 - data/lib/aozora2html.rb +1 -0
 - data/lib/aozora2html/version.rb +1 -1
 - data/lib/t2hs.rb +1 -1
 - data/test/test_aozora2html.rb +54 -40
 - metadata +3 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: f5986973cf323ca85a48b74c8537a0c43ff4c9b5
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: ed11bf0bffd8773090e0c336e9d25818156e42ff
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 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 
     | 
    
         
            -
            * 第 
     | 
| 
      
 19 
     | 
    
         
            +
            * 第2引数が省略された場合、結果をファイルではなく標準出力に出力するようにした
         
     | 
| 
       8 
20 
     | 
    
         | 
| 
       9 
21 
     | 
    
         
             
            <a name="0.3.0"></a>
         
     | 
| 
       10 
22 
     | 
    
         
             
            ## 0.3.0
         
     | 
    
        data/bin/aozora2html
    CHANGED
    
    
    
        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
    
    
    
        data/lib/aozora2html/version.rb
    CHANGED
    
    
    
        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," 
     | 
| 
      
 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 = []
         
     | 
    
        data/test/test_aozora2html.rb
    CHANGED
    
    | 
         @@ -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. 
     | 
| 
      
 15 
     | 
    
         
            +
                  File.binwrite(input, "テスト\r\n")
         
     | 
| 
       16 
16 
     | 
    
         
             
                  parser = Aozora2Html.new(input, output)
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
      
 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. 
     | 
| 
      
 29 
     | 
    
         
            +
                  File.binwrite(input, "a\r\nb\r\nc\r\n")
         
     | 
| 
       27 
30 
     | 
    
         
             
                  parser = Aozora2Html.new(input, output)
         
     | 
| 
       28 
31 
     | 
    
         | 
| 
       29 
     | 
    
         
            -
                   
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
      
 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. 
     | 
| 
      
 59 
     | 
    
         
            +
                  File.binwrite(input, "ab\r\nc\r\n")
         
     | 
| 
       53 
60 
     | 
    
         
             
                  parser = Aozora2Html.new(input, output)
         
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
      
 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. 
     | 
| 
      
 74 
     | 
    
         
            +
                  File.binwrite(input, "ab\r\nc\r\n")
         
     | 
| 
       65 
75 
     | 
    
         
             
                  parser = Aozora2Html.new(input, output)
         
     | 
| 
       66 
76 
     | 
    
         | 
| 
       67 
     | 
    
         
            -
                   
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
      
 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 
     | 
    
         
            -
             
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
       77 
     | 
    
         
            -
             
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
     | 
    
         
            -
             
     | 
| 
       80 
     | 
    
         
            -
             
     | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
       82 
     | 
    
         
            -
             
     | 
| 
      
 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 
     | 
    
         
            +
              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- 
     | 
| 
      
 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
         
     |