Module: Infoboxer::Parser::Inline
Instance Method Summary collapse
- #inline(until_pattern = nil) ⇒ Object
- #long_inline(until_pattern = nil) ⇒ Object
- #short_inline(until_pattern = nil) ⇒ Object
Instance Method Details
#inline(until_pattern = nil) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/infoboxer/parser/inline.rb', line 7 def inline(until_pattern = nil) start = @context.lineno nodes = Nodes[] guarded_loop do chunk = @context.scan_until(re.inline_until_cache[until_pattern]) nodes << chunk break if @context.matched_inline?(until_pattern) nodes << inline_formatting(@context.matched) unless @context.matched.empty? if @context.eof? break unless until_pattern @context.fail!("#{until_pattern} not found, starting from #{start}") end if @context.eol? nodes << "\n" @context.next! end end nodes end |
#long_inline(until_pattern = nil) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/infoboxer/parser/inline.rb', line 55 def long_inline(until_pattern = nil) nodes = Nodes[] guarded_loop do chunk = @context.scan_until(re.inline_until_cache[until_pattern]) nodes << chunk break if @context.matched?(until_pattern) nodes << inline_formatting(@context.matched) unless @context.matched.empty? if @context.eof? break unless until_pattern @context.fail!("#{until_pattern} not found") end if @context.eol? @context.next! paragraphs(until_pattern).each do |p| nodes << p end break end end nodes end |
#short_inline(until_pattern = nil) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/infoboxer/parser/inline.rb', line 32 def short_inline(until_pattern = nil) nodes = Nodes[] guarded_loop do # FIXME: quick and UGLY IS HELL JUST TRYING TO MAKE THE SHIT WORK if @context.inline_eol_sign == /^\]/ chunk = @context.scan_until(re.short_inline_until_cache_brackets[until_pattern]) elsif @context.inline_eol_sign == /^\]\]/ chunk = @context.scan_until(re.short_inline_until_cache_brackets2[until_pattern]) else chunk = @context.scan_until(re.short_inline_until_cache[until_pattern]) end nodes << chunk break if @context.matched_inline?(until_pattern) nodes << inline_formatting(@context.matched) break if @context.inline_eol?(until_pattern) end nodes end |