Sha256: e35cd0dbecbd7c710a1f82ec12422fe7eb78c6427b4abf1de3146d8e0099fcb2

Contents?: true

Size: 1.53 KB

Versions: 23

Compression:

Stored size: 1.53 KB

Contents

# -*- coding: utf-8 -*- #

module Rouge
  module Lexers
    load_lexer 'sass/common.rb'

    class Sass < SassCommon
      include Indentation

      title "Sass"
      desc 'The Sass stylesheet language language (sass-lang.com)'

      tag 'sass'
      filenames '*.sass'
      mimetypes 'text/x-sass'

      id = /[\w-]+/

      state :root do
        rule /[ \t]*\n/, Text
        rule(/[ \t]*/) { |m| token Text; indentation(m[0]) }
      end

      state :content do
        # block comments
        rule %r(//.*?\n) do
          token Comment::Single
          pop!; starts_block :single_comment
        end

        rule %r(/[*].*?\n) do
          token Comment::Multiline
          pop!; starts_block :multi_comment
        end

        rule /@import\b/, Keyword, :import

        mixin :content_common

        rule %r(=#{id}), Name::Function, :value
        rule %r([+]#{id}), Name::Decorator, :value

        rule /:/, Name::Attribute, :old_style_attr

        rule(/(?=.+?:([^a-z]|$))/) { push :attribute }

        rule(//) { push :selector }
      end

      state :single_comment do
        rule /.*?\n/, Comment::Single, :pop!
      end

      state :multi_comment do
        rule /.*?\n/, Comment::Multiline, :pop!
      end

      state :import do
        rule /[ \t]+/, Text
        rule /\S+/, Str
        rule /\n/, Text, :pop!
      end

      state :old_style_attr do
        mixin :attr_common
        rule(//) { pop!; push :value }
      end

      state :end_section do
        rule(/\n/) { token Text; reset_stack }
      end
    end
  end
end

Version data entries

23 entries across 21 versions & 5 rubygems

Version Path
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/rouge-2.2.1/lib/rouge/lexers/sass.rb
rouge_ecl-1.0.0 lib/rouge/lexers/sass.rb
rouge-3.0.0 lib/rouge/lexers/sass.rb
rouge-2.2.1 lib/rouge/lexers/sass.rb
rouge-2.2.0 lib/rouge/lexers/sass.rb
rougegal-2.1.2 lib/rouge/lexers/sass.rb
tdiary-5.0.5 vendor/bundle/gems/rouge-2.1.1/lib/rouge/lexers/sass.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/rouge-2.0.7/lib/rouge/lexers/sass.rb
tdiary-5.0.5 vendor/bundle/gems/rouge-2.0.7/lib/rouge/lexers/sass.rb
rouge-2.1.1 lib/rouge/lexers/sass.rb
rouge-2.1.0 lib/rouge/lexers/sass.rb
tdiary-5.0.4 vendor/bundle/gems/rouge-2.0.7/lib/rouge/lexers/sass.rb
rouge-2.0.7 lib/rouge/lexers/sass.rb
rouge-2.0.6 lib/rouge/lexers/sass.rb
rouge-2.0.5 lib/rouge/lexers/sass.rb
rouge-2.0.3 lib/rouge/lexers/sass.rb
rouge-2.0.2 lib/rouge/lexers/sass.rb
rouge-2.0.1 lib/rouge/lexers/sass.rb
rouge-2.0.0 lib/rouge/lexers/sass.rb
rouge-1.11.1 lib/rouge/lexers/sass.rb