aozora2html 3.0.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +2 -3
  3. data/.gitignore +1 -0
  4. data/.rubocop.yml +3 -0
  5. data/CHANGELOG.md +15 -0
  6. data/aozora2html.gemspec +2 -2
  7. data/lib/aozora2html/midashi_counter.rb +32 -0
  8. data/lib/aozora2html/tag/ruby.rb +1 -1
  9. data/lib/aozora2html/version.rb +1 -1
  10. data/lib/aozora2html.rb +21 -50
  11. data/sample/chukiichiran_kinyurei.html +27 -27
  12. data/sample/chukiichiran_kinyurei.txt +1 -1
  13. metadata +23 -72
  14. data/test/test_aozora2html.rb +0 -368
  15. data/test/test_aozora_accent_parser.rb +0 -48
  16. data/test/test_command_parse.rb +0 -216
  17. data/test/test_compat.rb +0 -10
  18. data/test/test_dakuten_katakana_tag.rb +0 -25
  19. data/test/test_decorate_tag.rb +0 -27
  20. data/test/test_dir_tag.rb +0 -27
  21. data/test/test_editor_note_tag.rb +0 -25
  22. data/test/test_exception.rb +0 -25
  23. data/test/test_font_size_tag.rb +0 -44
  24. data/test/test_gaiji_tag.rb +0 -50
  25. data/test/test_header.rb +0 -45
  26. data/test/test_helper.rb +0 -7
  27. data/test/test_i18n.rb +0 -39
  28. data/test/test_img_tag.rb +0 -27
  29. data/test/test_inline_caption_tag.rb +0 -27
  30. data/test/test_inline_font_size_tag.rb +0 -37
  31. data/test/test_inline_keigakomi_tag.rb +0 -27
  32. data/test/test_inline_yokogumi_tag.rb +0 -27
  33. data/test/test_jizume_tag.rb +0 -27
  34. data/test/test_jstream.rb +0 -60
  35. data/test/test_kaeriten_tag.rb +0 -27
  36. data/test/test_keigakomi_tag.rb +0 -33
  37. data/test/test_midashi_tag.rb +0 -39
  38. data/test/test_multiline_caption_tag.rb +0 -27
  39. data/test/test_multiline_midashi_tag.rb +0 -54
  40. data/test/test_multiline_style_tag.rb +0 -27
  41. data/test/test_multiline_yokogumi_tag.rb +0 -27
  42. data/test/test_okurigana_tag.rb +0 -27
  43. data/test/test_ruby_parse.rb +0 -130
  44. data/test/test_ruby_tag.rb +0 -27
  45. data/test/test_tag_parser.rb +0 -82
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
- require 'aozora2html'
5
-
6
- class DecorateTagTest < Test::Unit::TestCase
7
- def setup
8
- @parser = Object.new
9
- stub(@parser).block_allowed_context? { true }
10
- end
11
-
12
- def test_decorate_new
13
- tag = Aozora2Html::Tag::Decorate.new(@parser, 'aa', 1, :dai)
14
- assert_equal Aozora2Html::Tag::Decorate, tag.class
15
- assert_equal true, tag.is_a?(Aozora2Html::Tag::Inline)
16
- end
17
-
18
- using Aozora2Html::StringRefinements
19
-
20
- def test_to_s
21
- tag = Aozora2Html::Tag::Decorate.new(@parser, 'テスト'.to_sjis, 'foo', 'span')
22
- assert_equal '<span class="foo">テスト</span>', tag.to_s.to_utf8
23
- end
24
-
25
- def teardown
26
- end
27
- end
data/test/test_dir_tag.rb DELETED
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
- require 'aozora2html'
5
-
6
- class DirTagTest < Test::Unit::TestCase
7
- def setup
8
- @parser = Object.new
9
- stub(@parser).block_allowed_context? { true }
10
- end
11
-
12
- using Aozora2Html::StringRefinements
13
-
14
- def test_dir_new
15
- tag = Aozora2Html::Tag::Dir.new(@parser, 'テスト'.to_sjis)
16
- assert_equal Aozora2Html::Tag::Dir, tag.class
17
- assert_equal true, tag.is_a?(Aozora2Html::Tag::Inline)
18
- end
19
-
20
- def test_to_s
21
- tag = Aozora2Html::Tag::Dir.new(@parser, 'テスト'.to_sjis)
22
- assert_equal '<span dir="ltr">テスト</span>', tag.to_s.to_utf8
23
- end
24
-
25
- def teardown
26
- end
27
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
- require 'aozora2html'
5
-
6
- class EditorNoteTagTest < Test::Unit::TestCase
7
- def setup
8
- end
9
-
10
- using Aozora2Html::StringRefinements
11
-
12
- def test_editor_note_new
13
- tag = Aozora2Html::Tag::EditorNote.new(nil, '注記のテスト'.to_sjis)
14
- assert_equal Aozora2Html::Tag::EditorNote, tag.class
15
- assert_equal true, tag.is_a?(Aozora2Html::Tag::Inline)
16
- end
17
-
18
- def test_to_s
19
- tag = Aozora2Html::Tag::EditorNote.new(nil, '注記のテスト'.to_sjis)
20
- assert_equal '<span class="notes">[#注記のテスト]</span>', tag.to_s.to_utf8
21
- end
22
-
23
- def teardown
24
- end
25
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
- require 'aozora2html'
5
-
6
- class ExceptionTest < Test::Unit::TestCase
7
- def test_raise_aozora_exception
8
- assert_raises(Aozora2Html::Error) do
9
- raise Aozora2Html::Error, 'error!'
10
- end
11
- end
12
-
13
- using Aozora2Html::StringRefinements
14
-
15
- def test_raise_aozora_error
16
- error_msg = ''
17
- begin
18
- raise Aozora2Html::Error, 'sample error'
19
- rescue Aozora2Html::Error => e
20
- error_msg = e.message(123)
21
- end
22
- assert_equal "エラー(123行目):sample error. \r\n処理を停止します",
23
- error_msg.to_utf8
24
- end
25
- end
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
- require 'aozora2html'
5
-
6
- class FontSizeTagTest < Test::Unit::TestCase
7
- def setup
8
- @parser = Object.new
9
- stub(@parser).block_allowed_context? { true }
10
- end
11
-
12
- def test_font_size_new
13
- tag = Aozora2Html::Tag::FontSize.new(@parser, 1, :dai)
14
- assert_equal Aozora2Html::Tag::FontSize, tag.class
15
- assert_equal true, tag.is_a?(Aozora2Html::Tag::Block)
16
- assert_equal true, tag.is_a?(Aozora2Html::Tag::Multiline)
17
- end
18
-
19
- using Aozora2Html::StringRefinements
20
-
21
- def test_to_s
22
- tag = Aozora2Html::Tag::FontSize.new(@parser, 1, :dai)
23
- assert_equal '<div class="dai1" style="font-size: large;">', tag.to_s.to_utf8
24
- end
25
-
26
- def test_to_s2
27
- tag = Aozora2Html::Tag::FontSize.new(@parser, 2, :dai)
28
- assert_equal '<div class="dai2" style="font-size: x-large;">', tag.to_s.to_utf8
29
- end
30
-
31
- def test_to_s3
32
- tag = Aozora2Html::Tag::FontSize.new(@parser, 3, :sho)
33
- assert_equal '<div class="sho3" style="font-size: xx-small;">', tag.to_s.to_utf8
34
- end
35
-
36
- def test_to_s0
37
- assert_raise(Aozora2Html::Error.new('文字サイズの指定が不正です'.to_sjis)) do
38
- _tag = Aozora2Html::Tag::FontSize.new(@parser, 0, :sho)
39
- end
40
- end
41
-
42
- def teardown
43
- end
44
- end
@@ -1,50 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
- require 'aozora2html'
5
-
6
- class EmbedGaijiTagTest < Test::Unit::TestCase
7
- def setup
8
- @gaiji_dir = 'g_dir/'
9
- end
10
-
11
- using Aozora2Html::StringRefinements
12
-
13
- def test_gaiji_new
14
- egt = Aozora2Html::Tag::EmbedGaiji.new(nil, 'foo', '1-2-3', 'name', gaiji_dir: @gaiji_dir)
15
- assert_equal '<img src="g_dir/foo/1-2-3.png" alt="※(name)" class="gaiji" />', egt.to_s.to_utf8
16
- end
17
-
18
- def test_unembed_gaiji_new
19
- egt = Aozora2Html::Tag::UnEmbedGaiji.new(nil, 'テストtest'.to_sjis)
20
- assert_equal '<span class="notes">[テストtest]</span>', egt.to_s.to_utf8
21
- end
22
-
23
- def test_espcaed?
24
- egt = Aozora2Html::Tag::UnEmbedGaiji.new(nil, 'テストtest'.to_sjis)
25
- assert_equal false, egt.escaped?
26
- end
27
-
28
- def test_espcae!
29
- egt = Aozora2Html::Tag::UnEmbedGaiji.new(nil, 'テストtest'.to_sjis)
30
- egt.escape!
31
- assert_equal true, egt.escaped?
32
- end
33
-
34
- def test_jisx0213
35
- Aozora2Html::Tag::EmbedGaiji.use_jisx0213 = true
36
- egt = Aozora2Html::Tag::EmbedGaiji.new(nil, 'foo', '1-06-75', 'snowman', gaiji_dir: @gaiji_dir)
37
- assert_equal '&#x2603;', egt.to_s.to_utf8
38
- end
39
-
40
- def test_use_unicode
41
- Aozora2Html::Tag::EmbedGaiji.use_unicode = true
42
- egt = Aozora2Html::Tag::EmbedGaiji.new(nil, 'foo', '1-06-75', 'snowman', '2603', gaiji_dir: @gaiji_dir)
43
- assert_equal '&#x2603;', egt.to_s.to_utf8
44
- end
45
-
46
- def teardown
47
- Aozora2Html::Tag::EmbedGaiji.use_jisx0213 = false
48
- Aozora2Html::Tag::EmbedGaiji.use_unicode = false
49
- end
50
- end
data/test/test_header.rb DELETED
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
- require 'aozora2html'
5
-
6
- class HeaderTest < Test::Unit::TestCase
7
- def setup
8
- @header = Aozora2Html::Header.new(css_files: Array['../../aozora.css'])
9
- end
10
-
11
- using Aozora2Html::StringRefinements
12
-
13
- def test_header_to_html
14
- @header.push('武装せる市街'.to_sjis)
15
- @header.push('黒島伝治'.to_sjis)
16
- actual = @header.to_html.to_utf8
17
-
18
- # rubocop:disable Layout/LineLength
19
- expected =
20
- "<?xml version=\"1.0\" encoding=\"Shift_JIS\"?>\r\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"\r\n \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\r\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"ja\" >\r\n<head>\r\n\t<meta http-equiv=\"Content-Type\" content=\"text/html;charset=Shift_JIS\" />\r\n\t<meta http-equiv=\"content-style-type\" content=\"text/css\" />\r\n\t<link rel=\"stylesheet\" type=\"text/css\" href=\"../../aozora.css\" />\r\n\t<title>黒島伝治 武装せる市街</title>\r\n\t<script type=\"text/javascript\" src=\"../../jquery-1.4.2.min.js\"></script>\r\n <link rel=\"Schema.DC\" href=\"http://purl.org/dc/elements/1.1/\" />\r\n\t<meta name=\"DC.Title\" content=\"武装せる市街\" />\r\n\t<meta name=\"DC.Creator\" content=\"黒島伝治\" />\r\n\t<meta name=\"DC.Publisher\" content=\"青空文庫\" />\r\n</head>\r\n<body>\r\n<div class=\"metadata\">\r\n<h1 class=\"title\">武装せる市街</h1>\r\n<h2 class=\"author\">黒島伝治</h2>\r\n<br />\r\n<br />\r\n</div>\r\n<div id=\"contents\" style=\"display:none\"></div><div class=\"main_text\">"
21
- # rubocop:enable Layout/LineLength
22
-
23
- assert_equal(expected, actual)
24
- end
25
-
26
- def test_build_title
27
- @header.push('武装せる市街'.to_sjis)
28
- @header.push('黒島伝治'.to_sjis)
29
- header_info = @header.build_header_info
30
- actual = @header.build_title(header_info).to_utf8
31
- expected = '<title>黒島伝治 武装せる市街</title>'
32
- assert_equal(expected, actual)
33
- end
34
-
35
- def test_build_title2
36
- @header.push('スリーピー・ホローの伝説'.to_sjis)
37
- @header.push('故ディードリッヒ・ニッカボッカーの遺稿より'.to_sjis)
38
- @header.push('ワシントン・アーヴィング Washington Irving'.to_sjis)
39
- @header.push('吉田甲子太郎訳'.to_sjis)
40
- header_info = @header.build_header_info
41
- actual = @header.build_title(header_info).to_utf8
42
- expected = '<title>ワシントン・アーヴィング Washington Irving 吉田甲子太郎訳 スリーピー・ホローの伝説 故ディードリッヒ・ニッカボッカーの遺稿より</title>'
43
- assert_equal(expected, actual)
44
- end
45
- end
data/test/test_helper.rb DELETED
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- $LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../lib/")
4
- require 'test/unit'
5
- require 'test/unit/rr'
6
- require 'tmpdir'
7
- # require 'test/unit/notify'
data/test/test_i18n.rb DELETED
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
- require 'aozora2html'
5
-
6
- class I18nTest < Test::Unit::TestCase
7
- using Aozora2Html::StringRefinements
8
-
9
- def test_t
10
- assert_equal '警告(123行目):JIS外字「①」が使われています',
11
- Aozora2Html::I18n.t(:warn_jis_gaiji,
12
- 123,
13
- '①'.encode('cp932').force_encoding('shift_jis'))
14
- .force_encoding('cp932').to_utf8
15
- end
16
-
17
- def test_error_utf8
18
- orig_value = Aozora2Html::I18n.use_utf8
19
- Aozora2Html::I18n.use_utf8 = true
20
- begin
21
- assert_equal '警告(123行目):JIS外字「①」が使われています',
22
- Aozora2Html::I18n.t(:warn_jis_gaiji,
23
- 123,
24
- '①'.encode('cp932').force_encoding('shift_jis'))
25
- ensure
26
- Aozora2Html::I18n.use_utf8 = orig_value
27
- end
28
- end
29
-
30
- def test_ruby_puts_behavior
31
- $stdout = StringIO.new
32
- begin
33
- puts '①'.encode('cp932').force_encoding('shift_jis')
34
- assert_equal "①\n", $stdout.string.force_encoding('cp932').to_utf8
35
- ensure
36
- $stdout = STDOUT
37
- end
38
- end
39
- end
data/test/test_img_tag.rb DELETED
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
- require 'aozora2html'
5
-
6
- class ImgTagTest < Test::Unit::TestCase
7
- def setup
8
- @parser = Object.new
9
- stub(@parser).block_allowed_context? { true }
10
- end
11
-
12
- def test_img_new
13
- tag = Aozora2Html::Tag::Img.new(@parser, 'foo.png', 'img1', 'alt img1', 40, 50)
14
- assert_equal Aozora2Html::Tag::Img, tag.class
15
- assert_equal true, tag.is_a?(Aozora2Html::Tag::Inline)
16
- end
17
-
18
- using Aozora2Html::StringRefinements
19
-
20
- def test_to_s
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
23
- end
24
-
25
- def teardown
26
- end
27
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
- require 'aozora2html'
5
-
6
- class InlineCaptionTagTest < Test::Unit::TestCase
7
- def setup
8
- @parser = Object.new
9
- stub(@parser).block_allowed_context? { true }
10
- end
11
-
12
- def test_caption_new
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)
16
- end
17
-
18
- using Aozora2Html::StringRefinements
19
-
20
- def test_to_s
21
- tag = Aozora2Html::Tag::InlineCaption.new(@parser, 'テスト'.to_sjis)
22
- assert_equal '<span class="caption">テスト</span>', tag.to_s.to_utf8
23
- end
24
-
25
- def teardown
26
- end
27
- end
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
- require 'aozora2html'
5
-
6
- class InlineFontSizeTagTest < Test::Unit::TestCase
7
- def setup
8
- @parser = Object.new
9
- stub(@parser).block_allowed_context? { true }
10
- end
11
-
12
- def test_font_size_new
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)
16
- end
17
-
18
- using Aozora2Html::StringRefinements
19
-
20
- def test_to_s
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
23
- end
24
-
25
- def test_to_s2
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
28
- end
29
-
30
- def test_to_s3
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
33
- end
34
-
35
- def teardown
36
- end
37
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
- require 'aozora2html'
5
-
6
- class InlineKeigakomiTagTest < Test::Unit::TestCase
7
- def setup
8
- @parser = Object.new
9
- stub(@parser).block_allowed_context? { true }
10
- end
11
-
12
- def test_keigakomi_new
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)
16
- end
17
-
18
- using Aozora2Html::StringRefinements
19
-
20
- def test_to_s
21
- tag = Aozora2Html::Tag::InlineKeigakomi.new(@parser, 'テスト'.to_sjis)
22
- assert_equal '<span class="keigakomi">テスト</span>', tag.to_s.to_utf8
23
- end
24
-
25
- def teardown
26
- end
27
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
- require 'aozora2html'
5
-
6
- class InlineYokogumiTagTest < Test::Unit::TestCase
7
- def setup
8
- @parser = Object.new
9
- stub(@parser).block_allowed_context? { true }
10
- end
11
-
12
- def test_yokogumi_new
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)
16
- end
17
-
18
- using Aozora2Html::StringRefinements
19
-
20
- def test_to_s
21
- tag = Aozora2Html::Tag::InlineYokogumi.new(@parser, 'テスト'.to_sjis)
22
- assert_equal '<span class="yokogumi">テスト</span>', tag.to_s.to_utf8
23
- end
24
-
25
- def teardown
26
- end
27
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
- require 'aozora2html'
5
-
6
- class JizumeTagTest < Test::Unit::TestCase
7
- def setup
8
- @parser = Object.new
9
- stub(@parser).block_allowed_context? { true }
10
- end
11
-
12
- def test_jizume_new
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)
17
- end
18
-
19
- def test_to_s
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
23
- end
24
-
25
- def teardown
26
- end
27
- end
data/test/test_jstream.rb DELETED
@@ -1,60 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
- require 'aozora2html'
5
- require 'stringio'
6
-
7
- class JstreamTest < Test::Unit::TestCase
8
- using Aozora2Html::StringRefinements
9
-
10
- def test_new_error
11
- strio = StringIO.new("aaa\nbbb\n")
12
- orig_stdout = $stdout
13
- out = StringIO.new
14
- $stdout = out
15
- assert_raises(SystemExit) do
16
- Jstream.new(strio)
17
- end
18
- $stdout = orig_stdout
19
- assert_equal "エラー(1行目):改行コードを、「CR+LF」にあらためてください. \r\n処理を停止します\n", out.string.to_utf8
20
- end
21
-
22
- def test_read_char
23
- strio = StringIO.new("aあ5\r\n%\\b\r\n".to_sjis)
24
- stm = Jstream.new(strio)
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
33
- 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が複数回出る
36
- end
37
-
38
- def test_peek_char
39
- strio = StringIO.new("aあ5\r\n%\\b\r\n".to_sjis)
40
- stm = Jstream.new(strio)
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
49
-
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
54
-
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
59
- end
60
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
- require 'aozora2html'
5
-
6
- class KaeritenTagTest < Test::Unit::TestCase
7
- def setup
8
- @parser = Object.new
9
- stub(@parser).block_allowed_context? { true }
10
- end
11
-
12
- def test_kaeriten_new
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)
16
- end
17
-
18
- using Aozora2Html::StringRefinements
19
-
20
- def test_to_s
21
- tag = Aozora2Html::Tag::Kaeriten.new(@parser, 'テスト'.to_sjis)
22
- assert_equal '<sub class="kaeriten">テスト</sub>', tag.to_s.to_utf8
23
- end
24
-
25
- def teardown
26
- end
27
- end
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
- require 'aozora2html'
5
-
6
- class KeigakomiTagTest < Test::Unit::TestCase
7
- def setup
8
- @parser = Object.new
9
- stub(@parser).block_allowed_context? { true }
10
- end
11
-
12
- def test_keigakomi_new
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)
17
- end
18
-
19
- def test_to_s
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
23
- end
24
-
25
- def test_to_s2
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
29
- end
30
-
31
- def teardown
32
- end
33
- end
@@ -1,39 +0,0 @@
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,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
- require 'aozora2html'
5
-
6
- class MultilineCaptionTagTest < Test::Unit::TestCase
7
- def setup
8
- @parser = Object.new
9
- stub(@parser).block_allowed_context? { true }
10
- end
11
-
12
- def test_multiline_caption_new
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)
17
- end
18
-
19
- def test_to_s
20
- tag = Aozora2Html::Tag::MultilineCaption.new(@parser)
21
- assert_equal '<div class="caption">', tag.to_s
22
- assert_equal '</div>', tag.close_tag
23
- end
24
-
25
- def teardown
26
- end
27
- end