Class: MaRuKu::In::Markdown::SpanLevelParser::CaptureRule
- Defined in:
- lib/maruku/input/rubypants.rb
Overview
A more complex rule that uses a capture group from the pattern in its replacement.
Instance Attribute Summary
Attributes inherited from Rule
Instance Method Summary collapse
-
#apply(first, input, output) ⇒ Object
One at a time, replace each match, including some part of the match, and put the rest back into input to be processed next.
Methods inherited from Rule
Constructor Details
This class inherits a constructor from MaRuKu::In::Markdown::SpanLevelParser::Rule
Instance Method Details
#apply(first, input, output) ⇒ Object
One at a time, replace each match, including some part of the match, and put the rest back into input to be processed next.
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'lib/maruku/input/rubypants.rb', line 197 def apply(first, input, output) if pattern =~ first m = Regexp.last_match append_to_output(output, m.pre_match) input.unshift m.post_match unless m.post_match.empty? replacement.reverse_each do |sub| if sub == :one input.unshift m[1] else entity = sub.clone sub.doc = doc input.unshift entity end end else append_to_output(output, first) end end |