class PseudoHiki::MarkDownFormat::LinkNodeFormatter

Attributes

id_conv_table[W]

Public Instance Methods

get_caption(tree, memo) click to toggle source
# File lib/pseudohiki/markdownformat.rb, line 184
def get_caption(tree, memo)
  link_sep_index = tree.find_index([LinkSep])
  return nil unless link_sep_index
  caption_part = tree.shift(link_sep_index)
  tree.shift
  caption_part.map {|element| visited_result(element, memo) }
end
ref_tail(tree, caption) click to toggle source
# File lib/pseudohiki/markdownformat.rb, line 202
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) click to toggle source
# File lib/pseudohiki/markdownformat.rb, line 171
def visit(tree, memo)
  not_from_thumbnail = tree.first.class != LinkNode
  tree = tree.dup
  element = create_self_element
  caption = get_caption(tree, memo)
  if IMAGE_SUFFIX_RE.match? ref_tail(tree, caption) and not_from_thumbnail
    element.push "!"
  end
  link = format_link(tree)
  element.push "[#{(caption || tree).join}](#{link})"
  element
end