aozora2html 2.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rubocop.yml +19 -0
- data/.github/workflows/ruby.yml +5 -3
- data/.gitignore +1 -0
- data/.rubocop.yml +38 -151
- data/.rubocop_todo.yml +7 -0
- data/CHANGELOG.md +41 -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 +25 -23
- 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/midashi_counter.rb +32 -0
- 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 +1329 -3
- data/lib/extensions.rb +2 -34
- data/lib/jstream.rb +96 -25
- data/sample/chukiichiran_kinyurei.html +42 -29
- data/sample/chukiichiran_kinyurei.txt +16 -3
- metadata +80 -83
- data/.travis.yml +0 -12
- data/lib/t2hs.rb +0 -1607
- data/test/test_aozora2html.rb +0 -379
- data/test/test_aozora_accent_parser.rb +0 -31
- data/test/test_command_parse.rb +0 -213
- data/test/test_compat.rb +0 -11
- data/test/test_dakuten_katakana_tag.rb +0 -27
- data/test/test_decorate_tag.rb +0 -24
- data/test/test_dir_tag.rb +0 -24
- data/test/test_editor_note_tag.rb +0 -22
- data/test/test_exception.rb +0 -23
- data/test/test_font_size_tag.rb +0 -41
- data/test/test_gaiji_tag.rb +0 -49
- data/test/test_header.rb +0 -60
- data/test/test_helper.rb +0 -5
- data/test/test_i18n.rb +0 -23
- data/test/test_img_tag.rb +0 -23
- data/test/test_inline_caption_tag.rb +0 -24
- data/test/test_inline_font_size_tag.rb +0 -34
- data/test/test_inline_keigakomi_tag.rb +0 -24
- data/test/test_inline_yokogumi_tag.rb +0 -24
- data/test/test_jizume_tag.rb +0 -25
- data/test/test_jstream.rb +0 -57
- data/test/test_kaeriten_tag.rb +0 -24
- data/test/test_keigakomi_tag.rb +0 -31
- data/test/test_midashi_tag.rb +0 -38
- data/test/test_multiline_caption_tag.rb +0 -25
- data/test/test_multiline_midashi_tag.rb +0 -55
- data/test/test_multiline_style_tag.rb +0 -25
- data/test/test_multiline_yokogumi_tag.rb +0 -25
- data/test/test_okurigana_tag.rb +0 -24
- data/test/test_ruby_parse.rb +0 -130
- data/test/test_ruby_tag.rb +0 -24
- data/test/test_tag_parser.rb +0 -80
@@ -1,12 +1,13 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
class Aozora2Html
|
3
4
|
class Tag
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
@n = n
|
5
|
+
# 濁点つきカタカナ用
|
6
|
+
class DakutenKatakana < Aozora2Html::Tag::Inline
|
7
|
+
def initialize(parser, num, katakana, gaiji_dir:)
|
8
|
+
@n = num
|
9
9
|
@katakana = katakana
|
10
|
+
@gaiji_dir = gaiji_dir
|
10
11
|
super
|
11
12
|
end
|
12
13
|
|
@@ -14,10 +15,11 @@ class Aozora2Html
|
|
14
15
|
:katakana
|
15
16
|
end
|
16
17
|
|
18
|
+
using StringRefinements
|
19
|
+
|
17
20
|
def to_s
|
18
|
-
"<img src=\"#{
|
21
|
+
"<img src=\"#{@gaiji_dir}/1-07/1-07-8#{@n}.png\" alt=\"" + '※(濁点付き片仮名「'.to_sjis + @katakana + '」、1-07-8'.to_sjis + "#{@n})\" class=\"gaiji\" />"
|
19
22
|
end
|
20
23
|
end
|
21
24
|
end
|
22
25
|
end
|
23
|
-
|
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Aozora2Html
|
2
4
|
class Tag
|
5
|
+
# 装飾用
|
3
6
|
class Decorate < Aozora2Html::Tag::ReferenceMentioned
|
4
|
-
|
5
7
|
def initialize(parser, target, html_class, html_tag)
|
6
8
|
@target = target
|
7
9
|
@close = "</#{html_tag}>"
|
@@ -10,9 +12,8 @@ class Aozora2Html
|
|
10
12
|
end
|
11
13
|
|
12
14
|
def to_s
|
13
|
-
@open
|
15
|
+
@open + @target.to_s + @close
|
14
16
|
end
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|
18
|
-
|
data/lib/aozora2html/tag/dir.rb
CHANGED
@@ -1,14 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Aozora2Html
|
2
4
|
class Tag
|
5
|
+
# 書字方向(LTR)の指定用
|
3
6
|
class Dir < Aozora2Html::Tag::ReferenceMentioned
|
4
|
-
|
5
7
|
def initialize(parser, target)
|
6
8
|
@target = target
|
7
9
|
super
|
8
10
|
end
|
9
11
|
|
10
12
|
def to_s
|
11
|
-
"<span dir=\"ltr\">#{@target
|
13
|
+
"<span dir=\"ltr\">#{@target}</span>"
|
12
14
|
end
|
13
15
|
end
|
14
16
|
end
|
@@ -1,15 +1,18 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
class Aozora2Html
|
3
4
|
class Tag
|
4
|
-
|
5
|
-
|
5
|
+
# 編集者による訂正用
|
6
|
+
class EditorNote < Aozora2Html::Tag::Inline
|
6
7
|
def initialize(parser, desc)
|
7
8
|
@desc = desc
|
8
9
|
super
|
9
10
|
end
|
10
11
|
|
12
|
+
using StringRefinements
|
13
|
+
|
11
14
|
def to_s
|
12
|
-
'<span class="notes">[#'.
|
15
|
+
'<span class="notes">[#'.to_sjis + @desc + ']</span>'.to_sjis
|
13
16
|
end
|
14
17
|
end
|
15
18
|
end
|
@@ -1,32 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Aozora2Html
|
2
4
|
class Tag
|
5
|
+
# 外字注記用
|
3
6
|
class EmbedGaiji < Aozora2Html::Tag::Gaiji
|
4
7
|
attr_accessor :unicode
|
5
8
|
|
6
9
|
@use_jisx0213 = nil
|
7
10
|
@use_unicode = nil
|
8
11
|
|
9
|
-
|
10
|
-
|
12
|
+
class << self
|
13
|
+
attr_writer :use_jisx0213
|
11
14
|
end
|
12
15
|
|
13
|
-
|
14
|
-
|
16
|
+
class << self
|
17
|
+
attr_reader :use_jisx0213
|
15
18
|
end
|
16
19
|
|
17
|
-
|
18
|
-
|
20
|
+
class << self
|
21
|
+
attr_writer :use_unicode
|
19
22
|
end
|
20
23
|
|
21
|
-
|
22
|
-
|
24
|
+
class << self
|
25
|
+
attr_reader :use_unicode
|
23
26
|
end
|
24
27
|
|
25
|
-
def initialize(parser, folder, code, name, unicode_num = nil)
|
28
|
+
def initialize(parser, folder, code, name, unicode_num = nil, gaiji_dir:)
|
26
29
|
@folder = folder
|
27
30
|
@code = code
|
28
31
|
@name = name
|
29
32
|
@unicode = unicode_num
|
33
|
+
@gaiji_dir = gaiji_dir
|
30
34
|
super
|
31
35
|
end
|
32
36
|
|
@@ -38,9 +42,9 @@ class Aozora2Html
|
|
38
42
|
if Aozora2Html::Tag::EmbedGaiji.use_jisx0213 && @code
|
39
43
|
jisx0213_to_unicode(@code.to_sym)
|
40
44
|
elsif Aozora2Html::Tag::EmbedGaiji.use_unicode && @unicode
|
41
|
-
|
45
|
+
"&#x#{@unicode};"
|
42
46
|
else
|
43
|
-
"<img src=\"#{
|
47
|
+
"<img src=\"#{@gaiji_dir}#{@folder}/#{@code}.png\" alt=\"" + GAIJI_MARK + "(#{@name})\" class=\"gaiji\" />"
|
44
48
|
end
|
45
49
|
end
|
46
50
|
end
|
@@ -1,7 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Aozora2Html
|
2
4
|
class Tag
|
3
|
-
|
4
|
-
|
5
|
+
# フォントサイズ指定用
|
6
|
+
class FontSize < Aozora2Html::Tag::Block
|
7
|
+
include Aozora2Html::Tag::Multiline
|
5
8
|
|
6
9
|
def initialize(parser, times, daisho)
|
7
10
|
@class = daisho.to_s + times.to_s
|
data/lib/aozora2html/tag/img.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Aozora2Html
|
2
4
|
class Tag
|
3
|
-
|
4
|
-
|
5
|
-
|
5
|
+
# 画像用
|
6
|
+
class Img < Aozora2Html::Tag::Inline
|
6
7
|
def initialize(parser, filename, css_class, alt, width, height)
|
7
8
|
@filename = filename
|
8
9
|
@css_class = css_class
|
@@ -18,4 +19,3 @@ class Aozora2Html
|
|
18
19
|
end
|
19
20
|
end
|
20
21
|
end
|
21
|
-
|
@@ -1,13 +1,16 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
# 全ての末端青空classはどちらかのmoduleをincludeする必要がある
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
4
3
|
class Aozora2Html
|
5
4
|
class Tag
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
# インラインタグ用class
|
6
|
+
#
|
7
|
+
# 全ての青空記法はHTML elementに変換される
|
8
|
+
# したがって、block/inlineの区別がある
|
9
|
+
# 全ての末端青空classはどちらかのclassのサブクラスになる必要がある
|
10
|
+
class Inline < Aozora2Html::Tag
|
11
|
+
def initialize(*_args)
|
12
|
+
super()
|
9
13
|
end
|
10
14
|
end
|
11
15
|
end
|
12
16
|
end
|
13
|
-
|
@@ -1,5 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Aozora2Html
|
2
4
|
class Tag
|
5
|
+
# インラインキャプション
|
3
6
|
class InlineCaption < Aozora2Html::Tag::ReferenceMentioned
|
4
7
|
def initialize(parser, target)
|
5
8
|
@target = target
|
@@ -7,9 +10,8 @@ class Aozora2Html
|
|
7
10
|
end
|
8
11
|
|
9
12
|
def to_s
|
10
|
-
"<span class=\"caption\">#{@target
|
13
|
+
"<span class=\"caption\">#{@target}</span>"
|
11
14
|
end
|
12
15
|
end
|
13
16
|
end
|
14
17
|
end
|
15
|
-
|
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Aozora2Html
|
2
4
|
class Tag
|
5
|
+
# インラインフォントサイズ指定用
|
3
6
|
class InlineFontSize < Aozora2Html::Tag::ReferenceMentioned
|
4
|
-
|
5
7
|
def initialize(parser, target, times, daisho)
|
6
8
|
@target = target
|
7
9
|
@class = daisho.to_s + times.to_s
|
@@ -10,9 +12,8 @@ class Aozora2Html
|
|
10
12
|
end
|
11
13
|
|
12
14
|
def to_s
|
13
|
-
"<span class=\"#{@class}\" style=\"font-size: #{@style};\"
|
15
|
+
"<span class=\"#{@class}\" style=\"font-size: #{@style};\">#{@target}</span>"
|
14
16
|
end
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|
18
|
-
|
@@ -1,5 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Aozora2Html
|
2
4
|
class Tag
|
5
|
+
# インライン罫囲み用
|
3
6
|
class InlineKeigakomi < Aozora2Html::Tag::ReferenceMentioned
|
4
7
|
def initialize(parser, target)
|
5
8
|
@target = target
|
@@ -7,9 +10,8 @@ class Aozora2Html
|
|
7
10
|
end
|
8
11
|
|
9
12
|
def to_s
|
10
|
-
"<span class=\"keigakomi\">#{@target
|
13
|
+
"<span class=\"keigakomi\">#{@target}</span>"
|
11
14
|
end
|
12
15
|
end
|
13
16
|
end
|
14
17
|
end
|
15
|
-
|
@@ -1,16 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Aozora2Html
|
2
4
|
class Tag
|
5
|
+
# インライン横組み用
|
3
6
|
class InlineYokogumi < Aozora2Html::Tag::ReferenceMentioned
|
4
|
-
|
5
7
|
def initialize(parser, target)
|
6
8
|
@target = target
|
7
9
|
super
|
8
10
|
end
|
9
11
|
|
10
12
|
def to_s
|
11
|
-
"<span class=\"yokogumi\">#{@target
|
13
|
+
"<span class=\"yokogumi\">#{@target}</span>"
|
12
14
|
end
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
16
|
-
|
@@ -1,14 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Aozora2Html
|
2
4
|
class Tag
|
5
|
+
# 返り点用
|
3
6
|
class Kaeriten < Aozora2Html::Tag::Kunten
|
4
|
-
|
5
7
|
def initialize(parser, string)
|
6
8
|
@string = string
|
7
9
|
super
|
8
10
|
end
|
9
11
|
|
10
12
|
def to_s
|
11
|
-
"<sub class=\"kaeriten\">#{@string
|
13
|
+
"<sub class=\"kaeriten\">#{@string}</sub>"
|
12
14
|
end
|
13
15
|
end
|
14
16
|
end
|
@@ -1,13 +1,19 @@
|
|
1
|
-
|
2
|
-
include Aozora2Html::Tag::Block, Aozora2Html::Tag::Multiline
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
class Aozora2Html
|
4
|
+
class Tag
|
5
|
+
# 罫囲み用
|
6
|
+
class Keigakomi < Aozora2Html::Tag::Block
|
7
|
+
include Aozora2Html::Tag::Multiline
|
8
|
+
|
9
|
+
def initialize(parser, size = 1)
|
10
|
+
@size = size
|
11
|
+
super
|
12
|
+
end
|
8
13
|
|
9
|
-
|
10
|
-
|
14
|
+
def to_s
|
15
|
+
"<div class=\"keigakomi\" style=\"border: solid #{@size}px\">"
|
16
|
+
end
|
17
|
+
end
|
11
18
|
end
|
12
19
|
end
|
13
|
-
|
@@ -1,12 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Aozora2Html
|
2
4
|
class Tag
|
3
|
-
|
4
|
-
|
5
|
-
|
5
|
+
# 訓点用
|
6
|
+
class Kunten < Aozora2Html::Tag::Inline
|
6
7
|
def char_type
|
7
8
|
:else # just remove this line
|
8
9
|
end
|
9
10
|
end
|
10
11
|
end
|
11
12
|
end
|
12
|
-
|
@@ -1,14 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Aozora2Html
|
2
4
|
class Tag
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
def initialize(parser)
|
7
|
-
super
|
8
|
-
end
|
9
|
-
|
5
|
+
# 複数行キャプション用
|
6
|
+
class MultilineCaption < Aozora2Html::Tag::Block
|
7
|
+
include Aozora2Html::Tag::Multiline
|
10
8
|
def to_s
|
11
|
-
|
9
|
+
'<div class="caption">'
|
12
10
|
end
|
13
11
|
end
|
14
12
|
end
|
@@ -1,9 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Aozora2Html
|
2
4
|
class Tag
|
3
|
-
|
4
|
-
|
5
|
+
# ブロックでの見出し指定用
|
6
|
+
class MultilineMidashi < Aozora2Html::Tag::Block
|
7
|
+
include Aozora2Html::Tag::Multiline
|
5
8
|
|
6
|
-
def initialize(parser,size,type)
|
9
|
+
def initialize(parser, size, type)
|
7
10
|
super
|
8
11
|
@tag = Utils.create_midashi_tag(size)
|
9
12
|
@id = parser.new_midashi_id(size)
|
@@ -1,7 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Aozora2Html
|
2
4
|
class Tag
|
3
|
-
|
4
|
-
|
5
|
+
# ブロックでのスタイル指定用
|
6
|
+
class MultilineStyle < Aozora2Html::Tag::Block
|
7
|
+
include Aozora2Html::Tag::Multiline
|
5
8
|
|
6
9
|
def initialize(parser, style)
|
7
10
|
@style = style
|
@@ -14,4 +17,3 @@ class Aozora2Html
|
|
14
17
|
end
|
15
18
|
end
|
16
19
|
end
|
17
|
-
|
@@ -1,17 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Aozora2Html
|
2
4
|
class Tag
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
def initialize(parser)
|
7
|
-
super
|
8
|
-
end
|
5
|
+
# ブロックでの横組指定用
|
6
|
+
class MultilineYokogumi < Aozora2Html::Tag::Block
|
7
|
+
include Aozora2Html::Tag::Multiline
|
9
8
|
|
10
9
|
def to_s
|
11
|
-
|
10
|
+
'<div class="yokogumi">'
|
12
11
|
end
|
13
12
|
end
|
14
13
|
end
|
15
14
|
end
|
16
|
-
|
17
|
-
|
@@ -1,14 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Aozora2Html
|
2
4
|
class Tag
|
5
|
+
# 訓点送り仮名用
|
3
6
|
class Okurigana < Aozora2Html::Tag::Kunten
|
4
|
-
|
5
7
|
def initialize(parser, string)
|
6
8
|
@string = string
|
7
9
|
super
|
8
10
|
end
|
9
11
|
|
10
12
|
def to_s
|
11
|
-
"<sup class=\"okurigana\">#{@string
|
13
|
+
"<sup class=\"okurigana\">#{@string}</sup>"
|
12
14
|
end
|
13
15
|
end
|
14
16
|
end
|
@@ -1,42 +1,43 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
3
|
class Aozora2Html
|
4
4
|
class Tag
|
5
|
-
|
6
|
-
|
5
|
+
# 参照先用
|
6
|
+
#
|
7
|
+
# 前方参照でこいつだけは中身をチェックする
|
8
|
+
# 子要素を持つAozora2Html::Tag::Inlineは全てこいつのサブクラス
|
9
|
+
class ReferenceMentioned < Aozora2Html::Tag::Inline
|
7
10
|
attr_accessor :target
|
8
11
|
|
9
|
-
def initialize(*
|
10
|
-
|
11
|
-
|
12
|
-
|
12
|
+
def initialize(*_args) # rubocop:disable Lint/MissingSuper
|
13
|
+
return unless defined?(@target) && block_element?(@target)
|
14
|
+
|
15
|
+
syntax_error
|
13
16
|
end
|
14
17
|
|
15
18
|
def block_element?(elt)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
22
|
-
nil
|
23
|
-
elsif elt.is_a?(String)
|
24
|
-
elt.match(/<div/)
|
19
|
+
case elt
|
20
|
+
when Array
|
21
|
+
elt.any? { |x| block_element?(x) }
|
22
|
+
when String
|
23
|
+
elt.include?('<div')
|
25
24
|
else
|
26
25
|
elt.is_a?(Aozora2Html::Tag::Block)
|
27
26
|
end
|
28
27
|
end
|
29
28
|
|
30
29
|
def target_string
|
31
|
-
|
30
|
+
case @target
|
31
|
+
when Aozora2Html::Tag::ReferenceMentioned
|
32
32
|
@target.target_string
|
33
|
-
|
34
|
-
@target.collect
|
33
|
+
when Array
|
34
|
+
@target.collect do |x|
|
35
35
|
if x.is_a?(Aozora2Html::Tag::ReferenceMentioned)
|
36
36
|
x.target_string
|
37
37
|
else
|
38
38
|
x
|
39
|
-
end
|
39
|
+
end
|
40
|
+
end.join
|
40
41
|
else
|
41
42
|
@target
|
42
43
|
end
|