Class: PseudoHiki::PlainTextFormat::LinkNodeFormatter

Inherits:
PseudoHiki::PlainTextFormat show all
Defined in:
lib/pseudohiki/plaintextformat.rb

Constant Summary

Constants inherited from PseudoHiki::PlainTextFormat

DescSep, Formatters

Instance Method Summary collapse

Methods inherited from PseudoHiki::PlainTextFormat

#choose_expander_of_col_and_row, create, #create_self_element, format, #format, #format_table, #get_plain, #initialize, #push_visited_results, #split_into_parts, #visited_result

Constructor Details

This class inherits a constructor from PseudoHiki::PlainTextFormat

Instance Method Details

#get_caption(tree, memo) ⇒ Object



120
121
122
123
124
# File 'lib/pseudohiki/plaintextformat.rb', line 120

def get_caption(tree, memo)
  caption, ref_part = split_into_parts(tree, [LinkSep])
  caption = caption.map {|element| visited_result(element, memo) } if caption
  return caption, ref_part
end

#ref_tail(tree, caption) ⇒ Object



126
127
128
129
130
131
# File 'lib/pseudohiki/plaintextformat.rb', line 126

def ref_tail(tree, caption)
  tree.last.join
rescue NoMethodError
  raise NoMethodError unless tree.empty?
  STDERR.puts "No uri is specified for #{caption}"
end

#visit(tree, memo) ⇒ Object



108
109
110
111
112
113
114
115
116
117
118
# File 'lib/pseudohiki/plaintextformat.rb', line 108

def visit(tree, memo)
  element = Node.new
  caption, ref = get_caption(tree, memo)
  if IMAGE_SUFFIX_RE.match? ref_tail(ref, caption)
    element.push (caption || ref).join
  else
    element.push caption || ref.join
    element.push " (#{ref.join})" if @options.verbose_mode and caption
  end
  element
end