aozora2html 0.7.1 → 0.9.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.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/bin/aozora2html +3 -50
  3. data/lib/aozora2html.rb +0 -4
  4. data/lib/aozora2html/accent_parser.rb +91 -0
  5. data/lib/aozora2html/error.rb +16 -0
  6. data/lib/aozora2html/header.rb +139 -0
  7. data/lib/aozora2html/i18n.rb +17 -0
  8. data/lib/aozora2html/ruby_buffer.rb +81 -0
  9. data/lib/aozora2html/style_stack.rb +27 -0
  10. data/lib/aozora2html/tag.rb +55 -0
  11. data/lib/aozora2html/tag/accent.rb +39 -0
  12. data/lib/aozora2html/tag/block.rb +19 -0
  13. data/lib/aozora2html/tag/chitsuki.rb +15 -0
  14. data/lib/aozora2html/tag/dakuten_katakana.rb +23 -0
  15. data/lib/aozora2html/tag/decorate.rb +18 -0
  16. data/lib/aozora2html/tag/dir.rb +15 -0
  17. data/lib/aozora2html/tag/editor_note.rb +16 -0
  18. data/lib/aozora2html/tag/embed_gaiji.rb +48 -0
  19. data/lib/aozora2html/tag/font_size.rb +17 -0
  20. data/lib/aozora2html/tag/gaiji.rb +11 -0
  21. data/lib/aozora2html/tag/img.rb +21 -0
  22. data/lib/aozora2html/tag/indent.rb +8 -0
  23. data/lib/aozora2html/tag/inline.rb +13 -0
  24. data/lib/aozora2html/tag/inline_caption.rb +15 -0
  25. data/lib/aozora2html/tag/inline_font_size.rb +18 -0
  26. data/lib/aozora2html/tag/inline_keigakomi.rb +15 -0
  27. data/lib/aozora2html/tag/inline_yokogumi.rb +16 -0
  28. data/lib/aozora2html/tag/jisage.rb +15 -0
  29. data/lib/aozora2html/tag/jizume.rb +16 -0
  30. data/lib/aozora2html/tag/kaeriten.rb +15 -0
  31. data/lib/aozora2html/tag/keigakomi.rb +13 -0
  32. data/lib/aozora2html/tag/kunten.rb +12 -0
  33. data/lib/aozora2html/tag/midashi.rb +18 -0
  34. data/lib/aozora2html/tag/multiline.rb +6 -0
  35. data/lib/aozora2html/tag/multiline_caption.rb +15 -0
  36. data/lib/aozora2html/tag/multiline_chitsuki.rb +8 -0
  37. data/lib/aozora2html/tag/multiline_jisage.rb +8 -0
  38. data/lib/aozora2html/tag/multiline_midashi.rb +22 -0
  39. data/lib/aozora2html/tag/multiline_style.rb +17 -0
  40. data/lib/aozora2html/tag/multiline_yokogumi.rb +17 -0
  41. data/lib/aozora2html/tag/okurigana.rb +15 -0
  42. data/lib/aozora2html/tag/oneline_chitsuki.rb +9 -0
  43. data/lib/aozora2html/tag/oneline_indent.rb +2 -0
  44. data/lib/aozora2html/tag/oneline_jisage.rb +7 -0
  45. data/lib/aozora2html/tag/reference_mentioned.rb +46 -0
  46. data/lib/aozora2html/tag/ruby.rb +98 -0
  47. data/lib/aozora2html/tag/un_embed_gaiji.rb +24 -0
  48. data/lib/aozora2html/tag_parser.rb +53 -0
  49. data/lib/aozora2html/utils.rb +82 -0
  50. data/lib/aozora2html/version.rb +1 -1
  51. data/lib/aozora2html/yaml_loader.rb +31 -0
  52. data/lib/extensions.rb +31 -0
  53. data/lib/jstream.rb +68 -0
  54. data/lib/t2hs.rb +485 -1490
  55. data/test/test_aozora2html.rb +161 -57
  56. data/test/test_aozora_accent_parser.rb +13 -2
  57. data/test/test_command_parse.rb +213 -0
  58. data/test/test_dakuten_katakana_tag.rb +5 -4
  59. data/test/test_decorate_tag.rb +5 -4
  60. data/test/test_dir_tag.rb +5 -4
  61. data/test/test_editor_note_tag.rb +4 -4
  62. data/test/test_exception.rb +4 -4
  63. data/test/test_font_size_tag.rb +8 -7
  64. data/test/test_gaiji_tag.rb +14 -7
  65. data/test/test_header.rb +60 -0
  66. data/test/test_img_tag.rb +5 -4
  67. data/test/test_inline_caption_tag.rb +5 -4
  68. data/test/test_inline_font_size_tag.rb +7 -6
  69. data/test/test_inline_keigakomi_tag.rb +5 -4
  70. data/test/test_inline_yokogumi_tag.rb +5 -4
  71. data/test/test_jizume_tag.rb +7 -6
  72. data/test/test_jstream.rb +5 -5
  73. data/test/test_kaeriten_tag.rb +5 -4
  74. data/test/test_keigakomi_tag.rb +8 -7
  75. data/test/test_midashi_tag.rb +38 -0
  76. data/test/test_multiline_caption_tag.rb +7 -6
  77. data/test/test_multiline_midashi_tag.rb +12 -11
  78. data/test/test_multiline_style_tag.rb +7 -6
  79. data/test/test_multiline_yokogumi_tag.rb +7 -6
  80. data/test/test_okurigana_tag.rb +5 -4
  81. data/test/test_ruby_parse.rb +116 -0
  82. data/test/test_ruby_tag.rb +5 -4
  83. data/test/test_tag_parser.rb +10 -10
  84. data/yml/accent_table.yml +240 -0
  85. data/yml/command_table.yml +61 -0
  86. data/yml/jis2ucs.yml +11234 -0
  87. metadata +63 -6
  88. data/lib/accent_tag.rb +0 -23
  89. data/lib/aozora2html/jis2ucs.rb +0 -11237
  90. data/lib/embed_gaiji_tag.rb +0 -34
@@ -4,19 +4,20 @@ require 'aozora2html'
4
4
 
5
5
  class DakutenKatakanaTagTest < Test::Unit::TestCase
6
6
  def setup
7
+ @parser = Object.new
7
8
  @orig_gaiji_dir = $gaiji_dir
8
9
  $gaiji_dir = "g_dir"
9
10
  stub(@parser).block_allowed_context?{true}
10
11
  end
11
12
 
12
13
  def test_dakuten_katakana_new
13
- tag = Dakuten_katakana_tag.new(@parser,1,"ア".encode("shift_jis"))
14
- assert_equal Dakuten_katakana_tag, tag.class
15
- assert_equal true, tag.kind_of?(Inline_tag)
14
+ tag = Aozora2Html::Tag::DakutenKatakana.new(@parser,1,"ア".encode("shift_jis"))
15
+ assert_equal Aozora2Html::Tag::DakutenKatakana, tag.class
16
+ assert_equal true, tag.kind_of?(Aozora2Html::Tag::Inline)
16
17
  end
17
18
 
18
19
  def test_to_s
19
- tag = Dakuten_katakana_tag.new(@parser,1,"ア".encode("shift_jis"))
20
+ tag = Aozora2Html::Tag::DakutenKatakana.new(@parser,1,"ア".encode("shift_jis"))
20
21
  assert_equal "<img src=\"g_dir/1-07/1-07-81.png\" alt=\"※(濁点付き片仮名「ア」、1-07-81)\" class=\"gaiji\" />", tag.to_s.encode("utf-8")
21
22
  end
22
23
 
@@ -4,17 +4,18 @@ require 'aozora2html'
4
4
 
5
5
  class DecorateTagTest < Test::Unit::TestCase
6
6
  def setup
7
+ @parser = Object.new
7
8
  stub(@parser).block_allowed_context?{true}
8
9
  end
9
10
 
10
11
  def test_decorate_new
11
- tag = Decorate_tag.new(@parser,"aa",1,:dai)
12
- assert_equal Decorate_tag, tag.class
13
- assert_equal true, tag.kind_of?(Inline_tag)
12
+ tag = Aozora2Html::Tag::Decorate.new(@parser,"aa",1,:dai)
13
+ assert_equal Aozora2Html::Tag::Decorate, tag.class
14
+ assert_equal true, tag.kind_of?(Aozora2Html::Tag::Inline)
14
15
  end
15
16
 
16
17
  def test_to_s
17
- tag = Decorate_tag.new(@parser,"テスト".encode("shift_jis"),"foo","span")
18
+ tag = Aozora2Html::Tag::Decorate.new(@parser,"テスト".encode("shift_jis"),"foo","span")
18
19
  assert_equal "<span class=\"foo\">テスト</span>", tag.to_s.encode("utf-8")
19
20
  end
20
21
 
@@ -4,17 +4,18 @@ require 'aozora2html'
4
4
 
5
5
  class DirTagTest < Test::Unit::TestCase
6
6
  def setup
7
+ @parser = Object.new
7
8
  stub(@parser).block_allowed_context?{true}
8
9
  end
9
10
 
10
11
  def test_dir_new
11
- tag = Dir_tag.new(@parser,"テスト".encode("shift_jis"))
12
- assert_equal Dir_tag, tag.class
13
- assert_equal true, tag.kind_of?(Inline_tag)
12
+ tag = Aozora2Html::Tag::Dir.new(@parser,"テスト".encode("shift_jis"))
13
+ assert_equal Aozora2Html::Tag::Dir, tag.class
14
+ assert_equal true, tag.kind_of?(Aozora2Html::Tag::Inline)
14
15
  end
15
16
 
16
17
  def test_to_s
17
- tag = Dir_tag.new(@parser,"テスト".encode("shift_jis"))
18
+ tag = Aozora2Html::Tag::Dir.new(@parser,"テスト".encode("shift_jis"))
18
19
  assert_equal "<span dir=\"ltr\">テスト</span>", tag.to_s.encode("utf-8")
19
20
  end
20
21
 
@@ -7,13 +7,13 @@ class EditorNoteTagTest < Test::Unit::TestCase
7
7
  end
8
8
 
9
9
  def test_editor_note_new
10
- tag = Editor_note_tag.new(nil,"注記のテスト".encode("shift_jis"))
11
- assert_equal Editor_note_tag, tag.class
12
- assert_equal true, tag.kind_of?(Inline_tag)
10
+ tag = Aozora2Html::Tag::EditorNote.new(nil,"注記のテスト".encode("shift_jis"))
11
+ assert_equal Aozora2Html::Tag::EditorNote, tag.class
12
+ assert_equal true, tag.kind_of?(Aozora2Html::Tag::Inline)
13
13
  end
14
14
 
15
15
  def test_to_s
16
- tag = Editor_note_tag.new(nil,"注記のテスト".encode("shift_jis"))
16
+ tag = Aozora2Html::Tag::EditorNote.new(nil,"注記のテスト".encode("shift_jis"))
17
17
  assert_equal "<span class=\"notes\">[#注記のテスト]</span>", tag.to_s.encode("utf-8")
18
18
  end
19
19
 
@@ -4,16 +4,16 @@ require 'aozora2html'
4
4
 
5
5
  class ExceptionTest < Test::Unit::TestCase
6
6
  def test_raise_aozora_exception
7
- assert_raises(Aozora_Exception) do
8
- raise Aozora_Exception, "error!"
7
+ assert_raises(Aozora2Html::Error) do
8
+ raise Aozora2Html::Error, "error!"
9
9
  end
10
10
  end
11
11
 
12
12
  def test_raise_aozora_error
13
13
  error_msg = ""
14
14
  begin
15
- raise Aozora_Error, "sample error"
16
- rescue Aozora_Error => msg
15
+ raise Aozora2Html::Error, "sample error"
16
+ rescue Aozora2Html::Error => msg
17
17
  error_msg = msg.message(123)
18
18
  end
19
19
  assert_equal "エラー(123行目):sample error. \r\n処理を停止します",
@@ -3,28 +3,29 @@ require 'aozora2html'
3
3
 
4
4
  class FontSizeTagTest < Test::Unit::TestCase
5
5
  def setup
6
+ @parser = Object.new
6
7
  stub(@parser).block_allowed_context?{true}
7
8
  end
8
9
 
9
10
  def test_font_size_new
10
- tag = Font_size_tag.new(@parser,1,:dai)
11
- assert_equal Font_size_tag, tag.class
12
- assert_equal true, tag.kind_of?(Block_tag)
13
- assert_equal true, tag.kind_of?(Multiline_tag)
11
+ tag = Aozora2Html::Tag::FontSize.new(@parser,1,:dai)
12
+ assert_equal Aozora2Html::Tag::FontSize, tag.class
13
+ assert_equal true, tag.kind_of?(Aozora2Html::Tag::Block)
14
+ assert_equal true, tag.kind_of?(Aozora2Html::Tag::Multiline)
14
15
  end
15
16
 
16
17
  def test_to_s
17
- tag = Font_size_tag.new(@parser,1,:dai)
18
+ tag = Aozora2Html::Tag::FontSize.new(@parser,1,:dai)
18
19
  assert_equal "<div class=\"dai1\" style=\"font-size: large;\">", tag.to_s.encode("utf-8")
19
20
  end
20
21
 
21
22
  def test_to_s2
22
- tag = Font_size_tag.new(@parser,2,:dai)
23
+ tag = Aozora2Html::Tag::FontSize.new(@parser,2,:dai)
23
24
  assert_equal "<div class=\"dai2\" style=\"font-size: x-large;\">", tag.to_s.encode("utf-8")
24
25
  end
25
26
 
26
27
  def test_to_s3
27
- tag = Font_size_tag.new(@parser,3,:sho)
28
+ tag = Aozora2Html::Tag::FontSize.new(@parser,3,:sho)
28
29
  assert_equal "<div class=\"sho3\" style=\"font-size: xx-small;\">", tag.to_s.encode("utf-8")
29
30
  end
30
31
 
@@ -9,34 +9,41 @@ class EmbedGaijiTagTest < Test::Unit::TestCase
9
9
  end
10
10
 
11
11
  def test_gaiji_new
12
- egt = Embed_Gaiji_tag.new(nil,"foo","1-2-3","name")
12
+ egt = Aozora2Html::Tag::EmbedGaiji.new(nil,"foo","1-2-3","name")
13
13
  assert_equal "<img src=\"g_dir/foo/1-2-3.png\" alt=\"※(name)\" class=\"gaiji\" />", egt.to_s.encode("utf-8")
14
14
  end
15
15
 
16
16
  def test_unembed_gaiji_new
17
- egt = UnEmbed_Gaiji_tag.new(nil,"テストtest".encode("Shift_JIS"))
17
+ egt = Aozora2Html::Tag::UnEmbedGaiji.new(nil,"テストtest".encode("Shift_JIS"))
18
18
  assert_equal "<span class=\"notes\">[テストtest]</span>", egt.to_s.encode("utf-8")
19
19
  end
20
20
 
21
21
  def test_espcaed?
22
- egt = UnEmbed_Gaiji_tag.new(nil,"テストtest".encode("Shift_JIS"))
22
+ egt = Aozora2Html::Tag::UnEmbedGaiji.new(nil,"テストtest".encode("Shift_JIS"))
23
23
  assert_equal false, egt.escaped?
24
24
  end
25
25
 
26
26
  def test_espcae!
27
- egt = UnEmbed_Gaiji_tag.new(nil,"テストtest".encode("Shift_JIS"))
27
+ egt = Aozora2Html::Tag::UnEmbedGaiji.new(nil,"テストtest".encode("Shift_JIS"))
28
28
  egt.escape!
29
29
  assert_equal true, egt.escaped?
30
30
  end
31
31
 
32
32
  def test_jisx0213
33
- Embed_Gaiji_tag.use_jisx0213 = true
34
- egt = Embed_Gaiji_tag.new(nil,"foo","1-06-75","snowman")
33
+ Aozora2Html::Tag::EmbedGaiji.use_jisx0213 = true
34
+ egt = Aozora2Html::Tag::EmbedGaiji.new(nil,"foo","1-06-75","snowman")
35
+ assert_equal "&#x2603;", egt.to_s.encode("utf-8")
36
+ end
37
+
38
+ def test_use_unicode
39
+ Aozora2Html::Tag::EmbedGaiji.use_unicode = true
40
+ egt = Aozora2Html::Tag::EmbedGaiji.new(nil,"foo","1-06-75","snowman","2603")
35
41
  assert_equal "&#x2603;", egt.to_s.encode("utf-8")
36
42
  end
37
43
 
38
44
  def teardown
39
- Embed_Gaiji_tag.use_jisx0213 = false
45
+ Aozora2Html::Tag::EmbedGaiji.use_jisx0213 = false
46
+ Aozora2Html::Tag::EmbedGaiji.use_unicode = false
40
47
  $gaiji_dir = @orig_gaiji_dir
41
48
  end
42
49
  end
@@ -0,0 +1,60 @@
1
+ # encoding: utf-8
2
+ require 'test_helper'
3
+ require 'aozora2html'
4
+
5
+ class HeaderTest < Test::Unit::TestCase
6
+ def setup
7
+ @header = Aozora2Html::Header.new
8
+ end
9
+
10
+ def test_header_to_html
11
+ @header.push("武装せる市街".encode("shift_jis"))
12
+ @header.push("黒島伝治".encode("shift_jis"))
13
+ actual = @header.to_html.encode("utf-8")
14
+ expected =
15
+ "<?xml version=\"1.0\" encoding=\"Shift_JIS\"?>\r\n" +
16
+ "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"\r\n" +
17
+ " \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\r\n" +
18
+ "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"ja\" >\r\n" +
19
+ "<head>\r\n" +
20
+ "\t<meta http-equiv=\"Content-Type\" content=\"text/html;charset=Shift_JIS\" />\r\n" +
21
+ "\t<meta http-equiv=\"content-style-type\" content=\"text/css\" />\r\n" +
22
+ "\t<link rel=\"stylesheet\" type=\"text/css\" href=\"../../aozora.css\" />\r\n" +
23
+ "\t<title>黒島伝治 武装せる市街</title>\r\n" +
24
+ "\t<script type=\"text/javascript\" src=\"../../jquery-1.4.2.min.js\"></script>\r\n" +
25
+ " <link rel=\"Schema.DC\" href=\"http://purl.org/dc/elements/1.1/\" />\r\n" +
26
+ "\t<meta name=\"DC.Title\" content=\"武装せる市街\" />\r\n" +
27
+ "\t<meta name=\"DC.Creator\" content=\"黒島伝治\" />\r\n" +
28
+ "\t<meta name=\"DC.Publisher\" content=\"青空文庫\" />\r\n" +
29
+ "</head>\r\n" +
30
+ "<body>\r\n" +
31
+ "<div class=\"metadata\">\r\n" +
32
+ "<h1 class=\"title\">武装せる市街</h1>\r\n" +
33
+ "<h2 class=\"author\">黒島伝治</h2>\r\n" +
34
+ "<br />\r\n" +
35
+ "<br />\r\n" +
36
+ "</div>\r\n" +
37
+ "<div id=\"contents\" style=\"display:none\"></div><div class=\"main_text\">"
38
+ assert_equal(expected, actual)
39
+ end
40
+
41
+ def test_build_title
42
+ @header.push("武装せる市街".encode("shift_jis"))
43
+ @header.push("黒島伝治".encode("shift_jis"))
44
+ header_info = @header.build_header_info()
45
+ actual = @header.build_title(header_info).encode("utf-8")
46
+ expected = "<title>黒島伝治 武装せる市街</title>"
47
+ assert_equal(expected, actual)
48
+ end
49
+
50
+ def test_build_title2
51
+ @header.push("スリーピー・ホローの伝説".encode("shift_jis"))
52
+ @header.push("故ディードリッヒ・ニッカボッカーの遺稿より".encode("shift_jis"))
53
+ @header.push("ワシントン・アーヴィング Washington Irving".encode("shift_jis"))
54
+ @header.push("吉田甲子太郎訳".encode("shift_jis"))
55
+ header_info = @header.build_header_info()
56
+ actual = @header.build_title(header_info).encode("utf-8")
57
+ expected = "<title>ワシントン・アーヴィング Washington Irving 吉田甲子太郎訳 スリーピー・ホローの伝説 故ディードリッヒ・ニッカボッカーの遺稿より</title>"
58
+ assert_equal(expected, actual)
59
+ end
60
+ end
@@ -3,17 +3,18 @@ require 'aozora2html'
3
3
 
4
4
  class ImgTagTest < Test::Unit::TestCase
5
5
  def setup
6
+ @parser = Object.new
6
7
  stub(@parser).block_allowed_context?{true}
7
8
  end
8
9
 
9
10
  def test_img_new
10
- tag = Img_tag.new(@parser,"foo.png","img1","alt img1",40,50)
11
- assert_equal Img_tag, tag.class
12
- assert_equal true, tag.kind_of?(Inline_tag)
11
+ tag = Aozora2Html::Tag::Img.new(@parser,"foo.png","img1","alt img1",40,50)
12
+ assert_equal Aozora2Html::Tag::Img, tag.class
13
+ assert_equal true, tag.kind_of?(Aozora2Html::Tag::Inline)
13
14
  end
14
15
 
15
16
  def test_to_s
16
- tag = Img_tag.new(@parser,"foo.png","img1","alt img1",40,50)
17
+ tag = Aozora2Html::Tag::Img.new(@parser,"foo.png","img1","alt img1",40,50)
17
18
  assert_equal "<img class=\"img1\" width=\"40\" height=\"50\" src=\"foo.png\" alt=\"alt img1\" />", tag.to_s.encode("utf-8")
18
19
  end
19
20
 
@@ -4,17 +4,18 @@ require 'aozora2html'
4
4
 
5
5
  class InlineCaptionTagTest < Test::Unit::TestCase
6
6
  def setup
7
+ @parser = Object.new
7
8
  stub(@parser).block_allowed_context?{true}
8
9
  end
9
10
 
10
11
  def test_caption_new
11
- tag = Inline_caption_tag.new(@parser,"aaa")
12
- assert_equal Inline_caption_tag, tag.class
13
- assert_equal true, tag.kind_of?(Inline_tag)
12
+ tag = Aozora2Html::Tag::InlineCaption.new(@parser,"aaa")
13
+ assert_equal Aozora2Html::Tag::InlineCaption, tag.class
14
+ assert_equal true, tag.kind_of?(Aozora2Html::Tag::Inline)
14
15
  end
15
16
 
16
17
  def test_to_s
17
- tag = Inline_caption_tag.new(@parser,"テスト".encode("shift_jis"))
18
+ tag = Aozora2Html::Tag::InlineCaption.new(@parser,"テスト".encode("shift_jis"))
18
19
  assert_equal "<span class=\"caption\">テスト</span>", tag.to_s.encode("utf-8")
19
20
  end
20
21
 
@@ -4,27 +4,28 @@ require 'aozora2html'
4
4
 
5
5
  class InlineFontSizeTagTest < Test::Unit::TestCase
6
6
  def setup
7
+ @parser = Object.new
7
8
  stub(@parser).block_allowed_context?{true}
8
9
  end
9
10
 
10
11
  def test_font_size_new
11
- tag = Inline_font_size_tag.new(@parser,"aa",1,:dai)
12
- assert_equal Inline_font_size_tag, tag.class
13
- assert_equal true, tag.kind_of?(Inline_tag)
12
+ tag = Aozora2Html::Tag::InlineFontSize.new(@parser,"aa",1,:dai)
13
+ assert_equal Aozora2Html::Tag::InlineFontSize, tag.class
14
+ assert_equal true, tag.kind_of?(Aozora2Html::Tag::Inline)
14
15
  end
15
16
 
16
17
  def test_to_s
17
- tag = Inline_font_size_tag.new(@parser,"テスト".encode("shift_jis"),1,:dai)
18
+ tag = Aozora2Html::Tag::InlineFontSize.new(@parser,"テスト".encode("shift_jis"),1,:dai)
18
19
  assert_equal "<span class=\"dai1\" style=\"font-size: large;\">テスト</span>", tag.to_s.encode("utf-8")
19
20
  end
20
21
 
21
22
  def test_to_s2
22
- tag = Inline_font_size_tag.new(@parser,"テスト".encode("shift_jis"),2,:sho)
23
+ tag = Aozora2Html::Tag::InlineFontSize.new(@parser,"テスト".encode("shift_jis"),2,:sho)
23
24
  assert_equal "<span class=\"sho2\" style=\"font-size: x-small;\">テスト</span>", tag.to_s.encode("utf-8")
24
25
  end
25
26
 
26
27
  def test_to_s3
27
- tag = Inline_font_size_tag.new(@parser,"テスト".encode("shift_jis"),3,:sho)
28
+ tag = Aozora2Html::Tag::InlineFontSize.new(@parser,"テスト".encode("shift_jis"),3,:sho)
28
29
  assert_equal "<span class=\"sho3\" style=\"font-size: xx-small;\">テスト</span>", tag.to_s.encode("utf-8")
29
30
  end
30
31
 
@@ -4,17 +4,18 @@ require 'aozora2html'
4
4
 
5
5
  class InlineKeigakomiTagTest < Test::Unit::TestCase
6
6
  def setup
7
+ @parser = Object.new
7
8
  stub(@parser).block_allowed_context?{true}
8
9
  end
9
10
 
10
11
  def test_keigakomi_new
11
- tag = Inline_keigakomi_tag.new(@parser,"aaa")
12
- assert_equal Inline_keigakomi_tag, tag.class
13
- assert_equal true, tag.kind_of?(Inline_tag)
12
+ tag = Aozora2Html::Tag::InlineKeigakomi.new(@parser,"aaa")
13
+ assert_equal Aozora2Html::Tag::InlineKeigakomi, tag.class
14
+ assert_equal true, tag.kind_of?(Aozora2Html::Tag::Inline)
14
15
  end
15
16
 
16
17
  def test_to_s
17
- tag = Inline_keigakomi_tag.new(@parser,"テスト".encode("shift_jis"))
18
+ tag = Aozora2Html::Tag::InlineKeigakomi.new(@parser,"テスト".encode("shift_jis"))
18
19
  assert_equal "<span class=\"keigakomi\">テスト</span>", tag.to_s.encode("utf-8")
19
20
  end
20
21
 
@@ -4,17 +4,18 @@ require 'aozora2html'
4
4
 
5
5
  class InlineYokogumiTagTest < Test::Unit::TestCase
6
6
  def setup
7
+ @parser = Object.new
7
8
  stub(@parser).block_allowed_context?{true}
8
9
  end
9
10
 
10
11
  def test_yokogumi_new
11
- tag = Inline_yokogumi_tag.new(@parser,"aaa")
12
- assert_equal Inline_yokogumi_tag, tag.class
13
- assert_equal true, tag.kind_of?(Inline_tag)
12
+ tag = Aozora2Html::Tag::InlineYokogumi.new(@parser,"aaa")
13
+ assert_equal Aozora2Html::Tag::InlineYokogumi, tag.class
14
+ assert_equal true, tag.kind_of?(Aozora2Html::Tag::Inline)
14
15
  end
15
16
 
16
17
  def test_to_s
17
- tag = Inline_yokogumi_tag.new(@parser,"テスト".encode("shift_jis"))
18
+ tag = Aozora2Html::Tag::InlineYokogumi.new(@parser,"テスト".encode("shift_jis"))
18
19
  assert_equal "<span class=\"yokogumi\">テスト</span>", tag.to_s.encode("utf-8")
19
20
  end
20
21
 
@@ -3,18 +3,19 @@ require 'aozora2html'
3
3
 
4
4
  class JizumeTagTest < Test::Unit::TestCase
5
5
  def setup
6
- stub(@parser).block_allowed_context?{true}
6
+ @parser = Object.new
7
+ stub(@parser).block_allowed_context?{true}
7
8
  end
8
9
 
9
10
  def test_jizume_new
10
- tag = Jizume_tag.new(@parser,50)
11
- assert_equal Jizume_tag, tag.class
12
- assert_equal true, tag.kind_of?(Block_tag)
13
- assert_equal true, tag.kind_of?(Multiline_tag)
11
+ tag = Aozora2Html::Tag::Jizume.new(@parser,50)
12
+ assert_equal Aozora2Html::Tag::Jizume, tag.class
13
+ assert_equal true, tag.kind_of?(Aozora2Html::Tag::Block)
14
+ assert_equal true, tag.kind_of?(Aozora2Html::Tag::Multiline)
14
15
  end
15
16
 
16
17
  def test_to_s
17
- tag = Jizume_tag.new(@parser,50)
18
+ tag = Aozora2Html::Tag::Jizume.new(@parser,50)
18
19
  assert_equal "<div class=\"jizume_50\" style=\"width: 50em\">", tag.to_s
19
20
  assert_equal "</div>", tag.close_tag
20
21
  end
@@ -28,8 +28,8 @@ class JstreamTest < Test::Unit::TestCase
28
28
  assert_equal "b", stm.read_char.encode("utf-8")
29
29
  assert_equal "\r\n", stm.read_char.encode("utf-8")
30
30
  assert_equal :eof, stm.read_char
31
- assert_equal "\r\n", stm.read_char # XXX ??
32
- assert_equal :eof, stm.read_char # XXX ??
31
+ assert_equal "\r\n", stm.read_char # :eof以降は正しい値を保証しない
32
+ assert_equal :eof, stm.read_char # 何度もread_charすると:eofが複数回出る
33
33
  end
34
34
 
35
35
  def test_peek_char
@@ -39,9 +39,9 @@ class JstreamTest < Test::Unit::TestCase
39
39
  assert_equal "あ", stm.peek_char(1).encode("utf-8")
40
40
  assert_equal "5", stm.peek_char(2).encode("utf-8")
41
41
  assert_equal "\r\n", stm.peek_char(3).encode("utf-8")
42
- assert_equal "\r\n", stm.peek_char(4).encode("utf-8") # XXX ??
43
- assert_equal "\r\n", stm.peek_char(5).encode("utf-8") # XXX ??
44
- assert_equal "\r\n", stm.peek_char(100).encode("utf-8") # XXX ??
42
+ assert_equal "\r\n", stm.peek_char(4).encode("utf-8") # 改行文字以降は正しい値を保証しない
43
+ assert_equal "\r\n", stm.peek_char(5).encode("utf-8") # 同上
44
+ assert_equal "\r\n", stm.peek_char(100).encode("utf-8") # 同上
45
45
  assert_equal "a", stm.read_char.encode("utf-8")
46
46
 
47
47
  assert_equal "あ", stm.peek_char(0).encode("utf-8")
@@ -4,17 +4,18 @@ require 'aozora2html'
4
4
 
5
5
  class KaeritenTagTest < Test::Unit::TestCase
6
6
  def setup
7
+ @parser = Object.new
7
8
  stub(@parser).block_allowed_context?{true}
8
9
  end
9
10
 
10
11
  def test_kaeriten_new
11
- tag = Kaeriten_tag.new(@parser,"aaa")
12
- assert_equal Kaeriten_tag, tag.class
13
- assert_equal true, tag.kind_of?(Inline_tag)
12
+ tag = Aozora2Html::Tag::Kaeriten.new(@parser,"aaa")
13
+ assert_equal Aozora2Html::Tag::Kaeriten, tag.class
14
+ assert_equal true, tag.kind_of?(Aozora2Html::Tag::Inline)
14
15
  end
15
16
 
16
17
  def test_to_s
17
- tag = Kaeriten_tag.new(@parser,"テスト".encode("shift_jis"))
18
+ tag = Aozora2Html::Tag::Kaeriten.new(@parser,"テスト".encode("shift_jis"))
18
19
  assert_equal "<sub class=\"kaeriten\">テスト</sub>", tag.to_s.encode("utf-8")
19
20
  end
20
21