module MaRuKu::Helpers

Public Instance Methods

md_abbr(abbr, title) click to toggle source
# File lib/maruku/helpers.rb, line 79
def md_abbr(abbr, title)
        md_el(:abbr, [abbr], {:title=>title})
end
md_abbr_def(abbr, text, al=nil) click to toggle source
# File lib/maruku/helpers.rb, line 75
def md_abbr_def(abbr, text, al=nil)
        md_el(:abbr_def, [], {:abbr=>abbr, :text=>text}, al)
end
md_ald(id, al) click to toggle source

Attribute list definition

# File lib/maruku/helpers.rb, line 179
def md_ald(id, al)
        md_el(:ald, [], {:ald_id=>id,:ald=>al})
end
md_br() click to toggle source
# File lib/maruku/helpers.rb, line 123
def md_br()
        md_el(:linebreak, [], {}, nil)
end
md_code(code, al=nil) click to toggle source

Inline code

# File lib/maruku/helpers.rb, line 54
def md_code(code, al=nil)
        md_el(:inline_code, [], {:raw_code => code}, al)
end
md_codeblock(source, al=nil) click to toggle source

Code block

# File lib/maruku/helpers.rb, line 59
def md_codeblock(source, al=nil)
        md_el(:code, [], {:raw_code => source}, al)
end
md_el(node_type, children=[], meta={}, al=nil) click to toggle source

if the first is a #md_ial, it is used as such

# File lib/maruku/helpers.rb, line 34
def md_el(node_type, children=[], meta={}, al=nil)
        if  (e=children.first).kind_of?(MDElement) and 
                e.node_type == :ial then
                if al
                        al += e.ial
                else
                        al = e.ial
                end
                children.shift
        end 
        e = MDElement.new(node_type, children, meta, al)
        e.doc = @doc
        return e
end
md_em(children, al=nil) click to toggle source
# File lib/maruku/helpers.rb, line 119
def md_em(children, al=nil)
        md_el(:emphasis, [children].flatten, {}, al)
end
md_email(email, al=nil) click to toggle source

<andrea@rubyforge.org> <andrea@rubyforge.org>

# File lib/maruku/helpers.rb, line 146
def md_email(email, al=nil)
        md_el(:email_address, [], {:email=>email}, al)
end
md_emstrong(children, al=nil) click to toggle source
# File lib/maruku/helpers.rb, line 135
def md_emstrong(children, al=nil)
        md_strong(md_em(children), al)
end
md_entity(entity_name, al=nil) click to toggle source
# File lib/maruku/helpers.rb, line 150
def md_entity(entity_name, al=nil)
        md_el(:entity, [], {:entity_name=>entity_name}, al)
end
md_foot_ref(ref_id, al=nil) click to toggle source

Markdown extra

# File lib/maruku/helpers.rb, line 155
def md_foot_ref(ref_id, al=nil)
        md_el(:footnote_reference, [], {:footnote_id=>ref_id}, al)
end
md_footnote(footnote_id, children, al=nil) click to toggle source
# File lib/maruku/helpers.rb, line 71
def md_footnote(footnote_id, children, al=nil)
        md_el(:footnote, children, {:footnote_id=>footnote_id}, al)
end
md_header(level, children, al=nil) click to toggle source
# File lib/maruku/helpers.rb, line 49
def md_header(level, children, al=nil)
        md_el(:header, children, {:level => level}, al)
end
md_hrule() click to toggle source
# File lib/maruku/helpers.rb, line 127
def md_hrule()
        md_el(:hrule, [], {}, nil)
end
md_html(raw_html, al=nil) click to toggle source
# File lib/maruku/helpers.rb, line 83
        def md_html(raw_html, al=nil)
                e = md_el(:raw_html, [], {:raw_html=>raw_html})
                begin
                        # remove newlines and whitespace at begin
                        # end end of string, or else REXML gets confused
                        raw_html = raw_html.gsub(/\A\s*</,'<').
                                            gsub(/>[\s\n]*\Z/,'>')
                        
                        raw_html = "<marukuwrap>#{raw_html}</marukuwrap>"
                        e.instance_variable_set :@parsed_html,
                             REXML::Document.new(raw_html)
                rescue        REXML::ParseException => ex
                        e.instance_variable_set :@parsed_html, nil
                        maruku_recover "REXML cannot parse this block of HTML/XML:\n"+
                        add_tabs(raw_html,1,'|') + "\n"+ex.inspect
#                       "  #{raw_html.inspect}\n\n"+ex.inspect
                end
                e
        end
md_ial(al) click to toggle source

inline attribute list

# File lib/maruku/helpers.rb, line 172
def md_ial(al)
        al = Maruku::AttributeList.new(al) if 
                not al.kind_of?Maruku::AttributeList
        md_el(:ial, [], {:ial=>al})
end
md_im_image(children, url, title=nil, al=nil) click to toggle source
# File lib/maruku/helpers.rb, line 115
def md_im_image(children, url, title=nil, al=nil)
        md_el(:im_image, children, {:url=>url,:title=>title},al)
end
md_image(children, ref_id, al=nil) click to toggle source
# File lib/maruku/helpers.rb, line 111
def md_image(children, ref_id, al=nil)
        md_el(:image, children, {:ref_id=>ref_id}, al)
end
md_li(children, want_my_par, al=nil) click to toggle source
# File lib/maruku/helpers.rb, line 67
def md_li(children, want_my_par, al=nil)
        md_el(:li, children, {:want_my_paragraph=>want_my_par}, al)
end
md_par(children, al=nil) click to toggle source
# File lib/maruku/helpers.rb, line 159
def md_par(children, al=nil)
        md_el(:paragraph, children, meta={}, al)
end
md_quote(children, al=nil) click to toggle source
# File lib/maruku/helpers.rb, line 63
def md_quote(children, al=nil)
        md_el(:quote, children, {}, al)
end
md_ref_def(ref_id, url, title=nil, meta={}, al=nil) click to toggle source
1]: url [properties
# File lib/maruku/helpers.rb, line 164
def md_ref_def(ref_id, url, title=nil, meta={}, al=nil)
        meta[:url] = url
        meta[:ref_id] = ref_id
        meta[:title] = title if title
        md_el(:ref_definition, [], meta, al)
end
md_strong(children, al=nil) click to toggle source
# File lib/maruku/helpers.rb, line 131
def md_strong(children, al=nil)
        md_el(:strong, [children].flatten, {}, al)
end
md_url(url, al=nil) click to toggle source

<www.example.com/>

# File lib/maruku/helpers.rb, line 140
def md_url(url, al=nil)
        md_el(:immediate_link, [], {:url=>url}, al)
end
md_xml_instr(target, code) click to toggle source

Server directive <?target code… ?>

# File lib/maruku/helpers.rb, line 184
def md_xml_instr(target, code)
        md_el(:xml_instr, [], {:target=>target, :code=>code})
end