Class: PointBlank::Parsing::CodeInline
- Inherits:
-
NullInline
- Object
- NullInline
- PointBlank::Parsing::CodeInline
- Defined in:
- lib/mmmd/blankshell.rb
Overview
Code inline parser
Class Method Summary collapse
-
.forward_walk(parts) ⇒ Object
TODO: optimize, buffer only after walking (see ::PointBlank::Parsing::NullInline#forward_walk).
- .tokenize(string, *_lookaround) ⇒ Object
Methods inherited from NullInline
build, check_contents, check_unescaped, construct_literal, construct_text, find_unescaped, iterate_tokens, reverse_walk
Class Method Details
.forward_walk(parts) ⇒ Object
TODO: optimize, buffer only after walking (see ::PointBlank::Parsing::NullInline#forward_walk)
1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 |
# File 'lib/mmmd/blankshell.rb', line 1160 def self.forward_walk(parts) buffer = "" opening = parts.first.first cutoff = 0 parts.each_with_index do |part, idx| text = (part.is_a?(Array) ? part.first : part) buffer += text next unless part.is_a? Array next if idx.zero? break (cutoff = idx) if part.first == opening end buffer = construct_literal(buffer[opening.length..(-1 - opening.length)]) [cutoff.positive? ? build([buffer]) : opening, parts[(cutoff + 1)..]] end |
.tokenize(string, *_lookaround) ⇒ Object
1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 |
# File 'lib/mmmd/blankshell.rb', line 1147 def self.tokenize(string, *_lookaround) iterate_tokens(string, "`") do |_before, current_text, matched| if matched match = current_text.match(/^`+/)[0] [match, self, :open] else current_text[0] end end end |