Sha256: ebc7e3ad8063f99ee8c140515db74f569750479c087f582ec52dd624a7e71108

Contents?: true

Size: 1.26 KB

Versions: 72

Compression:

Stored size: 1.26 KB

Contents

module Slim
  module Smart
    # @api private
    class Parser < ::Slim::Parser
      define_options implicit_text: true

      def initialize(opts = {})
        super
        word_re = options[:implicit_text] ? '[_a-z0-9]' : '\p{Word}'
        attr_keys = Regexp.union(@attr_shortcut.keys.sort_by {|k| -k.size } )
        @attr_shortcut_re = /\A(#{attr_keys}+)((?:\p{Word}|-)*)/
        tag_keys = Regexp.union((@tag_shortcut.keys - @attr_shortcut.keys).sort_by {|k| -k.size } )
        @tag_re = /\A(?:#{attr_keys}(?=-*\p{Word})|#{tag_keys}|\*(?=[^\s]+)|(#{word_re}(?:#{word_re}|:|-)*#{word_re}|#{word_re}+))/
      end

      def unknown_line_indicator
        if @line =~ /\A>( ?)/
          # Found explicit text block.
          @stacks.last << [:slim, :text, :explicit, parse_text_block($', @indents.last + $1.size + 1)]
        else
          unless options[:implicit_text]
            syntax_error! 'Illegal shortcut' if @line =~ @attr_shortcut_re
            super
          end
          # Found implicit smart text block.
          if line = @lines.first
            indent = ( line =~ /\A\s*\Z/ ? @indents.last + 1 : get_indent(line) )
          end
          @stacks.last << [:slim, :text, :implicit, parse_text_block(@line, indent)]
        end
      end
    end
  end
end

Version data entries

72 entries across 58 versions & 5 rubygems

Version Path
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/brakeman-4.7.2/bundle/ruby/2.6.0/gems/slim-4.0.1/lib/slim/smart/parser.rb
brakeman-4.7.2 bundle/ruby/2.6.0/gems/slim-4.0.1/lib/slim/smart/parser.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/brakeman-4.5.1/bundle/ruby/2.5.0/gems/slim-4.0.1/lib/slim/smart/parser.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/brakeman-4.7.0/bundle/ruby/2.6.0/gems/slim-4.0.1/lib/slim/smart/parser.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/brakeman-4.6.1/bundle/ruby/2.6.0/gems/slim-4.0.1/lib/slim/smart/parser.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/brakeman-4.7.1/bundle/ruby/2.6.0/gems/slim-4.0.1/lib/slim/smart/parser.rb
brakeman-4.7.1 bundle/ruby/2.6.0/gems/slim-4.0.1/lib/slim/smart/parser.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/brakeman-4.7.0/bundle/ruby/2.6.0/gems/slim-4.0.1/lib/slim/smart/parser.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/brakeman-4.6.1/bundle/ruby/2.6.0/gems/slim-4.0.1/lib/slim/smart/parser.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/brakeman-4.5.1/bundle/ruby/2.5.0/gems/slim-4.0.1/lib/slim/smart/parser.rb
brakeman-4.7.0 bundle/ruby/2.6.0/gems/slim-4.0.1/lib/slim/smart/parser.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/brakeman-4.6.1/bundle/ruby/2.6.0/gems/slim-4.0.1/lib/slim/smart/parser.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/brakeman-4.5.1/bundle/ruby/2.5.0/gems/slim-4.0.1/lib/slim/smart/parser.rb
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/brakeman-4.5.1/bundle/ruby/2.5.0/gems/slim-4.0.1/lib/slim/smart/parser.rb
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/brakeman-4.6.1/bundle/ruby/2.6.0/gems/slim-4.0.1/lib/slim/smart/parser.rb
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/brakeman-4.5.1/bundle/ruby/2.5.0/gems/slim-4.0.1/lib/slim/smart/parser.rb
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/brakeman-4.6.1/bundle/ruby/2.6.0/gems/slim-4.0.1/lib/slim/smart/parser.rb
zuora_connect_ui-0.8.1 vendor/ruby/2.6.0/gems/brakeman-4.6.1/bundle/ruby/2.6.0/gems/slim-4.0.1/lib/slim/smart/parser.rb
zuora_connect_ui-0.8.1 vendor/ruby/2.6.0/gems/brakeman-4.5.1/bundle/ruby/2.5.0/gems/slim-4.0.1/lib/slim/smart/parser.rb
zuora_connect_ui-0.8.0 vendor/ruby/2.6.0/gems/brakeman-4.6.1/bundle/ruby/2.6.0/gems/slim-4.0.1/lib/slim/smart/parser.rb