Class: MaRuKu::In::Markdown::SpanLevelParser::ReplaceRule
- Defined in:
- lib/maruku/input/rubypants.rb
Overview
Simple rule that says “Replace this pattern with these entities”
Instance Attribute Summary
Attributes inherited from Rule
Instance Method Summary collapse
-
#apply(first, input, output) ⇒ Object
Replace all matches in the input at once with the same elements from “replacement”.
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
Replace all matches in the input at once with the same elements from “replacement”.
166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/maruku/input/rubypants.rb', line 166 def apply(first, input, output) split = first.split(pattern) if split.empty? first.scan(pattern).size.times do clone_elems(replacement).each do |x| append_to_output(output, x) end end else intersperse(first.split(pattern), replacement).each do |x| append_to_output(output, x) end end end |