class PseudoHiki::MarkDownFormat::LinkNodeFormatter
Attributes
id_conv_table[W]
Public Instance Methods
format_link(tree)
click to toggle source
# File lib/pseudohiki/markdownformat.rb, line 192 def format_link(tree) link = tree.join return link unless @id_conv_table if /\A#/o.match? link and gfm_link = @id_conv_table[link[1..-1]] "#".concat gfm_link else link end end
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