Module: MaRuKu::Helpers
- Included in:
- In::Markdown::BlockLevelParser, In::Markdown::SpanLevelParser, MDElement
- Defined in:
- lib/amp-front/third_party/maruku.rb,
lib/amp-front/third_party/maruku/helpers.rb
Instance Method Summary collapse
- #md_abbr(abbr, title) ⇒ Object
- #md_abbr_def(abbr, text, al = nil) ⇒ Object
-
#md_ald(id, al) ⇒ Object
Attribute list definition.
- #md_br ⇒ Object
-
#md_code(code, al = nil) ⇒ Object
Inline code.
-
#md_codeblock(source, al = nil) ⇒ Object
Code block.
-
#md_el(node_type, children = [], meta = {}, al = nil) ⇒ Object
if the first is a md_ial, it is used as such.
- #md_em(children, al = nil) ⇒ Object
- #md_email(email, al = nil) ⇒ Object
- #md_emstrong(children, al = nil) ⇒ Object
- #md_entity(entity_name, al = nil) ⇒ Object
-
#md_foot_ref(ref_id, al = nil) ⇒ Object
Markdown extra.
- #md_footnote(footnote_id, children, al = nil) ⇒ Object
- #md_header(level, children, al = nil) ⇒ Object
- #md_hrule ⇒ Object
- #md_html(raw_html, al = nil) ⇒ Object
-
#md_ial(al) ⇒ Object
inline attribute list.
- #md_im_image(children, url, title = nil, al = nil) ⇒ Object
- #md_im_link(children, url, title = nil, al = nil) ⇒ Object
- #md_image(children, ref_id, al = nil) ⇒ Object
- #md_li(children, want_my_par, al = nil) ⇒ Object
- #md_link(children, ref_id, al = nil) ⇒ Object
- #md_par(children, al = nil) ⇒ Object
- #md_quote(children, al = nil) ⇒ Object
-
#md_ref_def(ref_id, url, title = nil, meta = {}, al = nil) ⇒ Object
[1]: url [properties].
- #md_strong(children, al = nil) ⇒ Object
-
#md_url(url, al = nil) ⇒ Object
<www.example.com/>.
-
#md_xml_instr(target, code) ⇒ Object
Server directive <?target code…
Instance Method Details
#md_abbr(abbr, title) ⇒ Object
79 80 81 |
# File 'lib/amp-front/third_party/maruku/helpers.rb', line 79 def md_abbr(abbr, title) md_el(:abbr, [abbr], {:title=>title}) end |
#md_abbr_def(abbr, text, al = nil) ⇒ Object
75 76 77 |
# File 'lib/amp-front/third_party/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) ⇒ Object
Attribute list definition
179 180 181 |
# File 'lib/amp-front/third_party/maruku/helpers.rb', line 179 def md_ald(id, al) md_el(:ald, [], {:ald_id=>id,:ald=>al}) end |
#md_br ⇒ Object
123 124 125 |
# File 'lib/amp-front/third_party/maruku/helpers.rb', line 123 def md_br() md_el(:linebreak, [], {}, nil) end |
#md_code(code, al = nil) ⇒ Object
Inline code
54 55 56 |
# File 'lib/amp-front/third_party/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) ⇒ Object
Code block
59 60 61 |
# File 'lib/amp-front/third_party/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) ⇒ Object
if the first is a md_ial, it is used as such
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/amp-front/third_party/maruku/helpers.rb', line 34 def md_el(node_type, children=[], ={}, 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, , al) e.doc = @doc return e end |
#md_em(children, al = nil) ⇒ Object
119 120 121 |
# File 'lib/amp-front/third_party/maruku/helpers.rb', line 119 def md_em(children, al=nil) md_el(:emphasis, [children].flatten, {}, al) end |
#md_email(email, al = nil) ⇒ Object
146 147 148 |
# File 'lib/amp-front/third_party/maruku/helpers.rb', line 146 def md_email(email, al=nil) md_el(:email_address, [], {:email=>email}, al) end |
#md_emstrong(children, al = nil) ⇒ Object
135 136 137 |
# File 'lib/amp-front/third_party/maruku/helpers.rb', line 135 def md_emstrong(children, al=nil) md_strong(md_em(children), al) end |
#md_entity(entity_name, al = nil) ⇒ Object
150 151 152 |
# File 'lib/amp-front/third_party/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) ⇒ Object
Markdown extra
155 156 157 |
# File 'lib/amp-front/third_party/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) ⇒ Object
71 72 73 |
# File 'lib/amp-front/third_party/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) ⇒ Object
49 50 51 |
# File 'lib/amp-front/third_party/maruku/helpers.rb', line 49 def md_header(level, children, al=nil) md_el(:header, children, {:level => level}, al) end |
#md_hrule ⇒ Object
127 128 129 |
# File 'lib/amp-front/third_party/maruku/helpers.rb', line 127 def md_hrule() md_el(:hrule, [], {}, nil) end |
#md_html(raw_html, al = nil) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/amp-front/third_party/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) ⇒ Object
inline attribute list
172 173 174 175 176 |
# File 'lib/amp-front/third_party/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) ⇒ Object
115 116 117 |
# File 'lib/amp-front/third_party/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_im_link(children, url, title = nil, al = nil) ⇒ Object
107 108 109 |
# File 'lib/amp-front/third_party/maruku/helpers.rb', line 107 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) ⇒ Object
111 112 113 |
# File 'lib/amp-front/third_party/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) ⇒ Object
67 68 69 |
# File 'lib/amp-front/third_party/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_link(children, ref_id, al = nil) ⇒ Object
103 104 105 |
# File 'lib/amp-front/third_party/maruku/helpers.rb', line 103 def md_link(children, ref_id, al=nil) md_el(:link, children, {:ref_id=>ref_id.downcase}, al) end |
#md_par(children, al = nil) ⇒ Object
159 160 161 |
# File 'lib/amp-front/third_party/maruku/helpers.rb', line 159 def md_par(children, al=nil) md_el(:paragraph, children, ={}, al) end |
#md_quote(children, al = nil) ⇒ Object
63 64 65 |
# File 'lib/amp-front/third_party/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) ⇒ Object
- 1]: url [properties
164 165 166 167 168 169 |
# File 'lib/amp-front/third_party/maruku/helpers.rb', line 164 def md_ref_def(ref_id, url, title=nil, ={}, al=nil) [:url] = url [:ref_id] = ref_id [:title] = title if title md_el(:ref_definition, [], , al) end |
#md_strong(children, al = nil) ⇒ Object
131 132 133 |
# File 'lib/amp-front/third_party/maruku/helpers.rb', line 131 def md_strong(children, al=nil) md_el(:strong, [children].flatten, {}, al) end |
#md_url(url, al = nil) ⇒ Object
140 141 142 |
# File 'lib/amp-front/third_party/maruku/helpers.rb', line 140 def md_url(url, al=nil) md_el(:immediate_link, [], {:url=>url}, al) end |
#md_xml_instr(target, code) ⇒ Object
Server directive <?target code… ?>
184 185 186 |
# File 'lib/amp-front/third_party/maruku/helpers.rb', line 184 def md_xml_instr(target, code) md_el(:xml_instr, [], {:target=>target, :code=>code}) end |