class Markie::Generator
Public Class Methods
generate(ast)
click to toggle source
# File lib/markie/generator.rb, line 4 def generate(ast) body(ast) end
Private Class Methods
body(node)
click to toggle source
# File lib/markie/generator.rb, line 10 def body(node) content = node.children.map { |child| paragraph(child) }.join("") "<body>#{content}</body>" end
emphasis(node)
click to toggle source
# File lib/markie/generator.rb, line 40 def emphasis(node) "<em>#{node.value}</em>" end
link(node)
click to toggle source
# File lib/markie/generator.rb, line 36 def link(node) "<a href=\"#{node.value}\">#{text(node.children[0])}</a>" end
paragraph(node)
click to toggle source
# File lib/markie/generator.rb, line 18 def paragraph(node) content = node.children.map { |child| if child.type == :text text(child) elsif child.type == :link link(child) elsif child.type == :emphasis emphasis(child) end }.join("") "<p>#{content}</p>" end
text(node)
click to toggle source
# File lib/markie/generator.rb, line 32 def text(node) node.value end