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
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/infoboxer/parser/inline.rb', line 8 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.source} not found, starting from #{start}") end if @context.eol? nodes << "\n" @context.next! end end nodes end |
#long_inline(until_pattern = nil) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/infoboxer/parser/inline.rb', line 58 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.source} 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
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/infoboxer/parser/inline.rb', line 34 def short_inline(until_pattern = nil) nodes = Nodes[] guarded_loop do # FIXME: quick and UGLY IS HELL JUST TRYING TO MAKE THE SHIT WORK chunk = if @context.inline_eol_sign == /^\]/ # rubocop:disable Style/CaseLikeIf @context.scan_until(re.short_inline_until_cache_brackets[until_pattern]) elsif @context.inline_eol_sign == /^\]\]/ @context.scan_until(re.short_inline_until_cache_brackets2[until_pattern]) else @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 |