mdextab 0.1.5 → 0.1.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 409eda158bf955f5ae51fa53d5a087e00b642452d77610d5d9af13e57ff76758
4
- data.tar.gz: 91765084458edf0fbe1042e926d4dc0b641c018ef020e7662661216771c5251f
3
+ metadata.gz: 30954db83b3ff5d42198eb363617f1dd143bc753f602410d9f2accf108636ac1
4
+ data.tar.gz: 4482a475295a0d00705173c6bb1682486e3d74bfed580810362f6ab142080909
5
5
  SHA512:
6
- metadata.gz: b9d17b9cfc05a3ea645d723b049f83f26e80b8ca562ef6405bafc979b3b5afa8309f3e837b26e2f7d64fbe1d9d94404370fa28e1cb41ff082d2d592838a014e2
7
- data.tar.gz: c1846f3aa1ee6bec4c3f5a2a6e78dfc2b1fd21d6b9dc1e45804e464d9f2317b2b7589ee405f8e08e0043b2b4b689892be91d255f52cc44c000d8fa6b0734e114
6
+ metadata.gz: 16fa6d519c1570b4cf4243265601a4489eb6743827b7cd298c991d87b0b562416118439616550ff20cfcfad65cd9798840dba6cb1627dfb721473cc84aa70d26
7
+ data.tar.gz: cb837801ecbcc40b90d2b0d37eba3059dbf675e14bb3eeb0eafedaf013f78c5a8c83eda1befd2bdff76e7577bf54f93c8e5be33bb02bc9f5110dc6765f62de4b
data/.gitmodules CHANGED
File without changes
data/.rspec CHANGED
File without changes
data/.rubocop.yml CHANGED
File without changes
data/.rubocop_todo.yml CHANGED
File without changes
data/.travis.yml CHANGED
File without changes
data/Gemfile CHANGED
File without changes
data/LICENSE.txt CHANGED
File without changes
data/README.md CHANGED
File without changes
data/Rakefile CHANGED
File without changes
data/lib/mdextab/layer.rb CHANGED
@@ -1,43 +1,82 @@
1
1
  module Mdextab
2
+ #
3
+ # 入れ子のTableにを管理するレイヤークラス
2
4
  class Layer
3
- attr_accessor :return_from_nested_env, :cur_layer, :size
4
-
5
+ # 入れ子のレイヤーからリターンしたかを示す
6
+ # @return [Boolean]
7
+ attr_accessor :return_from_nested_layer
8
+ # 現在のレイヤー
9
+ # @return [Layer]
10
+ attr_accessor :cur_layer
11
+ # レイヤーの階層数
12
+ # @return [Integer]
13
+ attr_accessor :size
14
+
15
+ #
16
+ # 初期化
17
+ #
18
+ # @param mes [Messagex] Messagexクラスのインスタンス
19
+ # @param output [IO] 出力先
5
20
  def initialize(mes, output)
6
21
  @mes = mes
7
22
  @output = output
8
- @return_from_nested_env = false
23
+ @return_from_nested_layer = false
9
24
 
10
25
  @layer_struct = Struct.new(:table, :star, :cur_state, :fname, :lineno)
11
26
  @cur_layer = nil
12
27
  @layers = []
13
28
  end
14
29
 
30
+ # @overload cur_state=(val)
31
+ # カレントレイヤーの状態を設定
32
+ # @param val [Symbol]
15
33
  def cur_state=(val)
16
34
  # raise if val.class != Symbol
17
35
  @cur_layer.cur_state = val
18
36
  end
19
37
 
38
+ # @overload cur_state
39
+ # カレントレイヤーの状態を設定
40
+ # @return [Symbol] 現在の状態
20
41
  def cur_state
21
42
  raise if @cur_layer.cur_state.class != Symbol
22
43
  @cur_layer.cur_state
23
44
  end
24
45
 
25
- def table
26
- @cur_layer.table
27
- end
28
-
46
+ # @overload table=(val)
47
+ # カレントレイヤーのtableを設定
48
+ # @param val [Table] カレントレイヤーのtable
29
49
  def table=(val)
30
50
  @cur_layer.table = val
31
51
  end
32
52
 
53
+ # @overload tablee=(val)
54
+ # カレントレイヤーのtableを取得
55
+ # @param val [Table] カレントレイヤーのtable
56
+ def table
57
+ @cur_layer.table
58
+ end
59
+
60
+ # @overload star=(val)
61
+ # カレントレイヤーのstarの存在の有無を設定
62
+ # @param val [Boolean] カレントレイヤーのstarの存在の有無 true:starが存在 false:startが存在しない
33
63
  def star=(val)
34
64
  @cur_layer.star = val
35
65
  end
36
66
 
67
+ # @overload star=(val)
68
+ # カレントレイヤーのstarの存在の有無を取得
69
+ # @return [Boolean] カレントレイヤーのstaの存在の有無 true:starが存在 false:startが存在しない
37
70
  def star
38
71
  @cur_layer.star
39
72
  end
40
73
 
74
+ #
75
+ # 新しいレイヤーの追加
76
+ #
77
+ # @param fname [String] 構文解析対象のMarkdownファイル名
78
+ # @param lineno [String] TABLE_STARTトークン出現行の行番号
79
+ # @return [Symbol] テーブル拡張向け構文解析での状態
41
80
  def add_layer(fname, lineno, state=:START)
42
81
  new_layer = @layer_struct.new(nil, nil, nil, fname, lineno)
43
82
  @layers << new_layer
@@ -52,7 +91,11 @@ module Mdextab
52
91
  @cur_layer = new_layer
53
92
  end
54
93
 
55
- def pop_prev_layer
94
+ #
95
+ # カレントレイヤーを取り出して返す
96
+ #
97
+ # @return [Layer] 取り出されたカレントレイヤー
98
+ def pop_layer
56
99
  tmp_ = @layers.pop
57
100
  @size = @layers.size
58
101
  @cur_layer = @layers.last
@@ -60,63 +103,96 @@ module Mdextab
60
103
  tmp_
61
104
  end
62
105
 
106
+ #
107
+ # 1つ前のレイヤーを返す
108
+ #
109
+ # @return [Layer,nil] 1つ前のレイヤーまたはnil
110
+ # (1つ前のレイヤーが存在しない場合)
63
111
  def peek_prev_layer
64
112
  return nil unless @layers.size > 1
65
113
 
66
114
  @layers[@layers.size - 2]
67
115
  end
68
116
 
117
+ #
118
+ # 入れ子のTABLE_STARTトークンとトークン出現行の処理
119
+ #
120
+ # @param token [Token] 読み込んだトークン
121
+ # @param lineno [Integer] トークン出現行の行番号
122
+ # @param fname [String] 構文解析対象のMarkdownファイル名
123
+ # @return [void]
69
124
  def process_nested_table_start(token, lineno, fname)
125
+ # TBODYトークンが出現する前にTABLE_STARTトークンが出現した場合、仮想的なTBODYトークンが出現したとみなす
70
126
  if table.tbody.nil?
71
127
  table.add_tbody(lineno)
72
128
  end
73
129
  @mes.output_debug("B process_nested_table_start 1 @cur_layer.table=#{@cur_layer.table.object_id} token.kind=#{token.kind} token.opt[:lineno]=#{token.opt[:lineno]} cur_state=#{@cur_layer.cur_state}")
130
+ # 新しいレイヤーを追加して、それをカレントレイヤーとし、カレントレイヤーにTableを追加する
74
131
  add_layer(fname, lineno, :OUT_OF_TABLE)
75
132
  @cur_layer.table = Table.new(token.opt[:lineno], @mes, token.opt[:attr])
76
133
  @mes.output_debug("process_nested_table_start 3 token.kind=#{token.kind} cur_state=#{@cur_layer.cur_state}")
77
134
  end
78
135
 
136
+ #
137
+ # TABLE_ENDトークンの処理
138
+ #
139
+ # @param token [Token] 読み込んだトークン
140
+ # @return [void]
79
141
  def process_table_end(token)
80
142
  prev_layer = peek_prev_layer
81
- return unless prev_layer
143
+ retrun unless prev_layer
82
144
 
83
- process_table_end_for_prev_env(token, prev_layer)
145
+ # 一つ前のレイヤーが存在すれば、入れ子のTABLE_ENDトークンとして処理する
146
+ process_table_end_for_prev_env(token)
84
147
  end
85
148
 
86
- def process_table_end_for_prev_env(token, prev_layer)
149
+ #
150
+ # 入れ子のTABLE_ENDトークンの処理
151
+ #
152
+ # @param token [Token] 読み込んだトークン
153
+ # @return [void]
154
+ # @note tokenはデバッグ出力、エラー出力に使う
155
+ def process_table_end_for_prev_env(token)
87
156
  tmp_table = @cur_layer.table
88
- pop_prev_layer
89
- @return_from_nested_env = true
157
+ pop_layer
158
+ @return_from_nested_layer = true
90
159
 
160
+ # pop_layerを呼んだ後なので、カレントレイヤーはメソッド呼び出し時より一つ前のレイヤー
91
161
  case @cur_layer.cur_state
92
162
  when :IN_TD
93
- prev_layer.table.td_append(tmp_table, prev_layer.star)
163
+ @cur_layer.table.td_append(tmp_table, @cur_layer.star)
94
164
  when :IN_TD_NO_TBODY
95
- prev_layer.table.td_append(tmp_table, prev_layer.star)
165
+ @cur_layer.table.td_append(tmp_table, @cur_layer.star)
96
166
  when :IN_TH
97
- prev_layer.table.th_append(tmp_table, prev_layer.star)
167
+ @cur_layer.table.th_append(tmp_table, @cur_layer.star)
98
168
  when :IN_TH_NO_TBODY
99
- prev_layer.table.th_append(tmp_table, prev_layer.star)
169
+ @cur_layer.table.th_append(tmp_table, @cur_layer.star)
100
170
  when :IN_TABLE
101
- if prev_layer.table.nil?
171
+ if @cur_layer.table.nil?
102
172
  @mes.output_debug("In process_nested_table_env_for_prev_env: table=nil token.kind=#{token.kind} token.opt[:lineno]=#{token.opt[:lineno]} cur_state=#{@cur_layer.cur_state}")
103
173
  raise
104
174
  end
105
- prev_layer.table.add(tmp_table)
175
+ @cur_layer.table.add(tmp_table)
106
176
  when :IN_TABLE_BODY
107
- prev_layer.table.add(tmp_table)
177
+ @cur_layer.table.add(tmp_table)
108
178
  when :START
109
179
  @mes.output_debug("In process_nested_table_env_for_prev_env: table=nil token.kind=#{token.kind} token.opt[:lineno]=#{token.opt[:lineno]} cur_state=#{@cur_layer.cur_state}")
110
180
  raise
111
181
  else
112
- v = prev_layer.cur_state || "nil"
182
+ v = @cur_layer.cur_state || "nil"
113
183
  @mes.output_fatal("E100 cur_state=#{v}")
114
- @mes.output_fatal("table=#{prev_layer.table}")
184
+ @mes.output_fatal("table=#{@cur_layer.table}")
115
185
  @mes.output_fatal("IllegalState(#{@cur_layer.cur_state} in process_table_end(#{token})")
116
186
  exit(@mes.ec("EXIT_CODE_TABLE_END"))
117
187
  end
118
188
  end
119
189
 
190
+ #
191
+ # 全レイヤーの状態検査
192
+ #
193
+ # @param fname [String] 構文解析対象のMarkdownファイル名
194
+ # @return [void]
195
+ # @note fnameはデバッグ出力、エラー出力に使う
120
196
  def check_layers(fname)
121
197
  case @cur_layer.cur_state
122
198
  when :OUT_OF_TABLE
@@ -146,12 +222,5 @@ module Mdextab
146
222
  exit(@mes.ec("EXIT_CODE_ILLEAG<AL_STATE"))
147
223
  end
148
224
  end
149
-
150
- def debug(nth, token)
151
- @mes.output_debug("***#{nth}")
152
- @layers.each_with_index {|_x, ind| @mes.output_debug("@layers[#{ind}]=#{@layers[ind]}") }
153
- @mes.output_debug("******#{nth}")
154
- @mes.output_debug("Layer#debug 1 token.kind=#{token.kind} @layer.cur_state=#{@cur_layer.cur_state}")
155
- end
156
225
  end
157
226
  end
@@ -3,27 +3,31 @@ module Mdextab
3
3
  require "pp"
4
4
  require "filex"
5
5
 
6
+ #
7
+ # テーブル拡張Markdown生成クラス
6
8
  class Makemdtab
9
+ #
10
+ # 初期化
11
+ #
12
+ # @param opt [Hash] オプション
13
+ # @option opt [Symbol] :debug Messagexクラスのインスタンスに与えるデバッグモード
14
+ # @param eruby_variable_str [String] 2回の置き換えが必要なeRubyスクリプト
15
+ # @param eruby_static_str [String] 1回の置き換えが必要なeRubyスクリプト
16
+ # @param obj_by_yaml [Hash] eRubyスクリプト向け置換用ハッシュ
17
+ # @param mes [Messagex] Messagexクラスのインスタンス
7
18
  def initialize(opts, eruby_variable_str, eruby_static_str, obj_by_yaml, mes=nil)
8
- @yamlfiles = {}
9
- @str_yamlfiles = {}
10
- @str_mdfiles = {}
11
- @str_erubyfiles = {}
12
- @dataop = opts["dataop"]
13
- @datayamlfname = opts["data"]
19
+ @dataop = opts[:dataop]
20
+ @datayamlfname = opts[:data]
14
21
  @eruby_variable_str = eruby_variable_str
15
22
  @eruby_static_str = eruby_static_str
16
- @outputfname = opts["output"]
23
+ @outputfname = opts[:output]
17
24
  @obj_by_yaml = obj_by_yaml
18
25
 
19
- @exit_cannot_find_file = 1
20
- @exit_cannot_write_file = 2
21
-
22
26
  @mes = mes
23
27
  unless @mes
24
- if opts["debug"]
28
+ if opts[:debug]
25
29
  @mes = Messagex::Messagex.new("EXIT_CODE_NORMAL_EXIT", 0, :debug)
26
- elsif opts["verbose"]
30
+ elsif opts[:verbose]
27
31
  @mes = Messagex::Messagex.new("EXIT_CODE_NORMAL_EXIT", 0, :verbose)
28
32
  else
29
33
  @mes = Messagex::Messagex.new("EXIT_CODE_NORMAL_EXIT", 0)
@@ -35,11 +39,22 @@ module Mdextab
35
39
  @output = @mes.exc_file_write(@outputfname) { File.open(@outputfname, "w") }
36
40
  end
37
41
 
42
+ #
43
+ # ファイルから生成(使われていない?)
44
+ #
45
+ # @param opt [Hash] オプション
46
+ # @option opt [String] :debug Messagexクラスのインスタンスに与えるデバッグモード
47
+ # @option opt [IO] :output 出力先IO
48
+ # @param fname_variable_str [String] 2回の置き換えが必要なeRubyスクリプトファイル名
49
+ # @param fname_static_str [String] 1回の置き換えが必要なeRubyスクリプトファイル名
50
+ # @param root_settingfile [String] eRubyスクリプト向け置換用YAML形式ファイル名
51
+ # @param mes [Messagex] Messagexクラスのインスタンス
52
+ # @retrun [Makemdtab]
38
53
  def self.create(opts, fname_variable, fname_static, root_settingfile, mes)
39
54
  Filex::Filex.setup(mes)
40
55
 
41
- unless File.exist?(opts["output"])
42
- mes.output_fatal("Can't find #{opts['output']}")
56
+ unless File.exist?(opts[:output])
57
+ mes.output_fatal("Can't find #{opts[:output]}")
43
58
  exit(mes.ec("EXIT_CODE_CANNOT_FIND_FILE"))
44
59
  end
45
60
  obj_by_yaml = Filex::Filex.check_and_load_yamlfile(root_settingfile, mes)
@@ -50,10 +65,19 @@ module Mdextab
50
65
  Makemdtab.new(opts, str_variable, str_static, obj_by_yaml, mes)
51
66
  end
52
67
 
68
+ #
69
+ # YAML形式ファイルからテーブル拡張Markdown形式ファイルを生成
70
+ #
71
+ # @param root_dir [String] ルートディレクト(templatefileが示す相対パスの起点)
72
+ # @param templatefile [String,nil] テーブル拡張Makrdown形式の変換元YAML形式ファイルへの相対パス
73
+ # @param auxhs [Hash] eRubyスクリプト向け置換用ハッシュ(@obj_by_yamlにマージする)
74
+ # @retrun [void]
53
75
  def make_md2(root_dir, templatefile=nil, auxhs={})
76
+ # 補助的な置換用ハッシュを@obj_by_yamlにマージする
54
77
  objx = @obj_by_yaml.merge(auxhs)
55
78
  case @dataop
56
79
  when :FILE_INCLUDE
80
+ # ハッシュobjxは、メソッドfileReadの実引数を、読み込むべきファイルの相対パスに変換する定義を含んでいる
57
81
  array = load_file_include(root_dir, @datayamlfname, objx)
58
82
  when :YAML_TO_MD
59
83
  unless templatefile
@@ -64,7 +88,7 @@ module Mdextab
64
88
  @mes.output_fatal("Not specified templatefile")
65
89
  exit(@mes.ec("EXIT_CODE_NOT_SPECIFIED_FILE"))
66
90
  end
67
-
91
+ # YAMLファイルを、eRubyスクリプトであるtemplatefileを用いてテーブル拡張Markdown形式に変換する
68
92
  array = load_yaml_to_md(@datayamlfname, templatefile, objx)
69
93
  else
70
94
  array = []
@@ -72,45 +96,78 @@ module Mdextab
72
96
  array.map {|x| @mes.exc_file_write(@outputfname) { @output.puts(x) } }
73
97
  end
74
98
 
75
- def load_file_include(root_dir, datayamlfname, objx)
76
- mdfname = datayamlfname
99
+ #
100
+ # eRubyスクリプト取り込み処理
101
+ #
102
+ # @param root_dir [String] ルートディレクト(eruby_fnameが示す相対パスの起点)
103
+ # @param eruby_fname [String] fileReadメソッド呼び出しを含むeRubyスクリプトファイル名
104
+ # @param objx [Hash] eRubyスクリプト向け置換用ハッシュ
105
+ # @retrun [Array<String>] 指定ファイルを取り込んで展開した結果の文字列の配列(ただし要素は1個のみ)
106
+ def load_file_include(root_dir, eruby_fname, objx)
107
+ # eruby_fnameはfileReadメソッド呼び出しを含むeRubyスクリプトファイル
108
+ # fileReadメソッドは、引数を読み込むべきファイルへのパスに変換して、ファイルを読み込む
109
+
110
+ # fileReadメソッドで参照するparentDirという変数に、root_dirの値を割り当てる
77
111
  objy = { "parentDir" => "%q!" + root_dir + "!" }
112
+ # @eruby_variable_strにfileReadメソッドの定義が含まれる
78
113
  eruby_exanpded_str = ""
79
114
  if @eruby_variable_str
80
115
  if @eruby_variable_str.empty?
81
116
  eruby_exanpded_str = ""
82
117
  else
118
+ # 変数parent_dirをobjyで定義された値に置換て、fileReadメソッドの定義を完成させる
119
+ # 置換して得られた文字列を、もう一度eRubyスクリプトにする
83
120
  eruby_exanpded_str = ["<% ", Filex::Filex.expand_str(@eruby_variable_str, objy, @mes), " %>"].join("\n")
84
121
  end
85
122
  end
86
- mbstr = Filex::Filex.check_and_load_file(mdfname, @mes)
123
+ # fileReadメソッド呼び出しを含むeRubyスクリプトファイルを読み込む
124
+ mbstr = Filex::Filex.check_and_load_file(eruby_fname, @mes)
125
+ # fileReadメソッド定義とそれ以外のメソッド定義と読み込んだeRubuスクリプトを連結して一つのeRubyスクリプトにする
87
126
  dx = [eruby_exanpded_str, @eruby_static_str, mbstr].join("\n")
88
127
  if dx.strip.empty?
89
- puts "empty mdfname=#{mdfname}"
128
+ puts "empty eruby_fname=#{eruby_fname}"
90
129
  else
91
- array = [Filex::Filex.expand_str(dx, objx, @mes, { "mdfname" => mdfname })]
130
+ # ハッシュobjxは、メソッドfileReadの実引数を、読み込むべきファイルの相対パスに変換する定義を含んでいる
131
+ # Filex::Filex.expand_strに渡すハッシュは、エラーメッセージに用いるためのものであり、eRubyスクリプトとは無関係である
132
+ array = [Filex::Filex.expand_str(dx, objx, @mes, { "eruby_fname" => eruby_fname })]
92
133
  end
93
134
 
94
135
  array
95
136
  end
96
137
 
138
+ #
139
+ # eRubyスクリプトファイルでもあるYAML形式ファイルからテーブル拡張Markdown形式に変換
140
+ #
141
+ # @param datayamlfname [String] eRubyスクリプトファイルでもあるYAML形式ファイル
142
+ # @param templatefile [String] YAML形式をテーブル拡張Markdwon形式に変換するeRubyスクリプトファイル
143
+ # @param objx [Hash] eRubyスクリプト向け置換用ハッシュ
144
+ # @retrun [Array<String>] 変換されたテーブル拡張Markdwon形式の文字列の配列(ただし要素は1個のみ)
97
145
  def load_yaml_to_md(datayamlfname, templatefile, objx)
98
146
  @mes.output_debug("datayamlfname=#{datayamlfname}")
99
147
  @mes.output_debug("objx=#{objx}")
100
148
 
149
+ # いったんeRubyスクリプトファイルとして読み込んで置換したあと、YAML形式として再度読み込み、Rubyのハッシュに変換する
101
150
  objy = Filex::Filex.check_and_expand_yamlfile(datayamlfname, objx, @mes)
102
151
  @mes.output_debug("objy=#{objy}")
103
152
  @mes.output_debug("templatefile=#{templatefile}")
104
153
 
154
+ # YAML形式をテーブル拡張Markdwon形式に変換するeRubyスクリプトファイルを読み込む
105
155
  erubystr = Filex::Filex.check_and_load_file(templatefile, @mes)
106
156
  @mes.output_debug("erubystr=#{erubystr}")
157
+ # メソッド定義を含むeRubyスクリプトとtemplatefileを一つのeRubyスクリプトにする
107
158
  dx = [@eruby_static_str, erubystr].join("\n")
108
159
  @mes.output_debug("dx=#{dx}")
160
+ # eRubyスクリプトにdatayamlfnameの内容を置換用ハッシュとして適用して、テーブル拡張Markdown形式に変換する
161
+ # Filex::Filex.expand_strに渡すハッシュは、エラーメッセージに用いるためのものであり、eRubyスクリプトとは無関係である
109
162
  array = [Filex::Filex.expand_str(dx, objy, @mes, { "datayamlfname" => datayamlfname, "templatefile" => templatefile })]
110
163
 
111
164
  array
112
165
  end
113
166
 
167
+ #
168
+ # 終了処理
169
+ #
170
+ # @return [void]
114
171
  def post_process
115
172
  @mes.exc_file_close(@outputfname) { @output&.close }
116
173
  @output = nil
data/lib/mdextab/table.rb CHANGED
@@ -1,11 +1,38 @@
1
1
  require "forwardable"
2
2
 
3
3
  module Mdextab
4
+ #
5
+ # Tableクラス
6
+ #
4
7
  class Table
5
8
  extend Forwardable
9
+
10
+ # @!method add_thお
11
+ # @see Tbody#add_th
12
+ # @!method add_td
13
+ # @see Tbody#add_td
14
+ # @!method td_append
15
+ # @see Tbody#td_append
16
+ # @!method th_append
17
+ # @see Tbody#th_append
18
+ # @!method add
19
+ # @see Tbody#add
20
+ def_delegators :@tbody, :add_th, :add_td, :td_append, :th_append, :add
21
+
6
22
  def_delegators :@tbody, :add_th, :add_td, :td_append, :th_append, :add
7
- attr_reader :lineno, :tbody
8
23
 
24
+ # @return 入力Markdownファイル中のTABLEトークン出現行
25
+ attr_reader :lineno
26
+
27
+ # @return TABLE中のTBODYトークン出現行
28
+ attr_reader :tbody
29
+
30
+ #
31
+ # 初期化
32
+ #
33
+ # @param lineno [Integer] TABLE_STARTトークンの出現行の行番号
34
+ # @param mes [Messagex] Messagexクラスのインスタンス
35
+ # @param sttr [String] TABLE_STARTトークンの属性
9
36
  def initialize(lineno, mes, attr=nil)
10
37
  @lineno = lineno
11
38
  @attr = attr
@@ -13,22 +40,36 @@ module Mdextab
13
40
  @mes = mes
14
41
  end
15
42
 
43
+ #
44
+ # tbodyの追加
45
+ #
46
+ # @param lineno [Integer] TBODY_STARTトークンまたは暗黙のtbodyの出現に係るトークンの出現行の行番号
47
+ # @return [void]
16
48
  def add_tbody(lineno)
17
49
  @tbody = Tbody.new(lineno, @mes)
18
50
  end
19
51
 
52
+ #
53
+ # tbodyの終了処理
54
+ #
55
+ # @return [void]
20
56
  def tbody_end
21
- @tbody.end
22
- end
23
-
24
- def end
25
- table_end
57
+ @tbody.finish
26
58
  end
27
59
 
60
+ #
61
+ # tableの終了処理
62
+ #
63
+ # @return (see #to_s)
28
64
  def table_end
29
65
  to_s
30
66
  end
31
67
 
68
+ #
69
+ # tableの文字列化
70
+ #
71
+ # @param debug [Symbol] デバッグ用フラグ true: デバッグ情報を付加する false: デバッグ情報を付加しない
72
+ # @return [String] HTMLのTABLEタグとして文字列化したもの
32
73
  def to_s(debug=false)
33
74
  if @attr
34
75
  if debug
data/lib/mdextab/tbody.rb CHANGED
@@ -1,7 +1,25 @@
1
1
  module Mdextab
2
+ #
3
+ # TBODYトークン対応クラス
2
4
  class Tbody
5
+ extend Forwardable
6
+
7
+ # @return [Integer] TBODYトークン出現行の行番号
3
8
  attr_reader :lineno
4
9
 
10
+ # @!method td_append
11
+ # @see Td#add
12
+ def_delegator :@td, :add, :td_append
13
+
14
+ # @!method th_append
15
+ # @see Th#add
16
+ def_delegator :@th, :add, :th_append
17
+
18
+ #
19
+ # 初期化
20
+ #
21
+ # @param fname [String] 構文解析対象のMarkdownファイル名
22
+ # @param lineno [String] TBODYトークン出現行の行番号
5
23
  def initialize(lineno, mes)
6
24
  @array = []
7
25
  @tr = nil
@@ -11,7 +29,17 @@ module Mdextab
11
29
  @mes = mes
12
30
  end
13
31
 
32
+ #
33
+ # THの追加
34
+ #
35
+ # @param lineno [String] THトークン出現行の行番号
36
+ # @param content [String] THトークンのコンテンツ
37
+ # @param nth [Integer] THトークンの出現順番
38
+ # @param attr [String] THトークンの属性
39
+ # @param condense [Boolean] 文字列化方法 true:改行を含めない false:改行を含める
40
+ # @return [void]
14
41
  def add_th(lineno, content, nth, attr, condense)
42
+ # TRトークンが出現せずにTHトークンが出現したら、仮想的なTRトークンが出現したとみなす
15
43
  if nth == 1
16
44
  @tr = Tr.new(lineno)
17
45
  @array << @tr
@@ -21,8 +49,18 @@ module Mdextab
21
49
  @tr.add(@th)
22
50
  end
23
51
 
52
+ #
53
+ # TDの追加
54
+ #
55
+ # @param lineno [String] TDトークン出現行の行番号
56
+ # @param content [String] TDトークンのコンテンツ
57
+ # @param nth [Integer] TDトークンの出現順番
58
+ # @param attr [String] TDトークンの属性
59
+ # @param condense [Boolean] 文字列化方法 true:改行を含めない false:改行を含める
60
+ # @return [void]
24
61
  def add_td(lineno, content, nth, attr, condense)
25
62
  @mes.output_debug("content=#{content}|nth=#{nth}|attr=#{attr}")
63
+ # TRトークンが出現せずにTDトークンが出現したら、仮想的なTDトークンが出現したとみなす
26
64
  if nth == 1
27
65
  @tr = Tr.new(lineno)
28
66
  @array << @tr
@@ -32,22 +70,18 @@ module Mdextab
32
70
  @tr.add(@td)
33
71
  end
34
72
 
35
- def td_append(content, condense)
36
- @td.add(content, condense)
37
- end
38
-
39
- def th_append(content, condense)
40
- @th.add(content, condense)
41
- end
42
-
43
- def add(cont)
44
- @array << cont
45
- end
46
-
47
- def end
73
+ #
74
+ # TBODYの追加終了
75
+ #
76
+ # @return [void]
77
+ def finish
48
78
  @tr = nil
49
79
  end
50
80
 
81
+ #
82
+ # tbodyの文字列化
83
+ #
84
+ # @return [String] HTMLのTBODYタグとして文字列化したもの
51
85
  def to_s
52
86
  ["<tbody>", @array.map(&:to_s), "</tbody>"].join("\n")
53
87
  end
data/lib/mdextab/td.rb CHANGED
@@ -1,31 +1,50 @@
1
- class Td
2
- def initialize(lineno, attr=nil)
3
- @lineno = lineno
4
- @attr = attr
5
- @content = ""
6
- end
1
+ module Mdextab
2
+ #
3
+ # TDトークン対応クラス
4
+ class Td
5
+ #
6
+ # 初期化
7
+ #
8
+ # @param lineno [String] TDトークン出現行の行番号
9
+ # @param attr [String] TDトークンの属性
10
+ def initialize(lineno, attr=nil)
11
+ @lineno = lineno
12
+ @attr = attr
13
+ @content = ""
14
+ end
7
15
 
8
- def add(content, condnese)
9
- if condnese
10
- if @content
11
- if @contnet.match?(/^\s*$/)
12
- @content = content.to_s
16
+ #
17
+ # TDトークンのコンテンツ追加
18
+ #
19
+ # @param content [String] TDトークンのコンテンツ
20
+ # @param condense [Boolean] 文字列化方法 true:改行を含めない false:改行を含める
21
+ # @return [void]
22
+ def add(content, condnese)
23
+ if condnese
24
+ if @content
25
+ if @contnet.match?(/^\s*$/)
26
+ @content = content.to_s
27
+ else
28
+ @content += content.to_s
29
+ end
13
30
  else
14
- @content += content.to_s
31
+ @content = content.to_s
15
32
  end
16
- else
17
- @content = content.to_s
33
+ elsif content
34
+ @content = [@content, content].join("\n")
18
35
  end
19
- elsif content
20
- @content = [@content, content].join("\n")
21
36
  end
22
- end
23
37
 
24
- def to_s
25
- if @attr.nil?
26
- %Q(<td>#{@content}</td>)
27
- else
28
- %Q(<td #{@attr}>#{@content}</td>)
38
+ #
39
+ # tdの文字列化
40
+ #
41
+ # @return [String] HTMLのTDタグとして文字列化したもの
42
+ def to_s
43
+ if @attr.nil?
44
+ %Q(<td>#{@content}</td>)
45
+ else
46
+ %Q(<td #{@attr}>#{@content}</td>)
47
+ end
29
48
  end
30
49
  end
31
50
  end
data/lib/mdextab/th.rb CHANGED
@@ -1,11 +1,24 @@
1
1
  module Mdextab
2
+ #
3
+ # THトークン対応クラス
2
4
  class Th
5
+ #
6
+ # 初期化
7
+ #
8
+ # @param lineno [String] THトークン出現行の行番号
9
+ # @param attr [String] THトークンの属性
3
10
  def initialize(lineno, attr=nil)
4
11
  @lineno = lineno
5
12
  @attr = attr
6
13
  @content = ""
7
14
  end
8
15
 
16
+ #
17
+ # THトークンのコンテンツ追加
18
+ #
19
+ # @param content [String] THトークンのコンテンツ
20
+ # @param condense [Boolean] 文字列化方法 true:改行を含めない false:改行を含める
21
+ # @return [void]
9
22
  def add(content, condense)
10
23
  if condense
11
24
  if @content
@@ -22,6 +35,10 @@ module Mdextab
22
35
  end
23
36
  end
24
37
 
38
+ #
39
+ # thの文字列化
40
+ #
41
+ # @return [String] HTMLのTHタグとして文字列化したもの
25
42
  def to_s
26
43
  if @attr.nil?
27
44
  %Q(<th>#{@content}</th>)
data/lib/mdextab/token.rb CHANGED
@@ -1,17 +1,44 @@
1
1
  module Mdextab
2
+ #
3
+ # Tokenクラス
2
4
  class Token
3
- attr_reader :kind, :opt
5
+ # @return [Symbol] トークンの種類
6
+ attr_reader :kind
7
+ # @return [Hash] トークンのオプション
8
+ attr_reader :opt
4
9
 
10
+ #
11
+ # 初期化
12
+ #
13
+ # @param mes [Messagex] Messagexクラスのインスタンス
5
14
  def initialize(mes)
6
15
  @mes = mes
7
16
  @token_struct = Struct.new(:kind, :opt)
8
17
  end
9
18
 
19
+ #
20
+ # トークンの生成
21
+ #
22
+ # @param kind [Symbol] 生成するトークンの種類
23
+ # @param opt [Hash] 生成するトークンのオプション設定
24
+ # @option opt [String] :content トークンの内容
25
+ # @option opt [Integer] :lineno トークン出現行の行番号
26
+ # @option opt [Integer] :nth ":"の並び文字列長
27
+ # @option opt [String,nil] :attr トークンの属性またはnil(属性が存在しない場合)
28
+ # @option opt [Integer] :lineno トークン出現行の行番号
29
+ # @return [Struct] 生成されたトークン
10
30
  def create_token(kind, opt={})
11
31
  @token_struct.new(kind, opt)
12
32
  end
13
33
 
14
- def get_token_start_table(line, lineno)
34
+ #
35
+ # TABLE_STARTトークンの取得
36
+ #
37
+ # @param line [String] 現在行
38
+ # @param lineno [Integer] 現在行の行番号
39
+ # @return [Struct,nil] 生成されたトークンまたはnil(トークンが存在しない場合)
40
+ # @note TABLE_STARTトークンが存在するかもしれないと判断されたときに呼ばれる
41
+ def get_token_table_start(line, lineno)
15
42
  if /^\s*<table>\s*$/.match?(line)
16
43
  ret = create_token(:TABLE_START, { lineno: lineno })
17
44
  elsif (m = /^\s*<table\s+(.+)>\s*$/.match(line))
@@ -22,7 +49,14 @@ module Mdextab
22
49
  ret
23
50
  end
24
51
 
25
- def get_token_start_tbody(line, lineno)
52
+ #
53
+ # TBODY_STARTトークンの取得
54
+ #
55
+ # @param line [String] 現在行
56
+ # @param lineno [Integer] 現在行の行番号
57
+ # @return [Struct,nil] 生成されたトークンまたはnil(トークンが存在しない場合)
58
+ # @note TBODY_STARTトークンが存在するかもしれないと判断されたときに呼ばれる
59
+ def get_token_tbody_start(line, lineno)
26
60
  if /^\s*<tbody>\s*$/.match?(line)
27
61
  ret = create_token(:TBODY_START, { lineno: lineno })
28
62
  else
@@ -31,7 +65,16 @@ module Mdextab
31
65
  ret
32
66
  end
33
67
 
34
- def get_token_start_colon(line, lineno, nth, cont)
68
+ #
69
+ # 先頭が:で始まる場合の適切なトークンの取得
70
+ #
71
+ # @param line [String] 現在行
72
+ # @param lineno [Integer] 現在行の行番号
73
+ # @param nth [Integer] 並んでいる:の個数
74
+ # @param cont [String] 現在行の中の:の並びを区切り文字列とした場合の右側の部分
75
+ # @return [Struct,nil] 生成されたトークンまたはnil(トークンが存在しない場合)
76
+ # @note 先頭が:のときに呼ばれる
77
+ def get_token_colon_start(line, lineno, nth, cont)
35
78
  if (m = /^th(.*)/.match(cont))
36
79
  cont2 = m[1]
37
80
  if (m2 = /^\s(.*)/.match(cont2))
@@ -61,7 +104,14 @@ module Mdextab
61
104
  ret
62
105
  end
63
106
 
64
- def get_token_end_table(line, lineno)
107
+ #
108
+ # TABLE_ENDトークンの取得
109
+ #
110
+ # @param line [String] 現在行
111
+ # @param lineno [Integer] 現在行の行番号
112
+ # @return [Struct,nil] 生成されたトークンまたはnil(トークンが存在しない場合)
113
+ # @note TABLE_ENDトークンが存在するかもしれないと判断されたときに呼ばれる
114
+ def get_token_table_end(line, lineno)
65
115
  if %r{^\s*</table>\s*$}.match?(line)
66
116
  ret = create_token(:TABLE_END, { lineno: lineno })
67
117
  else
@@ -70,6 +120,12 @@ module Mdextab
70
120
  ret
71
121
  end
72
122
 
123
+ #
124
+ # トークンの取得
125
+ #
126
+ # @param line [String] 現在行
127
+ # @param lineno [Integer] 現在行の行番号
128
+ # @return [Struct,nil] 生成されたトークンまたはnil(トークンが存在しない場合)
73
129
  def get_token(line, lineno)
74
130
  case line
75
131
  when /^\*S(.+)$/
@@ -79,13 +135,13 @@ module Mdextab
79
135
  content = Regexp.last_match(1)
80
136
  ret = create_token(:STAR_END, { content: content, lineno: lineno })
81
137
  when /^\s*<table/
82
- ret = get_token_start_table(line, lineno)
138
+ ret = get_token_table_start(line, lineno)
83
139
  when /^\s*<tbody/
84
- ret = get_token_start_tbody(line, lineno)
140
+ ret = get_token_tbody_start(line, lineno)
85
141
  when /^\s*(\:+)(.*)$/
86
142
  nth = Regexp.last_match(1).size
87
143
  cont = Regexp.last_match(2)
88
- ret = get_token_start_colon(line, lineno, nth, cont)
144
+ ret = get_token_colon_start(line, lineno, nth, cont)
89
145
  when %r{^\s*</table}
90
146
  ret = get_token_end_table(line, lineno)
91
147
  when %r{^\s*</tbody}
data/lib/mdextab/tr.rb CHANGED
@@ -1,14 +1,29 @@
1
1
  module Mdextab
2
+ #
3
+ # TRトークン対応クラス
2
4
  class Tr
5
+ #
6
+ # 初期化
7
+ #
8
+ # @param lineno [String] TRトークン出現行の行番号
3
9
  def initialize(lineno)
4
10
  @lineno = lineno
5
11
  @array = []
6
12
  end
7
13
 
14
+ #
15
+ # TRトークンのコンテンツ追加
16
+ #
17
+ # @param content [String] TRトークンのコンテンツ
18
+ # @return [void]
8
19
  def add(cont)
9
20
  @array << cont
10
21
  end
11
22
 
23
+ #
24
+ # trの文字列化
25
+ #
26
+ # @return [String] HTMLのTRタグとして文字列化したもの
12
27
  def to_s
13
28
  ["<tr>", @array.map(&:to_s), "</tr>"].join("\n")
14
29
  end
@@ -1,3 +1,4 @@
1
1
  module Mdextab
2
- VERSION = "0.1.5"
2
+ # バージョン番号
3
+ VERSION = "0.1.6"
3
4
  end
data/lib/mdextab.rb CHANGED
@@ -8,7 +8,7 @@ module Mdextab
8
8
  class Error < StandardError; end
9
9
 
10
10
  #
11
- # MarkDownテーブル拡張モジュールクラス
11
+ # MarkDownテーブル拡張クラス
12
12
  #
13
13
  class Mdextab
14
14
  require "mdextab/version"
@@ -28,26 +28,26 @@ module Mdextab
28
28
 
29
29
  #
30
30
  # 初期化
31
- # @param [Hash] オプション
32
- # @param [String] 入力Markdownファイル名
33
- # @param [String] 出力Markdownファイル名
34
- # @param [Messagex] mes Messagexクラスのインスタンス
31
+ #
32
+ # @param opt [Hash] オプション
33
+ # @option opt [Symbol] :debug Messagexクラスのインスタンスに与えるデバッグモード
34
+ # @param fname [String] 入力Markdownファイル名
35
+ # @param o_fname [String] 出力Markdownファイル名
36
+ # @param mes [Messagex] Messagexクラスのインスタンス
35
37
  def initialize(opt, fname, o_fname, mes=nil)
36
38
  @fname = fname
37
39
  @o_fname = o_fname
38
40
 
39
41
  @mes = mes
40
42
  unless @mes
41
- @mes = Messagex::Messagex.new("EXIT_CODE_NORMAL_EXIT", 0, opt["debug"])
43
+ @mes = Messagex::Messagex.new("EXIT_CODE_NORMAL_EXIT", 0, opt[:debug])
42
44
  @mes.register_ecx
43
45
  end
44
46
 
45
47
  @mes.add_exitcode("EXIT_CODE_NEXT_STATE")
46
48
  @mes.add_exitcode("EXIT_CODE_NIL")
47
49
  @mes.add_exitcode("EXIT_CODE_EXCEPTION")
48
- @mes.add_exitcode("EXIT_CODE_TABLE_END")
49
50
  @mes.add_exitcode("EXIT_CODE_UNKNOWN")
50
- @mes.add_exitcode("EXIT_CODE_ILLEAGAL_STATE")
51
51
 
52
52
  Filex::Filex.setup(@mes)
53
53
 
@@ -71,6 +71,7 @@ module Mdextab
71
71
  #
72
72
  # テーブル拡張向け構文解析用状態遷移テーブルの設定
73
73
  #
74
+ # @return [void]
74
75
  def set_state
75
76
  @states = {
76
77
  START: { TABLE_START: :IN_TABLE, ELSE: :OUT_OF_TABLE, STAR_START: :START, STAR_END: :START },
@@ -86,7 +87,9 @@ module Mdextab
86
87
 
87
88
  #
88
89
  # テーブル拡張向け構文解析
89
- # @param [Hash] eRubyスクリプト向け置換用ハッシュ
90
+ #
91
+ # @param hash [Hash] eRubyスクリプト向け置換用ハッシュ
92
+ # @return [void]
90
93
  def parse(hash)
91
94
  lineno = 0
92
95
  @layer.add_layer(@fname, lineno)
@@ -103,7 +106,6 @@ module Mdextab
103
106
  else
104
107
  @mes.output_debug("(script)#{__LINE__}| @layer.cur_state=#{@layer.cur_state}")
105
108
  end
106
- # debug_envs(5, token)
107
109
 
108
110
  @layer.cur_state = process_one_line(@layer.cur_state, token, line, lineno)
109
111
  unless @layer.cur_state
@@ -119,7 +121,9 @@ module Mdextab
119
121
 
120
122
  #
121
123
  # テーブル拡張向け構文解析
122
- # @param [String] eRubyスクリプト向け置換用データファイル名(YAML形式)
124
+ #
125
+ # @param yamlfname [String] eRubyスクリプト向け置換用データファイル名(YAML形式)
126
+ # @return [void]
123
127
  def parse2(yamlfname)
124
128
  hs = Filex::Filex.check_and_load_yamlfile(yamlfname, @mes)
125
129
  parse(hs)
@@ -127,9 +131,11 @@ module Mdextab
127
131
 
128
132
  #
129
133
  # テーブル拡張向け構文解析での次の状態を得る
130
- # @param [String] token 読み込んだトークン
131
- # @param [String] line 現在行
132
- # @param [String] lineno 現在行の行番号
134
+ #
135
+ # @param token [Token] 読み込んだトークン
136
+ # @param line [String] トークン出現行
137
+ # @param lineno [String] トークン出現行の行番号
138
+ # @return [Symbol] テーブル拡張向け構文解析での次の状態
133
139
  def get_next_state(token, line, lineno)
134
140
  kind = token.kind
135
141
  @mes.output_debug("#{__LINE__}|@layer.cur_state=#{@layer.cur_state} #{@layer.cur_state.class}")
@@ -160,7 +166,9 @@ module Mdextab
160
166
 
161
167
  #
162
168
  # トークンELSEに対応する行の出力
163
- # @param [String] str トークンELSEに対応する行
169
+ #
170
+ # @param str [String] トークンELSEに対応する行
171
+ # @return [void]
164
172
  def output_in_else(str)
165
173
  if @layer.star
166
174
  if str.match?(/^\s*$/)
@@ -175,7 +183,9 @@ module Mdextab
175
183
 
176
184
  #
177
185
  # テーブルのTHタグの一部として、トークンELSEに対応する行を追加
178
- # @param [String] str トークンELSEに対応する行
186
+ #
187
+ # @param str [String] トークンELSEに対応する行
188
+ # @return [void]
179
189
  def table_th_append_in_else(str)
180
190
  if @layer.star
181
191
  if str.match?(/^\s*$/)
@@ -190,7 +200,9 @@ module Mdextab
190
200
 
191
201
  #
192
202
  # テーブルのTDタグの一部として、トークンELSEに対応する行を追加
193
- # @param [String] str トークンELSEに対応する行
203
+ #
204
+ # @param str [String] トークンELSEに対応する行
205
+ # @return [void]
194
206
  def table_td_append_in_else(str)
195
207
  if @layer.star
196
208
  if str.match?(/^\s*$/)
@@ -204,10 +216,12 @@ module Mdextab
204
216
  end
205
217
 
206
218
  #
207
- # START状態でのトークンと現在行の処理
208
- # @param [String] token 読み込んだトークン
209
- # @param [String] line 現在行
210
- # @param [String] lineno 現在行の行番号
219
+ # START状態でのトークンとトークン出現行の処理
220
+ #
221
+ # @param token [Token] 読み込んだトークン
222
+ # @param line [String] トークン出現行
223
+ # @param lineno [String] トークン出現行の行番号
224
+ # @return [void]
211
225
  def process_one_line_for_start(token, line, lineno)
212
226
  case token.kind
213
227
  when :TABLE_START
@@ -229,10 +243,12 @@ module Mdextab
229
243
  end
230
244
 
231
245
  #
232
- # OUT_OF_TABLE状態でのトークンと現在行の処理
233
- # @param [String] token 読み込んだトークン
234
- # @param [String] line 現在行
235
- # @param [String] lineno 現在行の行番号
246
+ # OUT_OF_TABLE状態でのトークンとトークン出現行の処理
247
+ #
248
+ # @param token [Token] 読み込んだトークン
249
+ # @param line [String] トークン出現行
250
+ # @param lineno [String] トークン出現行の行番号
251
+ # @return [void]
236
252
  def process_one_line_for_out_of_table(token, line, lineno)
237
253
  case token.kind
238
254
  when :TABLE_START
@@ -257,20 +273,24 @@ module Mdextab
257
273
 
258
274
  #
259
275
  # TABLE_END状態でのトークン処理
260
- # @param [String] token 読み込んだトークン
276
+ #
277
+ # @param token [Token] 読み込んだトークン
278
+ # @return [void]
261
279
  def process_one_line_for_table_end(token)
262
280
  @layer.process_table_end(token)
263
- return if @layer.return_from_nested_env
281
+ return if @layer.return_from_nested_layer
264
282
 
265
- @mes.output_debug("1 - process_one_line_table_end cur_state=#{@layer.cur_state} @return_from_nested_env~#{@layer.return_from_nested_env}")
266
- @mes.exc_file_write(@o_fname) { @output.puts(@layer.table.end) }
283
+ @mes.output_debug("1 - process_one_line_table_end cur_state=#{@layer.cur_state} @return_from_nested_layer~#{@layer.return_from_nested_layer}")
284
+ @mes.exc_file_write(@o_fname) { @output.puts(@layer.table.table_end) }
267
285
  end
268
286
 
269
287
  #
270
- # IN_TABLE状態でのトークンと現在行の処理
271
- # @param [String] token 読み込んだトークン
272
- # @param [String] line 現在行
273
- # @param [String] lineno 現在行の行番号
288
+ # IN_TABLE状態でのトークンとトークン出現行の処理
289
+ #
290
+ # @param token [Token] 読み込んだトークン
291
+ # @param line [String] トークン出現行
292
+ # @param lineno [String] トークン出現行の行番号
293
+ # @return [void]
274
294
  def process_one_line_for_in_table(token, line, lineno)
275
295
  case token.kind
276
296
  when :TBODY_START
@@ -302,10 +322,12 @@ module Mdextab
302
322
  end
303
323
 
304
324
  #
305
- # IN_TABLE_BODY状態でのトークンと現在行の処理
306
- # @param [String] token 読み込んだトークン
307
- # @param [String] line 現在行
308
- # @param [String] lineno 現在行の行番号
325
+ # IN_TABLE_BODY状態でのトークンとトークン出現行の処理
326
+ #
327
+ # @param token [Token] 読み込んだトークン
328
+ # @param line [String] トークン出現行
329
+ # @param lineno [String] トークン出現行の行番号
330
+ # @return [void]
309
331
  def process_one_line_for_in_table_body(token, line, lineno)
310
332
  case token.kind
311
333
  when :TH
@@ -316,7 +338,7 @@ module Mdextab
316
338
  when :ELSE
317
339
  output_in_else(token.opt[:content])
318
340
  when :TABLE_START
319
- @layer.process_nested_table_start(token, lineno, @fnam)
341
+ @layer.process_nested_table_start(token, lineno, @fname)
320
342
  when :TBODY_END
321
343
  true # don't call process_table_end(token)
322
344
  when :TABLE_END
@@ -335,10 +357,12 @@ module Mdextab
335
357
  end
336
358
 
337
359
  #
338
- # IN_TH状態でのトークンと現在行の処理
339
- # @param [String] token 読み込んだトークン
340
- # @param [String] line 現在行
341
- # @param [String] lineno 現在行の行番号
360
+ # IN_TH状態でのトークンとトークン出現行の処理
361
+ #
362
+ # @param token [Token] 読み込んだトークン
363
+ # @param line [String] トークン出現行
364
+ # @param lineno [String] トークン出現行の行番号
365
+ # @return [void]
342
366
  def process_one_line_for_in_th(token, line, lineno)
343
367
  case token.kind
344
368
  when :ELSE
@@ -363,10 +387,12 @@ module Mdextab
363
387
  end
364
388
 
365
389
  #
366
- # IN_TH_NO_TBODY状態でのトークンと現在行の処理
367
- # @param [String] token 読み込んだトークン
368
- # @param [String] line 現在行
369
- # @param [String] lineno 現在行の行番号
390
+ # IN_TH_NO_TBODY状態でのトークンとトークン出現行の処理
391
+ #
392
+ # @param token [Token] 読み込んだトークン
393
+ # @param line [String] トークン出現行
394
+ # @param lineno [String] トークン出現行の行番号
395
+ # @return [void]
370
396
  def process_one_line_for_in_th_no_tbody(token, line, lineno)
371
397
  case token.kind
372
398
  when :ELSE
@@ -391,10 +417,12 @@ module Mdextab
391
417
  end
392
418
 
393
419
  #
394
- # IN_TD状態でのトークンと現在行の処理
395
- # @param [String] token 読み込んだトークン
396
- # @param [String] line 現在行
397
- # @param [String] lineno 現在行の行番号
420
+ # IN_TD状態でのトークンとトークン出現行の処理
421
+ #
422
+ # @param token [Token] 読み込んだトークン
423
+ # @param line [String] トークン出現行
424
+ # @param lineno [String] トークン出現行の行番号
425
+ # @return [void]
398
426
  def process_one_line_for_in_td(token, line, lineno)
399
427
  case token.kind
400
428
  when :ELSE
@@ -421,10 +449,12 @@ module Mdextab
421
449
  end
422
450
 
423
451
  #
424
- # IN_TD_NO_TBODY状態でのトークンと現在行の処理
425
- # @param [String] token 読み込んだトークン
426
- # @param [String] line 現在行
427
- # @param [String] lineno 現在行の行番号
452
+ # IN_TD_NO_TBODY状態でのトークンとトークン出現行の処理
453
+ #
454
+ # @param token [Token] 読み込んだトークン
455
+ # @param line [String] トークン出現行
456
+ # @param lineno [String] トークン出現行の行番号
457
+ # @return [void]
428
458
  def process_one_line_for_in_td_no_tbody(token, line, lineno)
429
459
  case token.kind
430
460
  when :ELSE
@@ -453,13 +483,15 @@ module Mdextab
453
483
  end
454
484
 
455
485
  #
456
- # 現在の状態に対するトークンと現在行の処理
486
+ # 現在の状態に対するトークンとトークン出現行の処理
487
+ #
457
488
  # @param [Symbol] current_state 現在の状態
458
- # @param [String] token 読み込んだトークン
459
- # @param [String] line 現在行
460
- # @param [String] lineno 現在行の行番号
489
+ # @param [Token] token 読み込んだトークン
490
+ # @param [String] line トークン出現行
491
+ # @param [String] lineno トークン出現行の行番号
492
+ # @return [void] テーブル拡張向け構文解析での次の状態
461
493
  def process_one_line(current_state, token, line, lineno)
462
- @layer.return_from_nested_env = false
494
+ @layer.return_from_nested_layer = false
463
495
 
464
496
  case current_state
465
497
  when :START
@@ -484,7 +516,7 @@ module Mdextab
484
516
  exit(@mes.ec("EXIT_CODE_UNKNOWN"))
485
517
  end
486
518
 
487
- if @layer.return_from_nested_env
519
+ if @layer.return_from_nested_layer
488
520
  next_state = @layer.cur_state
489
521
  else
490
522
  next_state = get_next_state(token, line, lineno)
data/mdextab.gemspec CHANGED
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mdextab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - yasuo kominami
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-25 00:00:00.000000000 Z
11
+ date: 2019-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler