aozora2html 2.0.0 → 3.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 +4 -4
- data/.github/workflows/rubocop.yml +19 -0
- data/.github/workflows/ruby.yml +4 -1
- data/.rubocop.yml +36 -152
- data/.rubocop_todo.yml +7 -0
- data/CHANGELOG.md +26 -0
- data/Gemfile +2 -0
- data/Guardfile +3 -1
- data/HACKING.md +45 -0
- data/README.md +14 -6
- data/Rakefile +12 -5
- data/aozora2html.gemspec +24 -22
- data/bin/aozora2html +21 -19
- data/lib/aozora2html/accent_parser.rb +62 -54
- data/lib/aozora2html/error.rb +5 -4
- data/lib/aozora2html/header.rb +20 -18
- data/lib/aozora2html/i18n.rb +40 -20
- data/lib/aozora2html/ruby_buffer.rb +63 -28
- data/lib/aozora2html/string_refinements.rb +36 -0
- data/lib/aozora2html/style_stack.rb +6 -0
- data/lib/aozora2html/tag/accent.rb +10 -12
- data/lib/aozora2html/tag/block.rb +11 -9
- data/lib/aozora2html/tag/chitsuki.rb +6 -2
- data/lib/aozora2html/tag/dakuten_katakana.rb +10 -8
- data/lib/aozora2html/tag/decorate.rb +4 -3
- data/lib/aozora2html/tag/dir.rb +4 -2
- data/lib/aozora2html/tag/editor_note.rb +7 -4
- data/lib/aozora2html/tag/embed_gaiji.rb +15 -11
- data/lib/aozora2html/tag/font_size.rb +5 -2
- data/lib/aozora2html/tag/gaiji.rb +4 -3
- data/lib/aozora2html/tag/img.rb +4 -4
- data/lib/aozora2html/tag/indent.rb +3 -3
- data/lib/aozora2html/tag/inline.rb +10 -7
- data/lib/aozora2html/tag/inline_caption.rb +4 -2
- data/lib/aozora2html/tag/inline_font_size.rb +4 -3
- data/lib/aozora2html/tag/inline_keigakomi.rb +4 -2
- data/lib/aozora2html/tag/inline_yokogumi.rb +4 -3
- data/lib/aozora2html/tag/jisage.rb +3 -1
- data/lib/aozora2html/tag/jizume.rb +3 -0
- data/lib/aozora2html/tag/kaeriten.rb +4 -2
- data/lib/aozora2html/tag/keigakomi.rb +15 -9
- data/lib/aozora2html/tag/kunten.rb +4 -4
- data/lib/aozora2html/tag/midashi.rb +3 -1
- data/lib/aozora2html/tag/multiline.rb +3 -0
- data/lib/aozora2html/tag/multiline_caption.rb +6 -8
- data/lib/aozora2html/tag/multiline_chitsuki.rb +3 -1
- data/lib/aozora2html/tag/multiline_jisage.rb +3 -1
- data/lib/aozora2html/tag/multiline_midashi.rb +6 -3
- data/lib/aozora2html/tag/multiline_style.rb +5 -3
- data/lib/aozora2html/tag/multiline_yokogumi.rb +6 -9
- data/lib/aozora2html/tag/okurigana.rb +4 -2
- data/lib/aozora2html/tag/oneline_chitsuki.rb +3 -2
- data/lib/aozora2html/tag/oneline_indent.rb +8 -1
- data/lib/aozora2html/tag/oneline_jisage.rb +3 -0
- data/lib/aozora2html/tag/reference_mentioned.rb +22 -21
- data/lib/aozora2html/tag/ruby.rb +174 -70
- data/lib/aozora2html/tag/un_embed_gaiji.rb +8 -2
- data/lib/aozora2html/tag.rb +40 -38
- data/lib/aozora2html/tag_parser.rb +23 -16
- data/lib/aozora2html/text_buffer.rb +50 -0
- data/lib/aozora2html/utils.rb +113 -50
- data/lib/aozora2html/version.rb +3 -1
- data/lib/aozora2html/yaml_loader.rb +8 -2
- data/lib/aozora2html/zip.rb +4 -0
- data/lib/aozora2html.rb +1358 -3
- data/lib/extensions.rb +2 -34
- data/lib/jstream.rb +96 -25
- data/sample/chukiichiran_kinyurei.html +15 -2
- data/sample/chukiichiran_kinyurei.txt +15 -2
- data/test/test_aozora2html.rb +137 -148
- data/test/test_aozora_accent_parser.rb +26 -9
- data/test/test_command_parse.rb +25 -22
- data/test/test_compat.rb +3 -4
- data/test/test_dakuten_katakana_tag.rb +10 -12
- data/test/test_decorate_tag.rb +9 -6
- data/test/test_dir_tag.rb +9 -6
- data/test/test_editor_note_tag.rb +8 -5
- data/test/test_exception.rb +10 -8
- data/test/test_font_size_tag.rb +16 -13
- data/test/test_gaiji_tag.rb +15 -14
- data/test/test_header.rb +25 -40
- data/test/test_helper.rb +3 -1
- data/test/test_i18n.rb +22 -6
- data/test/test_img_tag.rb +9 -5
- data/test/test_inline_caption_tag.rb +9 -6
- data/test/test_inline_font_size_tag.rb +13 -10
- data/test/test_inline_keigakomi_tag.rb +9 -6
- data/test/test_inline_yokogumi_tag.rb +9 -6
- data/test/test_jizume_tag.rb +9 -7
- data/test/test_jstream.rb +33 -30
- data/test/test_kaeriten_tag.rb +9 -6
- data/test/test_keigakomi_tag.rb +11 -9
- data/test/test_midashi_tag.rb +15 -14
- data/test/test_multiline_caption_tag.rb +7 -5
- data/test/test_multiline_midashi_tag.rb +24 -25
- data/test/test_multiline_style_tag.rb +9 -7
- data/test/test_multiline_yokogumi_tag.rb +7 -5
- data/test/test_okurigana_tag.rb +9 -6
- data/test/test_ruby_parse.rb +14 -14
- data/test/test_ruby_tag.rb +9 -6
- data/test/test_tag_parser.rb +28 -26
- metadata +60 -14
- data/.travis.yml +0 -12
- data/lib/t2hs.rb +0 -1607
data/test/test_img_tag.rb
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'test_helper'
|
|
2
4
|
require 'aozora2html'
|
|
3
5
|
|
|
4
6
|
class ImgTagTest < Test::Unit::TestCase
|
|
5
7
|
def setup
|
|
6
8
|
@parser = Object.new
|
|
7
|
-
stub(@parser).block_allowed_context?{true}
|
|
9
|
+
stub(@parser).block_allowed_context? { true }
|
|
8
10
|
end
|
|
9
11
|
|
|
10
12
|
def test_img_new
|
|
11
|
-
tag = Aozora2Html::Tag::Img.new(@parser,
|
|
13
|
+
tag = Aozora2Html::Tag::Img.new(@parser, 'foo.png', 'img1', 'alt img1', 40, 50)
|
|
12
14
|
assert_equal Aozora2Html::Tag::Img, tag.class
|
|
13
|
-
assert_equal true, tag.
|
|
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 = Aozora2Html::Tag::Img.new(@parser,
|
|
18
|
-
assert_equal
|
|
21
|
+
tag = Aozora2Html::Tag::Img.new(@parser, 'foo.png', 'img1', 'alt img1', 40, 50)
|
|
22
|
+
assert_equal '<img class="img1" width="40" height="50" src="foo.png" alt="alt img1" />', tag.to_s.to_utf8
|
|
19
23
|
end
|
|
20
24
|
|
|
21
25
|
def teardown
|
|
@@ -1,22 +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
|
|
8
|
-
stub(@parser).block_allowed_context?{true}
|
|
9
|
+
stub(@parser).block_allowed_context? { true }
|
|
9
10
|
end
|
|
10
11
|
|
|
11
12
|
def test_caption_new
|
|
12
|
-
tag = Aozora2Html::Tag::InlineCaption.new(@parser,
|
|
13
|
+
tag = Aozora2Html::Tag::InlineCaption.new(@parser, 'aaa')
|
|
13
14
|
assert_equal Aozora2Html::Tag::InlineCaption, tag.class
|
|
14
|
-
assert_equal true, tag.
|
|
15
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Inline)
|
|
15
16
|
end
|
|
16
17
|
|
|
18
|
+
using Aozora2Html::StringRefinements
|
|
19
|
+
|
|
17
20
|
def test_to_s
|
|
18
|
-
tag = Aozora2Html::Tag::InlineCaption.new(@parser,
|
|
19
|
-
assert_equal
|
|
21
|
+
tag = Aozora2Html::Tag::InlineCaption.new(@parser, 'テスト'.to_sjis)
|
|
22
|
+
assert_equal '<span class="caption">テスト</span>', tag.to_s.to_utf8
|
|
20
23
|
end
|
|
21
24
|
|
|
22
25
|
def teardown
|
|
@@ -1,32 +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
|
|
8
|
-
stub(@parser).block_allowed_context?{true}
|
|
9
|
+
stub(@parser).block_allowed_context? { true }
|
|
9
10
|
end
|
|
10
11
|
|
|
11
12
|
def test_font_size_new
|
|
12
|
-
tag = Aozora2Html::Tag::InlineFontSize.new(@parser,
|
|
13
|
+
tag = Aozora2Html::Tag::InlineFontSize.new(@parser, 'aa', 1, :dai)
|
|
13
14
|
assert_equal Aozora2Html::Tag::InlineFontSize, tag.class
|
|
14
|
-
assert_equal true, tag.
|
|
15
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Inline)
|
|
15
16
|
end
|
|
16
17
|
|
|
18
|
+
using Aozora2Html::StringRefinements
|
|
19
|
+
|
|
17
20
|
def test_to_s
|
|
18
|
-
tag = Aozora2Html::Tag::InlineFontSize.new(@parser,
|
|
19
|
-
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
|
|
20
23
|
end
|
|
21
24
|
|
|
22
25
|
def test_to_s2
|
|
23
|
-
tag = Aozora2Html::Tag::InlineFontSize.new(@parser,
|
|
24
|
-
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
|
|
25
28
|
end
|
|
26
29
|
|
|
27
30
|
def test_to_s3
|
|
28
|
-
tag = Aozora2Html::Tag::InlineFontSize.new(@parser,
|
|
29
|
-
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
|
|
30
33
|
end
|
|
31
34
|
|
|
32
35
|
def teardown
|
|
@@ -1,22 +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
|
|
8
|
-
stub(@parser).block_allowed_context?{true}
|
|
9
|
+
stub(@parser).block_allowed_context? { true }
|
|
9
10
|
end
|
|
10
11
|
|
|
11
12
|
def test_keigakomi_new
|
|
12
|
-
tag = Aozora2Html::Tag::InlineKeigakomi.new(@parser,
|
|
13
|
+
tag = Aozora2Html::Tag::InlineKeigakomi.new(@parser, 'aaa')
|
|
13
14
|
assert_equal Aozora2Html::Tag::InlineKeigakomi, tag.class
|
|
14
|
-
assert_equal true, tag.
|
|
15
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Inline)
|
|
15
16
|
end
|
|
16
17
|
|
|
18
|
+
using Aozora2Html::StringRefinements
|
|
19
|
+
|
|
17
20
|
def test_to_s
|
|
18
|
-
tag = Aozora2Html::Tag::InlineKeigakomi.new(@parser,
|
|
19
|
-
assert_equal
|
|
21
|
+
tag = Aozora2Html::Tag::InlineKeigakomi.new(@parser, 'テスト'.to_sjis)
|
|
22
|
+
assert_equal '<span class="keigakomi">テスト</span>', tag.to_s.to_utf8
|
|
20
23
|
end
|
|
21
24
|
|
|
22
25
|
def teardown
|
|
@@ -1,22 +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
|
|
8
|
-
stub(@parser).block_allowed_context?{true}
|
|
9
|
+
stub(@parser).block_allowed_context? { true }
|
|
9
10
|
end
|
|
10
11
|
|
|
11
12
|
def test_yokogumi_new
|
|
12
|
-
tag = Aozora2Html::Tag::InlineYokogumi.new(@parser,
|
|
13
|
+
tag = Aozora2Html::Tag::InlineYokogumi.new(@parser, 'aaa')
|
|
13
14
|
assert_equal Aozora2Html::Tag::InlineYokogumi, tag.class
|
|
14
|
-
assert_equal true, tag.
|
|
15
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Inline)
|
|
15
16
|
end
|
|
16
17
|
|
|
18
|
+
using Aozora2Html::StringRefinements
|
|
19
|
+
|
|
17
20
|
def test_to_s
|
|
18
|
-
tag = Aozora2Html::Tag::InlineYokogumi.new(@parser,
|
|
19
|
-
assert_equal
|
|
21
|
+
tag = Aozora2Html::Tag::InlineYokogumi.new(@parser, 'テスト'.to_sjis)
|
|
22
|
+
assert_equal '<span class="yokogumi">テスト</span>', tag.to_s.to_utf8
|
|
20
23
|
end
|
|
21
24
|
|
|
22
25
|
def teardown
|
data/test/test_jizume_tag.rb
CHANGED
|
@@ -1,23 +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
|
|
7
|
-
stub(@parser).block_allowed_context?{true}
|
|
9
|
+
stub(@parser).block_allowed_context? { true }
|
|
8
10
|
end
|
|
9
11
|
|
|
10
12
|
def test_jizume_new
|
|
11
|
-
tag = Aozora2Html::Tag::Jizume.new(@parser,50)
|
|
13
|
+
tag = Aozora2Html::Tag::Jizume.new(@parser, 50)
|
|
12
14
|
assert_equal Aozora2Html::Tag::Jizume, tag.class
|
|
13
|
-
assert_equal true, tag.
|
|
14
|
-
assert_equal true, tag.
|
|
15
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Block)
|
|
16
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Multiline)
|
|
15
17
|
end
|
|
16
18
|
|
|
17
19
|
def test_to_s
|
|
18
|
-
tag = Aozora2Html::Tag::Jizume.new(@parser,50)
|
|
19
|
-
assert_equal
|
|
20
|
-
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
|
|
21
23
|
end
|
|
22
24
|
|
|
23
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 # :eof以降は正しい値を保証しない
|
|
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,22 +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
|
|
8
|
-
stub(@parser).block_allowed_context?{true}
|
|
9
|
+
stub(@parser).block_allowed_context? { true }
|
|
9
10
|
end
|
|
10
11
|
|
|
11
12
|
def test_kaeriten_new
|
|
12
|
-
tag = Aozora2Html::Tag::Kaeriten.new(@parser,
|
|
13
|
+
tag = Aozora2Html::Tag::Kaeriten.new(@parser, 'aaa')
|
|
13
14
|
assert_equal Aozora2Html::Tag::Kaeriten, tag.class
|
|
14
|
-
assert_equal true, tag.
|
|
15
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Inline)
|
|
15
16
|
end
|
|
16
17
|
|
|
18
|
+
using Aozora2Html::StringRefinements
|
|
19
|
+
|
|
17
20
|
def test_to_s
|
|
18
|
-
tag = Aozora2Html::Tag::Kaeriten.new(@parser,
|
|
19
|
-
assert_equal
|
|
21
|
+
tag = Aozora2Html::Tag::Kaeriten.new(@parser, 'テスト'.to_sjis)
|
|
22
|
+
assert_equal '<sub class="kaeriten">テスト</sub>', tag.to_s.to_utf8
|
|
20
23
|
end
|
|
21
24
|
|
|
22
25
|
def teardown
|
data/test/test_keigakomi_tag.rb
CHANGED
|
@@ -1,29 +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
|
|
7
|
-
stub(@parser).block_allowed_context?{true}
|
|
9
|
+
stub(@parser).block_allowed_context? { true }
|
|
8
10
|
end
|
|
9
11
|
|
|
10
12
|
def test_keigakomi_new
|
|
11
|
-
tag = Aozora2Html::Tag::Keigakomi.new(@parser,2)
|
|
13
|
+
tag = Aozora2Html::Tag::Keigakomi.new(@parser, 2)
|
|
12
14
|
assert_equal Aozora2Html::Tag::Keigakomi, tag.class
|
|
13
|
-
assert_equal true, tag.
|
|
14
|
-
assert_equal true, tag.
|
|
15
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Block)
|
|
16
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Multiline)
|
|
15
17
|
end
|
|
16
18
|
|
|
17
19
|
def test_to_s
|
|
18
20
|
tag = Aozora2Html::Tag::Keigakomi.new(@parser)
|
|
19
|
-
assert_equal
|
|
20
|
-
assert_equal
|
|
21
|
+
assert_equal '<div class="keigakomi" style="border: solid 1px">', tag.to_s
|
|
22
|
+
assert_equal '</div>', tag.close_tag
|
|
21
23
|
end
|
|
22
24
|
|
|
23
25
|
def test_to_s2
|
|
24
|
-
tag = Aozora2Html::Tag::Keigakomi.new(@parser,2)
|
|
25
|
-
assert_equal
|
|
26
|
-
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
|
|
27
29
|
end
|
|
28
30
|
|
|
29
31
|
def teardown
|
data/test/test_midashi_tag.rb
CHANGED
|
@@ -1,36 +1,37 @@
|
|
|
1
|
-
#
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
require 'test_helper'
|
|
3
4
|
require 'aozora2html'
|
|
4
5
|
|
|
5
6
|
class MidashiTagTest < Test::Unit::TestCase
|
|
6
7
|
def setup
|
|
7
8
|
@parser = Object.new
|
|
8
|
-
stub(@parser).block_allowed_context?{true}
|
|
9
|
-
stub(@parser).new_midashi_id{2}
|
|
9
|
+
stub(@parser).block_allowed_context? { true }
|
|
10
|
+
stub(@parser).new_midashi_id { 2 }
|
|
10
11
|
end
|
|
11
12
|
|
|
13
|
+
using Aozora2Html::StringRefinements
|
|
14
|
+
|
|
12
15
|
def test_midashi_new
|
|
13
|
-
tag = Aozora2Html::Tag::Midashi.new(@parser,
|
|
16
|
+
tag = Aozora2Html::Tag::Midashi.new(@parser, 'テスト見出し'.to_sjis, '小'.to_sjis, :normal)
|
|
14
17
|
assert_equal Aozora2Html::Tag::Midashi, tag.class
|
|
15
|
-
assert_equal true, tag.
|
|
18
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Inline)
|
|
16
19
|
end
|
|
17
20
|
|
|
18
21
|
def test_to_s
|
|
19
|
-
tag = Aozora2Html::Tag::Midashi.new(@parser,
|
|
20
|
-
assert_equal "<h5 class=\"ko-midashi\"><a class=\"midashi_anchor\" id=\"midashi2\"
|
|
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
|
|
21
24
|
end
|
|
22
25
|
|
|
23
26
|
def test_to_s_mado
|
|
24
|
-
tag = Aozora2Html::Tag::Midashi.new(@parser,
|
|
25
|
-
assert_equal "<h5 class=\"mado-ko-midashi\"><a class=\"midashi_anchor\" id=\"midashi2\"
|
|
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
|
|
26
29
|
end
|
|
27
30
|
|
|
28
31
|
def test_undeined_midashi
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
assert_equal e.message(123).encode("utf-8"), "エラー(123行目):未定義な見出しです. \r\n処理を停止します"
|
|
33
|
-
end
|
|
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処理を停止します"
|
|
34
35
|
end
|
|
35
36
|
|
|
36
37
|
def teardown
|
|
@@ -1,23 +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
|
|
7
|
-
stub(@parser).block_allowed_context?{true}
|
|
9
|
+
stub(@parser).block_allowed_context? { true }
|
|
8
10
|
end
|
|
9
11
|
|
|
10
12
|
def test_multiline_caption_new
|
|
11
13
|
tag = Aozora2Html::Tag::MultilineCaption.new(@parser)
|
|
12
14
|
assert_equal Aozora2Html::Tag::MultilineCaption, tag.class
|
|
13
|
-
assert_equal true, tag.
|
|
14
|
-
assert_equal true, tag.
|
|
15
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Block)
|
|
16
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Multiline)
|
|
15
17
|
end
|
|
16
18
|
|
|
17
19
|
def test_to_s
|
|
18
20
|
tag = Aozora2Html::Tag::MultilineCaption.new(@parser)
|
|
19
|
-
assert_equal
|
|
20
|
-
assert_equal
|
|
21
|
+
assert_equal '<div class="caption">', tag.to_s
|
|
22
|
+
assert_equal '</div>', tag.close_tag
|
|
21
23
|
end
|
|
22
24
|
|
|
23
25
|
def teardown
|
|
@@ -1,53 +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
|
@parser = Object.new
|
|
8
|
-
stub(@parser).block_allowed_context?{true}
|
|
9
|
-
stub(@parser).new_midashi_id{2}
|
|
9
|
+
stub(@parser).block_allowed_context? { true }
|
|
10
|
+
stub(@parser).new_midashi_id { 2 }
|
|
10
11
|
end
|
|
11
12
|
|
|
13
|
+
using Aozora2Html::StringRefinements
|
|
14
|
+
|
|
12
15
|
def test_multiline_midashi_new
|
|
13
|
-
tag = Aozora2Html::Tag::MultilineMidashi.new(@parser,
|
|
16
|
+
tag = Aozora2Html::Tag::MultilineMidashi.new(@parser, '小'.to_sjis, :normal)
|
|
14
17
|
assert_equal Aozora2Html::Tag::MultilineMidashi, tag.class
|
|
15
|
-
assert_equal true, tag.
|
|
16
|
-
assert_equal true, tag.
|
|
18
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Block)
|
|
19
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Multiline)
|
|
17
20
|
end
|
|
18
21
|
|
|
19
22
|
def test_to_s
|
|
20
|
-
tag = Aozora2Html::Tag::MultilineMidashi.new(@parser,
|
|
21
|
-
assert_equal
|
|
22
|
-
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
|
|
23
26
|
end
|
|
24
27
|
|
|
25
28
|
def test_to_s_chu
|
|
26
|
-
tag = Aozora2Html::Tag::MultilineMidashi.new(@parser,
|
|
27
|
-
assert_equal
|
|
28
|
-
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
|
|
29
32
|
end
|
|
30
33
|
|
|
31
34
|
def test_to_s_dai
|
|
32
|
-
tag = Aozora2Html::Tag::MultilineMidashi.new(@parser,
|
|
33
|
-
assert_equal
|
|
34
|
-
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
|
|
35
38
|
end
|
|
36
39
|
|
|
37
40
|
def test_undeined_midashi
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
assert_equal e.message(123).encode("utf-8"), "エラー(123行目):未定義な見出しです. \r\n処理を停止します"
|
|
42
|
-
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処理を停止します"
|
|
43
44
|
end
|
|
44
45
|
|
|
45
46
|
def test_undeined_midashi2
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
assert_equal e.message(123).encode("utf-8"), "エラー(123行目):未定義な見出しです. \r\n処理を停止します"
|
|
50
|
-
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処理を停止します"
|
|
51
50
|
end
|
|
52
51
|
|
|
53
52
|
def teardown
|
|
@@ -1,23 +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
|
|
7
|
-
stub(@parser).block_allowed_context?{true}
|
|
9
|
+
stub(@parser).block_allowed_context? { true }
|
|
8
10
|
end
|
|
9
11
|
|
|
10
12
|
def test_multiline_style_new
|
|
11
|
-
tag = Aozora2Html::Tag::MultilineStyle.new(@parser,
|
|
13
|
+
tag = Aozora2Html::Tag::MultilineStyle.new(@parser, 'style1')
|
|
12
14
|
assert_equal Aozora2Html::Tag::MultilineStyle, tag.class
|
|
13
|
-
assert_equal true, tag.
|
|
14
|
-
assert_equal true, tag.
|
|
15
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Block)
|
|
16
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Multiline)
|
|
15
17
|
end
|
|
16
18
|
|
|
17
19
|
def test_to_s
|
|
18
|
-
tag = Aozora2Html::Tag::MultilineStyle.new(@parser,
|
|
19
|
-
assert_equal
|
|
20
|
-
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
|
|
21
23
|
end
|
|
22
24
|
|
|
23
25
|
def teardown
|
|
@@ -1,23 +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
|
|
7
|
-
stub(@parser).block_allowed_context?{true}
|
|
9
|
+
stub(@parser).block_allowed_context? { true }
|
|
8
10
|
end
|
|
9
11
|
|
|
10
12
|
def test_multiline_yokogumi_new
|
|
11
13
|
tag = Aozora2Html::Tag::MultilineYokogumi.new(@parser)
|
|
12
14
|
assert_equal Aozora2Html::Tag::MultilineYokogumi, tag.class
|
|
13
|
-
assert_equal true, tag.
|
|
14
|
-
assert_equal true, tag.
|
|
15
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Block)
|
|
16
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Multiline)
|
|
15
17
|
end
|
|
16
18
|
|
|
17
19
|
def test_to_s
|
|
18
20
|
tag = Aozora2Html::Tag::MultilineYokogumi.new(@parser)
|
|
19
|
-
assert_equal
|
|
20
|
-
assert_equal
|
|
21
|
+
assert_equal '<div class="yokogumi">', tag.to_s
|
|
22
|
+
assert_equal '</div>', tag.close_tag
|
|
21
23
|
end
|
|
22
24
|
|
|
23
25
|
def teardown
|
data/test/test_okurigana_tag.rb
CHANGED
|
@@ -1,22 +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
|
|
8
|
-
stub(@parser).block_allowed_context?{true}
|
|
9
|
+
stub(@parser).block_allowed_context? { true }
|
|
9
10
|
end
|
|
10
11
|
|
|
11
12
|
def test_okurigana_new
|
|
12
|
-
tag = Aozora2Html::Tag::Okurigana.new(@parser,
|
|
13
|
+
tag = Aozora2Html::Tag::Okurigana.new(@parser, 'aaa')
|
|
13
14
|
assert_equal Aozora2Html::Tag::Okurigana, tag.class
|
|
14
|
-
assert_equal true, tag.
|
|
15
|
+
assert_equal true, tag.is_a?(Aozora2Html::Tag::Inline)
|
|
15
16
|
end
|
|
16
17
|
|
|
18
|
+
using Aozora2Html::StringRefinements
|
|
19
|
+
|
|
17
20
|
def test_to_s
|
|
18
|
-
tag = Aozora2Html::Tag::Okurigana.new(@parser,
|
|
19
|
-
assert_equal
|
|
21
|
+
tag = Aozora2Html::Tag::Okurigana.new(@parser, 'テスト'.to_sjis)
|
|
22
|
+
assert_equal '<sup class="okurigana">テスト</sup>', tag.to_s.to_utf8
|
|
20
23
|
end
|
|
21
24
|
|
|
22
25
|
def teardown
|