class MaRuKu::AttributeList

This represents a list of attributes specified in the Markdown document that apply to a Markdown-generated tag. What was ‘{#id .class key=“val” ref}` in the Markdown is parsed into `[[:id, ’id’], [:class, ‘class’], [‘key’, ‘val’], [:ref, ‘ref’]]‘.

Public Instance Methods

to_md()
Alias for: to_s
to_s() click to toggle source
# File lib/maruku/attributes.rb, line 7
def to_s
  map do |k, v|
    value = quote_if_needed(v)
    case k
    when :id;    "#" + value
    when :class; "." + value
    when :ref;    value
    else quote_if_needed(k) + "=" + value
    end
  end.join(' ')
end
Also aliased as: to_md

Private Instance Methods

quote_if_needed(str) click to toggle source
# File lib/maruku/attributes.rb, line 22
def quote_if_needed(str)
  (str =~ /[\s'"]/) ? str.inspect : str
end