lib/hamlit/parsers/text.rb in hamlit-1.6.3 vs lib/hamlit/parsers/text.rb in hamlit-1.6.4
- old
+ new
@@ -3,14 +3,26 @@
module Hamlit
module Parsers
module Text
include Concerns::Error
- def parse_text(scanner, lstrip: false, escape: true, scan: nil)
+ def parse_text(scanner, lstrip: false, escape: true, scan: nil, inline: true)
+ reject_text_nesting! unless inline
+
scanner.scan(scan) if scan
text = (scanner.scan(/.+/) || '')
text = text.lstrip if lstrip
[:haml, :text, text, escape]
+ end
+
+ private
+
+ def reject_text_nesting!
+ return unless next_line
+
+ if next_indent > @current_indent
+ syntax_error!('Illegal nesting: nesting within plain text is illegal.')
+ end
end
end
end
end