Module: MaRuKu::Helpers
- Included in:
- In::Markdown::BlockLevelParser, In::Markdown::SpanLevelParser, MDElement
- Defined in:
- lib/maruku.rb,
lib/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/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/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
178 179 180 |
# File 'lib/maruku/helpers.rb', line 178 def md_ald(id, al) md_el(:ald, [], {:ald_id=>id,:ald=>al}) end |
#md_br ⇒ Object
122 123 124 |
# File 'lib/maruku/helpers.rb', line 122 def md_br() md_el(:linebreak, [], {}, nil) end |
#md_code(code, al = nil) ⇒ Object
Inline code
54 55 56 |
# 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) ⇒ Object
Code block
59 60 61 |
# 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) ⇒ 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/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
118 119 120 |
# File 'lib/maruku/helpers.rb', line 118 def md_em(children, al=nil) md_el(:emphasis, [children].flatten, {}, al) end |
#md_email(email, al = nil) ⇒ Object
145 146 147 |
# File 'lib/maruku/helpers.rb', line 145 def md_email(email, al=nil) md_el(:email_address, [], {:email=>email}, al) end |
#md_emstrong(children, al = nil) ⇒ Object
134 135 136 |
# File 'lib/maruku/helpers.rb', line 134 def md_emstrong(children, al=nil) md_strong(md_em(children), al) end |
#md_entity(entity_name, al = nil) ⇒ Object
149 150 151 |
# File 'lib/maruku/helpers.rb', line 149 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
154 155 156 |
# File 'lib/maruku/helpers.rb', line 154 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/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/maruku/helpers.rb', line 49 def md_header(level, children, al=nil) md_el(:header, children, {:level => level}, al) end |
#md_hrule ⇒ Object
126 127 128 |
# File 'lib/maruku/helpers.rb', line 126 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 |
# 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 # tell_user "Malformed block of HTML:\n"+ # add_tabs(raw_html,1,'|') # " #{raw_html.inspect}\n\n"+ex.inspect end e end |
#md_ial(al) ⇒ Object
inline attribute list
171 172 173 174 175 |
# File 'lib/maruku/helpers.rb', line 171 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
114 115 116 |
# File 'lib/maruku/helpers.rb', line 114 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
106 107 108 |
# File 'lib/maruku/helpers.rb', line 106 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
110 111 112 |
# File 'lib/maruku/helpers.rb', line 110 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/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
102 103 104 |
# File 'lib/maruku/helpers.rb', line 102 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
158 159 160 |
# File 'lib/maruku/helpers.rb', line 158 def md_par(children, al=nil) md_el(:paragraph, children, ={}, al) end |
#md_quote(children, al = nil) ⇒ Object
63 64 65 |
# 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) ⇒ Object
- 1]: url [properties
163 164 165 166 167 168 |
# File 'lib/maruku/helpers.rb', line 163 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
130 131 132 |
# File 'lib/maruku/helpers.rb', line 130 def md_strong(children, al=nil) md_el(:strong, [children].flatten, {}, al) end |
#md_url(url, al = nil) ⇒ Object
139 140 141 |
# File 'lib/maruku/helpers.rb', line 139 def md_url(url, al=nil) md_el(:immediate_link, [], {:url=>url}, al) end |
#md_xml_instr(target, code) ⇒ Object
Server directive <?target code… ?>
183 184 185 |
# File 'lib/maruku/helpers.rb', line 183 def md_xml_instr(target, code) md_el(:xml_instr, [], {:target=>target, :code=>code}) end |