class Mdextab::Tbody

TBODYトークン対応クラス

Attributes

lineno[R]

@return [Integer] TBODYトークン出現行の行番号

Public Class Methods

new(lineno, mes) click to toggle source

初期化

@param fname [String] 構文解析対象のMarkdownファイル名 @param lineno [String] TBODYトークン出現行の行番号

# File lib/mdextab/tbody.rb, line 23
def initialize(lineno, mes)
  @array = []
  @tr = nil
  @th = nil
  @td = nil
  @lineno = lineno
  @mes = mes
end

Public Instance Methods

add_td(lineno, content, nth, attr, condense) click to toggle source

TDの追加

@param lineno [String] TDトークン出現行の行番号 @param content [String] TDトークンのコンテンツ @param nth [Integer] TDトークンの出現順番 @param attr [String] TDトークンの属性 @param condense [Boolean] 文字列化方法 true:改行を含めない false:改行を含める @return [void]

# File lib/mdextab/tbody.rb, line 61
def add_td(lineno, content, nth, attr, condense)
  @mes.output_debug("content=#{content}|nth=#{nth}|attr=#{attr}")
  # TRトークンが出現せずにTDトークンが出現したら、仮想的なTDトークンが出現したとみなす
  if nth == 1
    @tr = Tr.new(lineno)
    @array << @tr
  end
  @td = Td.new(lineno, attr)
  @td.add(content, condense)
  @tr.add(@td)
end
add_th(lineno, content, nth, attr, condense) click to toggle source

THの追加

@param lineno [String] THトークン出現行の行番号 @param content [String] THトークンのコンテンツ @param nth [Integer] THトークンの出現順番 @param attr [String] THトークンの属性 @param condense [Boolean] 文字列化方法 true:改行を含めない false:改行を含める @return [void]

# File lib/mdextab/tbody.rb, line 41
def add_th(lineno, content, nth, attr, condense)
  # TRトークンが出現せずにTHトークンが出現したら、仮想的なTRトークンが出現したとみなす
  if nth == 1
    @tr = Tr.new(lineno)
    @array << @tr
  end
  @th = Th.new(lineno, attr)
  @th.add(content, condense)
  @tr.add(@th)
end
finish() click to toggle source

TBODYの追加終了

@return [void]

# File lib/mdextab/tbody.rb, line 77
def finish
  @tr = nil
end
to_s() click to toggle source

tbodyの文字列化

@return [String] HTMLのTBODYタグとして文字列化したもの

# File lib/mdextab/tbody.rb, line 85
def to_s
  ["<tbody>", @array.map(&:to_s), "</tbody>"].join("\n")
end