lib/infoboxer/parser/context.rb in infoboxer-0.1.2.1 vs lib/infoboxer/parser/context.rb in infoboxer-0.2.0
- old
+ new
@@ -1,6 +1,8 @@
# encoding: utf-8
+require 'strscan'
+
module Infoboxer
class Parser
class Context
attr_reader :lineno
attr_reader :traits
@@ -84,14 +86,26 @@
res = _scan_until(re)
res[matched] = '' if res && !leave_pattern
res
end
+ def push_eol_sign(re)
+ @inline_eol_sign = re
+ end
+
+ def pop_eol_sign
+ @inline_eol_sign = nil
+ end
+
+ attr_reader :inline_eol_sign
+
def inline_eol?(exclude = nil)
# not using StringScanner#check, as it will change #matched value
eol? ||
- (current =~ %r[^(</ref>|}})] &&
- (!exclude || $1 !~ exclude)) # FIXME: ugly, but no idea of prettier solution
+ (
+ (current =~ %r[^(</ref>|}})] || @inline_eol_sign && current =~ @inline_eol_sign) &&
+ (!exclude || $1 !~ exclude)
+ ) # FIXME: ugly, but no idea of prettier solution
end
def scan_continued_until(re, leave_pattern = false)
res = ''