Sha256: 822a0ab44090a1bde687295118908dd351a95a3fb1ca6fadcddb1c8ac12121f4

Contents?: true

Size: 643 Bytes

Versions: 7

Compression:

Stored size: 643 Bytes

Contents

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
hamlit-1.7.2 lib/hamlit/parsers/text.rb
hamlit-1.7.1 lib/hamlit/parsers/text.rb
hamlit-1.7.0 lib/hamlit/parsers/text.rb
hamlit-1.6.7 lib/hamlit/parsers/text.rb
hamlit-1.6.6 lib/hamlit/parsers/text.rb
hamlit-1.6.5 lib/hamlit/parsers/text.rb
hamlit-1.6.4 lib/hamlit/parsers/text.rb