mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
28 lines
643 B
Ruby
28 lines
643 B
Ruby
require 'hamlit/concerns/error'
|
|
|
|
module Hamlit
|
|
module Parsers
|
|
module Text
|
|
include Concerns::Error
|
|
|
|
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
|