Sha256: 0fe39d0a0445de0a400a6247b80fcb59946a5fe1fb68e052cb6468434c1012ec

Contents?: true

Size: 1.58 KB

Versions: 44

Compression:

Stored size: 1.58 KB

Contents

# -*- coding: utf-8 -*- #
# frozen_string_literal: true

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 %r/[ \t]*\n/, Text
        rule(/[ \t]*/) { |m| token Text; indentation(m[0]) }
      end

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

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

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

        mixin :content_common

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

        rule %r/:/, Name::Attribute, :old_style_attr

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

        rule(//) { push :selector }
      end

      state :single_comment do
        rule %r/.*?$/, Comment::Single, :pop!
      end

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

      state :import do
        rule %r/[ \t]+/, Text
        rule %r/\S+/, Str
        rule %r/\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

44 entries across 44 versions & 2 rubygems

Version Path
rouge-4.5.1 lib/rouge/lexers/sass.rb
rouge-4.5.0 lib/rouge/lexers/sass.rb
rouge-4.4.0 lib/rouge/lexers/sass.rb
rouge-4.3.0 lib/rouge/lexers/sass.rb
rouge-4.2.1 lib/rouge/lexers/sass.rb
rouge-4.2.0 lib/rouge/lexers/sass.rb
rouge-4.1.3 lib/rouge/lexers/sass.rb
rouge-4.1.2 lib/rouge/lexers/sass.rb
rouge-4.1.1 lib/rouge/lexers/sass.rb
mumukit-content-type-1.12.1 vendor/bundle/ruby/2.7.0/gems/rouge-3.30.0/lib/rouge/lexers/sass.rb
mumukit-content-type-1.12.0 vendor/bundle/ruby/2.7.0/gems/rouge-3.30.0/lib/rouge/lexers/sass.rb
rouge-4.1.0 lib/rouge/lexers/sass.rb
rouge-4.0.1 lib/rouge/lexers/sass.rb
rouge-4.0.0 lib/rouge/lexers/sass.rb
rouge-3.30.0 lib/rouge/lexers/sass.rb
rouge-3.29.0 lib/rouge/lexers/sass.rb
rouge-3.28.0 lib/rouge/lexers/sass.rb
rouge-3.27.0 lib/rouge/lexers/sass.rb
rouge-3.26.1 lib/rouge/lexers/sass.rb
mumukit-content-type-1.11.1 vendor/bundle/ruby/2.6.0/gems/rouge-3.26.0/lib/rouge/lexers/sass.rb