Module: MaRuKu::Helpers

### Home Classes Methods

### In Files

- lib/maruku.rb
- lib/maruku/helpers.rb

### Methods

- #md_abbr
- #md_abbr_def
- #md_ald
- #md_br
- #md_code
- #md_codeblock
- #md_el
- #md_em
- #md_email
- #md_emstrong
- #md_entity
- #md_foot_ref
- #md_footnote
- #md_header
- #md_hrule
- #md_html
- #md_ial
- #md_im_image
- #md_im_link
- #md_image
- #md_li
- #md_link
- #md_par
- #md_quote
- #md_ref_def
- #md_strong
- #md_url
- #md_xml_instr

### Class/Module Index

Quicksearch

- MaRuKu
- MaRuKu::AttributeList
- MaRuKu::Errors
- MaRuKu::Exception
- MaRuKu::HTMLElement
- MaRuKu::HTMLFragment
- MaRuKu::Helpers
- MaRuKu::In
- MaRuKu::In::Markdown
- MaRuKu::In::Markdown::BlockLevelParser
- MaRuKu::In::Markdown::BlockLevelParser::BlockContext
- MaRuKu::In::Markdown::BlockLevelParser::LineSource
- MaRuKu::In::Markdown::SpanExtension
- MaRuKu::In::Markdown::SpanLevelParser
- MaRuKu::In::Markdown::SpanLevelParser::CharSourceDebug
- MaRuKu::In::Markdown::SpanLevelParser::CharSourceManual
- MaRuKu::In::Markdown::SpanLevelParser::CharSourceStrscan
- MaRuKu::In::Markdown::SpanLevelParser::HTMLHelper
- MaRuKu::In::Markdown::SpanLevelParser::SpanContext
- MaRuKu::MDDocument
- MaRuKu::MDElement
- MaRuKu::MDHTMLElement
- MaRuKu::MDLine
- MaRuKu::NokogiriHTMLFragment
- MaRuKu::Out
- MaRuKu::Out::EntityTable
- MaRuKu::Out::HTML
- MaRuKu::Out::HTML::HTMLElement
- MaRuKu::Out::Latex
- MaRuKu::Out::Latex::MDDocumentExtensions
- MaRuKu::Out::Markdown
- MaRuKu::REXMLHTMLFragment
- MaRuKu::Section
- MaRuKu::Strings
- Maruku
- Maruku::In
- Maruku::In::Markdown
- Maruku::In::Markdown::FencedCode
- Object
- String
- Textile2Signature

No matching classes.

# MaRuKu::Helpers

A collection of helper functions for creating Markdown elements. They hide the particular internal representations.

Always use these rather than creating an {MDElement} directly.

### Public Instance Methods

md_abbr(abbr, title) click to toggle source

    # File lib/maruku/helpers.rb, line 60
    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 56
    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 152
    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 98
    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 35
    def md_code(code, al=nil)
      md_el(:inline_code, [], { :raw_code => code }, al)
    end

md_codeblock(source, lang=nil, al=nil) click to toggle source

Code block

    # File lib/maruku/helpers.rb, line 40
    def md_codeblock(source, lang=nil, al=nil)
      md_el(:code, [], { :raw_code => source, :lang => lang }, al)
    end

md_el(node_type, children=[], meta={}, al=nil) click to toggle source

@param children [MDElement, String, Array<MDElement, String>]

    The child nodes.
    If the first child is a \{#md\_ial}, it's merged with `al`

    # File lib/maruku/helpers.rb, line 12
    def md_el(node_type, children=[], meta={}, al=nil)
      children = Array(children)

      first = children.first
      if first && first.is_a?(MDElement) && first.node_type == :ial
        if al
          al += first.ial
        else
          al = first.ial
        end
        children.shift
      end

      e = MDElement.new(node_type, children, meta, al)
      e.doc = @doc
      e
    end

md_em(children, al=nil) click to toggle source

    # File lib/maruku/helpers.rb, line 94
    def md_em(children, al=nil)
      md_el(:emphasis, children, {}, al)
    end

md_email(email, al=nil) click to toggle source

An email to be linkified (e.g. `<andrea@rubyforge.org>` or `<andrea@rubyforge.org>`).

    # File lib/maruku/helpers.rb, line 121
    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 110
    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 125
    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 130
    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 52
    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 30
    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 102
    def md_hrule
      md_el(:hrule, [], {}, nil)
    end

md_html(raw_html, al=nil) click to toggle source

    # File lib/maruku/helpers.rb, line 64
    def md_html(raw_html, al=nil)
      e = MDHTMLElement.new(:raw_html, [], :raw_html => raw_html)
      e.doc = @doc
      begin
        # Set this as an attribute so it doesn't get included
        # in metadata comparisons
        e.parsed_html = MaRuKu::HTMLFragment.new(raw_html)
      rescue => ex
        maruku_recover "Maruku cannot parse this block of HTML/XML:\n" +
          raw_html.gsub(/^/, '|').rstrip + "\n" + ex.to_s
      end
      e
    end

md_ial(al) click to toggle source

inline attribute list

    # File lib/maruku/helpers.rb, line 146
    def md_ial(al)
      al = Maruku::AttributeList.new(al) unless al.is_a?(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 90
    def md_im_image(children, url, title=nil, al=nil)
      md_el(:im_image, children, { :url => url, :title => title }, al)
    end

md_im_link(children, url, title = nil, al=nil) click to toggle source

    # File lib/maruku/helpers.rb, line 82
    def md_im_link(children, url, title = nil, al=nil)
      md_el(:im_link, children, { :url => url, :title => title }, al)
    end

md_image(children, ref_id, al=nil) click to toggle source

    # File lib/maruku/helpers.rb, line 86
    def md_image(children, ref_id, al=nil)
      md_el(:image, children, { :ref_id => ref_id }, al)
    end

md_li(children, want_my_par=false, al=nil) click to toggle source

    # File lib/maruku/helpers.rb, line 48
    def md_li(children, want_my_par=false, al=nil)
      md_el(:li, children, { :want_my_paragraph => want_my_par }, al)
    end

md_link(children, ref_id, al=nil) click to toggle source

    # File lib/maruku/helpers.rb, line 78
    def md_link(children, ref_id, al=nil)
      md_el(:link, children, { :ref_id => ref_id }, al)
    end

md_par(children, al=nil) click to toggle source

    # File lib/maruku/helpers.rb, line 134
    def md_par(children, al=nil)
      md_el(:paragraph, children, {}, al)
    end

md_quote(children, al=nil) click to toggle source

    # File lib/maruku/helpers.rb, line 44
    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

A definition of a reference (e.g. `[1]: url [properties]`).

    # File lib/maruku/helpers.rb, line 139
    def md_ref_def(ref_id, url, title=nil, meta={}, al=nil)
      all_meta = meta.merge({ :url => url, :ref_id => ref_id })
      all_meta[:title] ||= title
      md_el(:ref_definition, [], all_meta, al)
    end

md_strong(children, al=nil) click to toggle source

    # File lib/maruku/helpers.rb, line 106
    def md_strong(children, al=nil)
      md_el(:strong, children, {}, al)
    end

md_url(url, al=nil) click to toggle source

A URL to be linkified (e.g. `<www.example.com/>`).

    # File lib/maruku/helpers.rb, line 115
    def md_url(url, al=nil)
      md_el(:immediate_link, [], { :url => url }, al)
    end

md_xml_instr(target, code) click to toggle source

A server directive (e.g. `<?target code... ?>`)

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

[Validate]

Generated with the Darkfish Rdoc Generator 2.