aozora2html 0.7.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/rubocop.yml +19 -0
- data/.github/workflows/ruby.yml +37 -0
- data/.gitignore +8 -3
- data/.rubocop.yml +111 -0
- data/.rubocop_todo.yml +7 -0
- data/CHANGELOG.md +59 -0
- data/Gemfile +2 -0
- data/Guardfile +3 -1
- data/HACKING.md +45 -0
- data/LICENSE +116 -0
- data/README.md +29 -16
- data/Rakefile +12 -5
- data/aozora2html.gemspec +24 -24
- data/bin/aozora2html +25 -71
- data/lib/aozora2html/accent_parser.rb +99 -0
- data/lib/aozora2html/error.rb +17 -0
- data/lib/aozora2html/header.rb +141 -0
- data/lib/aozora2html/i18n.rb +48 -0
- data/lib/aozora2html/ruby_buffer.rb +116 -0
- data/lib/aozora2html/string_refinements.rb +36 -0
- data/lib/aozora2html/style_stack.rb +33 -0
- data/lib/aozora2html/tag/accent.rb +37 -0
- data/lib/aozora2html/tag/block.rb +21 -0
- data/lib/aozora2html/tag/chitsuki.rb +19 -0
- data/lib/aozora2html/tag/dakuten_katakana.rb +25 -0
- data/lib/aozora2html/tag/decorate.rb +19 -0
- data/lib/aozora2html/tag/dir.rb +17 -0
- data/lib/aozora2html/tag/editor_note.rb +19 -0
- data/lib/aozora2html/tag/embed_gaiji.rb +52 -0
- data/lib/aozora2html/tag/font_size.rb +20 -0
- data/lib/aozora2html/tag/gaiji.rb +12 -0
- data/lib/aozora2html/tag/img.rb +21 -0
- data/lib/aozora2html/tag/indent.rb +8 -0
- data/lib/aozora2html/tag/inline.rb +16 -0
- data/lib/aozora2html/tag/inline_caption.rb +17 -0
- data/lib/aozora2html/tag/inline_font_size.rb +19 -0
- data/lib/aozora2html/tag/inline_keigakomi.rb +17 -0
- data/lib/aozora2html/tag/inline_yokogumi.rb +17 -0
- data/lib/aozora2html/tag/jisage.rb +17 -0
- data/lib/aozora2html/tag/jizume.rb +19 -0
- data/lib/aozora2html/tag/kaeriten.rb +17 -0
- data/lib/aozora2html/tag/keigakomi.rb +19 -0
- data/lib/aozora2html/tag/kunten.rb +12 -0
- data/lib/aozora2html/tag/midashi.rb +20 -0
- data/lib/aozora2html/tag/multiline.rb +9 -0
- data/lib/aozora2html/tag/multiline_caption.rb +13 -0
- data/lib/aozora2html/tag/multiline_chitsuki.rb +10 -0
- data/lib/aozora2html/tag/multiline_jisage.rb +10 -0
- data/lib/aozora2html/tag/multiline_midashi.rb +25 -0
- data/lib/aozora2html/tag/multiline_style.rb +19 -0
- data/lib/aozora2html/tag/multiline_yokogumi.rb +14 -0
- data/lib/aozora2html/tag/okurigana.rb +17 -0
- data/lib/aozora2html/tag/oneline_chitsuki.rb +10 -0
- data/lib/aozora2html/tag/oneline_indent.rb +9 -0
- data/lib/aozora2html/tag/oneline_jisage.rb +10 -0
- data/lib/aozora2html/tag/reference_mentioned.rb +47 -0
- data/lib/aozora2html/tag/ruby.rb +202 -0
- data/lib/aozora2html/tag/un_embed_gaiji.rb +30 -0
- data/lib/aozora2html/tag.rb +57 -0
- data/lib/aozora2html/tag_parser.rb +60 -0
- data/lib/aozora2html/text_buffer.rb +50 -0
- data/lib/aozora2html/utils.rb +156 -0
- data/lib/aozora2html/version.rb +3 -1
- data/lib/aozora2html/yaml_loader.rb +37 -0
- data/lib/aozora2html/zip.rb +4 -0
- data/lib/aozora2html.rb +1359 -8
- data/lib/extensions.rb +12 -0
- data/lib/jstream.rb +139 -0
- data/sample/chukiichiran_kinyurei.html +15 -2
- data/sample/chukiichiran_kinyurei.txt +15 -2
- data/test/test_aozora2html.rb +323 -73
- data/test/test_aozora_accent_parser.rb +34 -6
- data/test/test_command_parse.rb +216 -0
- data/test/test_compat.rb +3 -4
- data/test/test_dakuten_katakana_tag.rb +12 -13
- data/test/test_decorate_tag.rb +11 -7
- data/test/test_dir_tag.rb +11 -7
- data/test/test_editor_note_tag.rb +9 -6
- data/test/test_exception.rb +11 -9
- data/test/test_font_size_tag.rb +22 -11
- data/test/test_gaiji_tag.rb +22 -14
- data/test/test_header.rb +45 -0
- data/test/test_helper.rb +3 -1
- data/test/test_i18n.rb +39 -0
- data/test/test_img_tag.rb +11 -6
- data/test/test_inline_caption_tag.rb +11 -7
- data/test/test_inline_font_size_tag.rb +15 -11
- data/test/test_inline_keigakomi_tag.rb +11 -7
- data/test/test_inline_yokogumi_tag.rb +11 -7
- data/test/test_jizume_tag.rb +11 -8
- data/test/test_jstream.rb +33 -30
- data/test/test_kaeriten_tag.rb +11 -7
- data/test/test_keigakomi_tag.rb +14 -11
- data/test/test_midashi_tag.rb +39 -0
- data/test/test_multiline_caption_tag.rb +11 -8
- data/test/test_multiline_midashi_tag.rb +26 -26
- data/test/test_multiline_style_tag.rb +11 -8
- data/test/test_multiline_yokogumi_tag.rb +11 -8
- data/test/test_okurigana_tag.rb +11 -7
- data/test/test_ruby_parse.rb +130 -0
- data/test/test_ruby_tag.rb +11 -7
- data/test/test_tag_parser.rb +31 -29
- data/vendor/jis2ucs/README.md +3 -6
- data/yml/accent_table.yml +240 -0
- data/yml/command_table.yml +61 -0
- data/yml/jis2ucs.yml +11234 -0
- metadata +99 -21
- data/.travis.yml +0 -12
- data/appveyor.yml +0 -23
- data/lib/accent_tag.rb +0 -23
- data/lib/aozora2html/jis2ucs.rb +0 -11237
- data/lib/embed_gaiji_tag.rb +0 -34
- data/lib/t2hs.rb +0 -2535
@@ -1,21 +1,25 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'test_helper'
|
3
4
|
require 'aozora2html'
|
4
5
|
|
5
6
|
class InlineCaptionTagTest < Test::Unit::TestCase
|
6
7
|
def setup
|
7
|
-
|
8
|
+
@parser = Object.new
|
9
|
+
stub(@parser).block_allowed_context? { true }
|
8
10
|
end
|
9
11
|
|
10
12
|
def test_caption_new
|
11
|
-
tag =
|
12
|
-
assert_equal
|
13
|
-
assert_equal true, tag.
|
13
|
+
tag = Aozora2Html::Tag::InlineCaption.new(@parser, 'aaa')
|
14
|
+
assert_equal Aozora2Html::Tag::InlineCaption, tag.class
|
15
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Inline)
|
14
16
|
end
|
15
17
|
|
18
|
+
using Aozora2Html::StringRefinements
|
19
|
+
|
16
20
|
def test_to_s
|
17
|
-
tag =
|
18
|
-
assert_equal
|
21
|
+
tag = Aozora2Html::Tag::InlineCaption.new(@parser, 'テスト'.to_sjis)
|
22
|
+
assert_equal '<span class="caption">テスト</span>', tag.to_s.to_utf8
|
19
23
|
end
|
20
24
|
|
21
25
|
def teardown
|
@@ -1,31 +1,35 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'test_helper'
|
3
4
|
require 'aozora2html'
|
4
5
|
|
5
6
|
class InlineFontSizeTagTest < Test::Unit::TestCase
|
6
7
|
def setup
|
7
|
-
|
8
|
+
@parser = Object.new
|
9
|
+
stub(@parser).block_allowed_context? { true }
|
8
10
|
end
|
9
11
|
|
10
12
|
def test_font_size_new
|
11
|
-
tag =
|
12
|
-
assert_equal
|
13
|
-
assert_equal true, tag.
|
13
|
+
tag = Aozora2Html::Tag::InlineFontSize.new(@parser, 'aa', 1, :dai)
|
14
|
+
assert_equal Aozora2Html::Tag::InlineFontSize, tag.class
|
15
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Inline)
|
14
16
|
end
|
15
17
|
|
18
|
+
using Aozora2Html::StringRefinements
|
19
|
+
|
16
20
|
def test_to_s
|
17
|
-
tag =
|
18
|
-
assert_equal
|
21
|
+
tag = Aozora2Html::Tag::InlineFontSize.new(@parser, 'テスト'.to_sjis, 1, :dai)
|
22
|
+
assert_equal '<span class="dai1" style="font-size: large;">テスト</span>', tag.to_s.to_utf8
|
19
23
|
end
|
20
24
|
|
21
25
|
def test_to_s2
|
22
|
-
tag =
|
23
|
-
assert_equal
|
26
|
+
tag = Aozora2Html::Tag::InlineFontSize.new(@parser, 'テスト'.to_sjis, 2, :sho)
|
27
|
+
assert_equal '<span class="sho2" style="font-size: x-small;">テスト</span>', tag.to_s.to_utf8
|
24
28
|
end
|
25
29
|
|
26
30
|
def test_to_s3
|
27
|
-
tag =
|
28
|
-
assert_equal
|
31
|
+
tag = Aozora2Html::Tag::InlineFontSize.new(@parser, 'テスト'.to_sjis, 3, :sho)
|
32
|
+
assert_equal '<span class="sho3" style="font-size: xx-small;">テスト</span>', tag.to_s.to_utf8
|
29
33
|
end
|
30
34
|
|
31
35
|
def teardown
|
@@ -1,21 +1,25 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'test_helper'
|
3
4
|
require 'aozora2html'
|
4
5
|
|
5
6
|
class InlineKeigakomiTagTest < Test::Unit::TestCase
|
6
7
|
def setup
|
7
|
-
|
8
|
+
@parser = Object.new
|
9
|
+
stub(@parser).block_allowed_context? { true }
|
8
10
|
end
|
9
11
|
|
10
12
|
def test_keigakomi_new
|
11
|
-
tag =
|
12
|
-
assert_equal
|
13
|
-
assert_equal true, tag.
|
13
|
+
tag = Aozora2Html::Tag::InlineKeigakomi.new(@parser, 'aaa')
|
14
|
+
assert_equal Aozora2Html::Tag::InlineKeigakomi, tag.class
|
15
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Inline)
|
14
16
|
end
|
15
17
|
|
18
|
+
using Aozora2Html::StringRefinements
|
19
|
+
|
16
20
|
def test_to_s
|
17
|
-
tag =
|
18
|
-
assert_equal
|
21
|
+
tag = Aozora2Html::Tag::InlineKeigakomi.new(@parser, 'テスト'.to_sjis)
|
22
|
+
assert_equal '<span class="keigakomi">テスト</span>', tag.to_s.to_utf8
|
19
23
|
end
|
20
24
|
|
21
25
|
def teardown
|
@@ -1,21 +1,25 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'test_helper'
|
3
4
|
require 'aozora2html'
|
4
5
|
|
5
6
|
class InlineYokogumiTagTest < Test::Unit::TestCase
|
6
7
|
def setup
|
7
|
-
|
8
|
+
@parser = Object.new
|
9
|
+
stub(@parser).block_allowed_context? { true }
|
8
10
|
end
|
9
11
|
|
10
12
|
def test_yokogumi_new
|
11
|
-
tag =
|
12
|
-
assert_equal
|
13
|
-
assert_equal true, tag.
|
13
|
+
tag = Aozora2Html::Tag::InlineYokogumi.new(@parser, 'aaa')
|
14
|
+
assert_equal Aozora2Html::Tag::InlineYokogumi, tag.class
|
15
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Inline)
|
14
16
|
end
|
15
17
|
|
18
|
+
using Aozora2Html::StringRefinements
|
19
|
+
|
16
20
|
def test_to_s
|
17
|
-
tag =
|
18
|
-
assert_equal
|
21
|
+
tag = Aozora2Html::Tag::InlineYokogumi.new(@parser, 'テスト'.to_sjis)
|
22
|
+
assert_equal '<span class="yokogumi">テスト</span>', tag.to_s.to_utf8
|
19
23
|
end
|
20
24
|
|
21
25
|
def teardown
|
data/test/test_jizume_tag.rb
CHANGED
@@ -1,22 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'test_helper'
|
2
4
|
require 'aozora2html'
|
3
5
|
|
4
6
|
class JizumeTagTest < Test::Unit::TestCase
|
5
7
|
def setup
|
6
|
-
|
8
|
+
@parser = Object.new
|
9
|
+
stub(@parser).block_allowed_context? { true }
|
7
10
|
end
|
8
11
|
|
9
12
|
def test_jizume_new
|
10
|
-
tag =
|
11
|
-
assert_equal
|
12
|
-
assert_equal true, tag.
|
13
|
-
assert_equal true, tag.
|
13
|
+
tag = Aozora2Html::Tag::Jizume.new(@parser, 50)
|
14
|
+
assert_equal Aozora2Html::Tag::Jizume, tag.class
|
15
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Block)
|
16
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Multiline)
|
14
17
|
end
|
15
18
|
|
16
19
|
def test_to_s
|
17
|
-
tag =
|
18
|
-
assert_equal
|
19
|
-
assert_equal
|
20
|
+
tag = Aozora2Html::Tag::Jizume.new(@parser, 50)
|
21
|
+
assert_equal '<div class="jizume_50" style="width: 50em">', tag.to_s
|
22
|
+
assert_equal '</div>', tag.close_tag
|
20
23
|
end
|
21
24
|
|
22
25
|
def teardown
|
data/test/test_jstream.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'test_helper'
|
3
4
|
require 'aozora2html'
|
4
5
|
require 'stringio'
|
5
6
|
|
6
7
|
class JstreamTest < Test::Unit::TestCase
|
8
|
+
using Aozora2Html::StringRefinements
|
9
|
+
|
7
10
|
def test_new_error
|
8
11
|
strio = StringIO.new("aaa\nbbb\n")
|
9
12
|
orig_stdout = $stdout
|
@@ -13,45 +16,45 @@ class JstreamTest < Test::Unit::TestCase
|
|
13
16
|
Jstream.new(strio)
|
14
17
|
end
|
15
18
|
$stdout = orig_stdout
|
16
|
-
assert_equal "エラー(1行目):改行コードを、「CR+LF」にあらためてください. \r\n処理を停止します\n", out.string.
|
19
|
+
assert_equal "エラー(1行目):改行コードを、「CR+LF」にあらためてください. \r\n処理を停止します\n", out.string.to_utf8
|
17
20
|
end
|
18
21
|
|
19
22
|
def test_read_char
|
20
|
-
strio = StringIO.new("aあ5\r\n%\\b\r\n".
|
23
|
+
strio = StringIO.new("aあ5\r\n%\\b\r\n".to_sjis)
|
21
24
|
stm = Jstream.new(strio)
|
22
|
-
assert_equal
|
23
|
-
assert_equal
|
24
|
-
assert_equal
|
25
|
-
assert_equal "\r\n", stm.read_char.
|
26
|
-
assert_equal
|
27
|
-
assert_equal
|
28
|
-
assert_equal
|
29
|
-
assert_equal "\r\n", stm.read_char.
|
25
|
+
assert_equal 'a', stm.read_char.to_utf8
|
26
|
+
assert_equal 'あ', stm.read_char.to_utf8
|
27
|
+
assert_equal '5', stm.read_char.to_utf8
|
28
|
+
assert_equal "\r\n", stm.read_char.to_utf8
|
29
|
+
assert_equal '%', stm.read_char.to_utf8
|
30
|
+
assert_equal '\\', stm.read_char.to_utf8
|
31
|
+
assert_equal 'b', stm.read_char.to_utf8
|
32
|
+
assert_equal "\r\n", stm.read_char.to_utf8
|
30
33
|
assert_equal :eof, stm.read_char
|
31
|
-
assert_equal "\r\n", stm.read_char #
|
32
|
-
assert_equal :eof, stm.read_char
|
34
|
+
# assert_equal "\r\n", stm.read_char # :eof以降は正しい値を保証しない
|
35
|
+
assert_equal :eof, stm.read_char # 何度もread_charすると:eofが複数回出る
|
33
36
|
end
|
34
37
|
|
35
38
|
def test_peek_char
|
36
|
-
strio = StringIO.new("aあ5\r\n%\\b\r\n".
|
39
|
+
strio = StringIO.new("aあ5\r\n%\\b\r\n".to_sjis)
|
37
40
|
stm = Jstream.new(strio)
|
38
|
-
assert_equal
|
39
|
-
assert_equal
|
40
|
-
assert_equal
|
41
|
-
assert_equal "\r\n", stm.peek_char(3).
|
42
|
-
assert_equal "\r\n", stm.peek_char(4).
|
43
|
-
assert_equal "\r\n", stm.peek_char(5).
|
44
|
-
assert_equal "\r\n", stm.peek_char(100).
|
45
|
-
assert_equal
|
41
|
+
assert_equal 'a', stm.peek_char(0).to_utf8
|
42
|
+
assert_equal 'あ', stm.peek_char(1).to_utf8
|
43
|
+
assert_equal '5', stm.peek_char(2).to_utf8
|
44
|
+
assert_equal "\r\n", stm.peek_char(3).to_utf8
|
45
|
+
# assert_equal "\r\n", stm.peek_char(4).to_utf8 # 改行文字以降は正しい値を保証しない
|
46
|
+
# assert_equal "\r\n", stm.peek_char(5).to_utf8 # 同上
|
47
|
+
# assert_equal "\r\n", stm.peek_char(100).to_utf8 # 同上
|
48
|
+
assert_equal 'a', stm.read_char.to_utf8
|
46
49
|
|
47
|
-
assert_equal
|
48
|
-
assert_equal
|
49
|
-
assert_equal
|
50
|
-
assert_equal "\r\n", stm.read_char.
|
50
|
+
assert_equal 'あ', stm.peek_char(0).to_utf8
|
51
|
+
assert_equal 'あ', stm.read_char.to_utf8
|
52
|
+
assert_equal '5', stm.read_char.to_utf8
|
53
|
+
assert_equal "\r\n", stm.read_char.to_utf8
|
51
54
|
|
52
|
-
assert_equal
|
53
|
-
assert_equal
|
54
|
-
assert_equal
|
55
|
-
assert_equal "\r\n", stm.peek_char(3).
|
55
|
+
assert_equal '%', stm.peek_char(0).to_utf8
|
56
|
+
assert_equal '\\', stm.peek_char(1).to_utf8
|
57
|
+
assert_equal 'b', stm.peek_char(2).to_utf8
|
58
|
+
assert_equal "\r\n", stm.peek_char(3).to_utf8
|
56
59
|
end
|
57
60
|
end
|
data/test/test_kaeriten_tag.rb
CHANGED
@@ -1,21 +1,25 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'test_helper'
|
3
4
|
require 'aozora2html'
|
4
5
|
|
5
6
|
class KaeritenTagTest < Test::Unit::TestCase
|
6
7
|
def setup
|
7
|
-
|
8
|
+
@parser = Object.new
|
9
|
+
stub(@parser).block_allowed_context? { true }
|
8
10
|
end
|
9
11
|
|
10
12
|
def test_kaeriten_new
|
11
|
-
tag =
|
12
|
-
assert_equal
|
13
|
-
assert_equal true, tag.
|
13
|
+
tag = Aozora2Html::Tag::Kaeriten.new(@parser, 'aaa')
|
14
|
+
assert_equal Aozora2Html::Tag::Kaeriten, tag.class
|
15
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Inline)
|
14
16
|
end
|
15
17
|
|
18
|
+
using Aozora2Html::StringRefinements
|
19
|
+
|
16
20
|
def test_to_s
|
17
|
-
tag =
|
18
|
-
assert_equal
|
21
|
+
tag = Aozora2Html::Tag::Kaeriten.new(@parser, 'テスト'.to_sjis)
|
22
|
+
assert_equal '<sub class="kaeriten">テスト</sub>', tag.to_s.to_utf8
|
19
23
|
end
|
20
24
|
|
21
25
|
def teardown
|
data/test/test_keigakomi_tag.rb
CHANGED
@@ -1,28 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'test_helper'
|
2
4
|
require 'aozora2html'
|
3
5
|
|
4
6
|
class KeigakomiTagTest < Test::Unit::TestCase
|
5
7
|
def setup
|
6
|
-
|
8
|
+
@parser = Object.new
|
9
|
+
stub(@parser).block_allowed_context? { true }
|
7
10
|
end
|
8
11
|
|
9
12
|
def test_keigakomi_new
|
10
|
-
tag =
|
11
|
-
assert_equal
|
12
|
-
assert_equal true, tag.
|
13
|
-
assert_equal true, tag.
|
13
|
+
tag = Aozora2Html::Tag::Keigakomi.new(@parser, 2)
|
14
|
+
assert_equal Aozora2Html::Tag::Keigakomi, tag.class
|
15
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Block)
|
16
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Multiline)
|
14
17
|
end
|
15
18
|
|
16
19
|
def test_to_s
|
17
|
-
tag =
|
18
|
-
assert_equal
|
19
|
-
assert_equal
|
20
|
+
tag = Aozora2Html::Tag::Keigakomi.new(@parser)
|
21
|
+
assert_equal '<div class="keigakomi" style="border: solid 1px">', tag.to_s
|
22
|
+
assert_equal '</div>', tag.close_tag
|
20
23
|
end
|
21
24
|
|
22
25
|
def test_to_s2
|
23
|
-
tag =
|
24
|
-
assert_equal
|
25
|
-
assert_equal
|
26
|
+
tag = Aozora2Html::Tag::Keigakomi.new(@parser, 2)
|
27
|
+
assert_equal '<div class="keigakomi" style="border: solid 2px">', tag.to_s
|
28
|
+
assert_equal '</div>', tag.close_tag
|
26
29
|
end
|
27
30
|
|
28
31
|
def teardown
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
require 'aozora2html'
|
5
|
+
|
6
|
+
class MidashiTagTest < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
@parser = Object.new
|
9
|
+
stub(@parser).block_allowed_context? { true }
|
10
|
+
stub(@parser).new_midashi_id { 2 }
|
11
|
+
end
|
12
|
+
|
13
|
+
using Aozora2Html::StringRefinements
|
14
|
+
|
15
|
+
def test_midashi_new
|
16
|
+
tag = Aozora2Html::Tag::Midashi.new(@parser, 'テスト見出し'.to_sjis, '小'.to_sjis, :normal)
|
17
|
+
assert_equal Aozora2Html::Tag::Midashi, tag.class
|
18
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Inline)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_to_s
|
22
|
+
tag = Aozora2Html::Tag::Midashi.new(@parser, 'テスト見出し'.to_sjis, '小'.to_sjis, :normal)
|
23
|
+
assert_equal "<h5 class=\"ko-midashi\"><a class=\"midashi_anchor\" id=\"midashi2\">#{'テスト見出し'.to_sjis}</a></h5>", tag.to_s
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_to_s_mado
|
27
|
+
tag = Aozora2Html::Tag::Midashi.new(@parser, 'テスト見出し'.to_sjis, '小'.to_sjis, :mado)
|
28
|
+
assert_equal "<h5 class=\"mado-ko-midashi\"><a class=\"midashi_anchor\" id=\"midashi2\">#{'テスト見出し'.to_sjis}</a></h5>", tag.to_s
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_undeined_midashi
|
32
|
+
Aozora2Html::Tag::Midashi.new(@parser, 'テスト見出し'.to_sjis, 'あ'.to_sjis, :normal)
|
33
|
+
rescue Aozora2Html::Error => e
|
34
|
+
assert_equal e.message(123).to_utf8, "エラー(123行目):未定義な見出しです. \r\n処理を停止します"
|
35
|
+
end
|
36
|
+
|
37
|
+
def teardown
|
38
|
+
end
|
39
|
+
end
|
@@ -1,22 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'test_helper'
|
2
4
|
require 'aozora2html'
|
3
5
|
|
4
6
|
class MultilineCaptionTagTest < Test::Unit::TestCase
|
5
7
|
def setup
|
6
|
-
|
8
|
+
@parser = Object.new
|
9
|
+
stub(@parser).block_allowed_context? { true }
|
7
10
|
end
|
8
11
|
|
9
12
|
def test_multiline_caption_new
|
10
|
-
tag =
|
11
|
-
assert_equal
|
12
|
-
assert_equal true, tag.
|
13
|
-
assert_equal true, tag.
|
13
|
+
tag = Aozora2Html::Tag::MultilineCaption.new(@parser)
|
14
|
+
assert_equal Aozora2Html::Tag::MultilineCaption, tag.class
|
15
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Block)
|
16
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Multiline)
|
14
17
|
end
|
15
18
|
|
16
19
|
def test_to_s
|
17
|
-
tag =
|
18
|
-
assert_equal
|
19
|
-
assert_equal
|
20
|
+
tag = Aozora2Html::Tag::MultilineCaption.new(@parser)
|
21
|
+
assert_equal '<div class="caption">', tag.to_s
|
22
|
+
assert_equal '</div>', tag.close_tag
|
20
23
|
end
|
21
24
|
|
22
25
|
def teardown
|
@@ -1,52 +1,52 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'test_helper'
|
3
4
|
require 'aozora2html'
|
4
5
|
|
5
6
|
class MultilineMidashiTagTest < Test::Unit::TestCase
|
6
7
|
def setup
|
7
|
-
|
8
|
-
stub(@parser).
|
8
|
+
@parser = Object.new
|
9
|
+
stub(@parser).block_allowed_context? { true }
|
10
|
+
stub(@parser).new_midashi_id { 2 }
|
9
11
|
end
|
10
12
|
|
13
|
+
using Aozora2Html::StringRefinements
|
14
|
+
|
11
15
|
def test_multiline_midashi_new
|
12
|
-
tag =
|
13
|
-
assert_equal
|
14
|
-
assert_equal true, tag.
|
15
|
-
assert_equal true, tag.
|
16
|
+
tag = Aozora2Html::Tag::MultilineMidashi.new(@parser, '小'.to_sjis, :normal)
|
17
|
+
assert_equal Aozora2Html::Tag::MultilineMidashi, tag.class
|
18
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Block)
|
19
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Multiline)
|
16
20
|
end
|
17
21
|
|
18
22
|
def test_to_s
|
19
|
-
tag =
|
20
|
-
assert_equal
|
21
|
-
assert_equal
|
23
|
+
tag = Aozora2Html::Tag::MultilineMidashi.new(@parser, '小'.to_sjis, :normal)
|
24
|
+
assert_equal '<h5 class="ko-midashi"><a class="midashi_anchor" id="midashi2">', tag.to_s
|
25
|
+
assert_equal '</a></h5>', tag.close_tag
|
22
26
|
end
|
23
27
|
|
24
28
|
def test_to_s_chu
|
25
|
-
tag =
|
26
|
-
assert_equal
|
27
|
-
assert_equal
|
29
|
+
tag = Aozora2Html::Tag::MultilineMidashi.new(@parser, '中'.to_sjis, :dogyo)
|
30
|
+
assert_equal '<h4 class="dogyo-naka-midashi"><a class="midashi_anchor" id="midashi2">', tag.to_s
|
31
|
+
assert_equal '</a></h4>', tag.close_tag
|
28
32
|
end
|
29
33
|
|
30
34
|
def test_to_s_dai
|
31
|
-
tag =
|
32
|
-
assert_equal
|
33
|
-
assert_equal
|
35
|
+
tag = Aozora2Html::Tag::MultilineMidashi.new(@parser, '大'.to_sjis, :mado)
|
36
|
+
assert_equal '<h3 class="mado-o-midashi"><a class="midashi_anchor" id="midashi2">', tag.to_s
|
37
|
+
assert_equal '</a></h3>', tag.close_tag
|
34
38
|
end
|
35
39
|
|
36
40
|
def test_undeined_midashi
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
assert_equal e.message(123).encode("utf-8"), "エラー(123行目):未定義な見出しです. \r\n処理を停止します"
|
41
|
-
end
|
41
|
+
Aozora2Html::Tag::MultilineMidashi.new(@parser, 'あ'.to_sjis, :mado)
|
42
|
+
rescue Aozora2Html::Error => e
|
43
|
+
assert_equal e.message(123).to_utf8, "エラー(123行目):未定義な見出しです. \r\n処理を停止します"
|
42
44
|
end
|
43
45
|
|
44
46
|
def test_undeined_midashi2
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
assert_equal e.message(123).encode("utf-8"), "エラー(123行目):未定義な見出しです. \r\n処理を停止します"
|
49
|
-
end
|
47
|
+
Aozora2Html::Tag::MultilineMidashi.new(@parser, '大'.to_sjis, :madoo)
|
48
|
+
rescue Aozora2Html::Error => e
|
49
|
+
assert_equal e.message(123).to_utf8, "エラー(123行目):未定義な見出しです. \r\n処理を停止します"
|
50
50
|
end
|
51
51
|
|
52
52
|
def teardown
|
@@ -1,22 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'test_helper'
|
2
4
|
require 'aozora2html'
|
3
5
|
|
4
6
|
class MultilineStyleTagTest < Test::Unit::TestCase
|
5
7
|
def setup
|
6
|
-
|
8
|
+
@parser = Object.new
|
9
|
+
stub(@parser).block_allowed_context? { true }
|
7
10
|
end
|
8
11
|
|
9
12
|
def test_multiline_style_new
|
10
|
-
tag =
|
11
|
-
assert_equal
|
12
|
-
assert_equal true, tag.
|
13
|
-
assert_equal true, tag.
|
13
|
+
tag = Aozora2Html::Tag::MultilineStyle.new(@parser, 'style1')
|
14
|
+
assert_equal Aozora2Html::Tag::MultilineStyle, tag.class
|
15
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Block)
|
16
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Multiline)
|
14
17
|
end
|
15
18
|
|
16
19
|
def test_to_s
|
17
|
-
tag =
|
18
|
-
assert_equal
|
19
|
-
assert_equal
|
20
|
+
tag = Aozora2Html::Tag::MultilineStyle.new(@parser, 's1')
|
21
|
+
assert_equal '<div class="s1">', tag.to_s
|
22
|
+
assert_equal '</div>', tag.close_tag
|
20
23
|
end
|
21
24
|
|
22
25
|
def teardown
|
@@ -1,22 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'test_helper'
|
2
4
|
require 'aozora2html'
|
3
5
|
|
4
6
|
class MultilineYokogumiTagTest < Test::Unit::TestCase
|
5
7
|
def setup
|
6
|
-
|
8
|
+
@parser = Object.new
|
9
|
+
stub(@parser).block_allowed_context? { true }
|
7
10
|
end
|
8
11
|
|
9
12
|
def test_multiline_yokogumi_new
|
10
|
-
tag =
|
11
|
-
assert_equal
|
12
|
-
assert_equal true, tag.
|
13
|
-
assert_equal true, tag.
|
13
|
+
tag = Aozora2Html::Tag::MultilineYokogumi.new(@parser)
|
14
|
+
assert_equal Aozora2Html::Tag::MultilineYokogumi, tag.class
|
15
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Block)
|
16
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Multiline)
|
14
17
|
end
|
15
18
|
|
16
19
|
def test_to_s
|
17
|
-
tag =
|
18
|
-
assert_equal
|
19
|
-
assert_equal
|
20
|
+
tag = Aozora2Html::Tag::MultilineYokogumi.new(@parser)
|
21
|
+
assert_equal '<div class="yokogumi">', tag.to_s
|
22
|
+
assert_equal '</div>', tag.close_tag
|
20
23
|
end
|
21
24
|
|
22
25
|
def teardown
|
data/test/test_okurigana_tag.rb
CHANGED
@@ -1,21 +1,25 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'test_helper'
|
3
4
|
require 'aozora2html'
|
4
5
|
|
5
6
|
class OkuriganaTagTest < Test::Unit::TestCase
|
6
7
|
def setup
|
7
|
-
|
8
|
+
@parser = Object.new
|
9
|
+
stub(@parser).block_allowed_context? { true }
|
8
10
|
end
|
9
11
|
|
10
12
|
def test_okurigana_new
|
11
|
-
tag =
|
12
|
-
assert_equal
|
13
|
-
assert_equal true, tag.
|
13
|
+
tag = Aozora2Html::Tag::Okurigana.new(@parser, 'aaa')
|
14
|
+
assert_equal Aozora2Html::Tag::Okurigana, tag.class
|
15
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Inline)
|
14
16
|
end
|
15
17
|
|
18
|
+
using Aozora2Html::StringRefinements
|
19
|
+
|
16
20
|
def test_to_s
|
17
|
-
tag =
|
18
|
-
assert_equal
|
21
|
+
tag = Aozora2Html::Tag::Okurigana.new(@parser, 'テスト'.to_sjis)
|
22
|
+
assert_equal '<sup class="okurigana">テスト</sup>', tag.to_s.to_utf8
|
19
23
|
end
|
20
24
|
|
21
25
|
def teardown
|