File: sass.rb

package info (click to toggle)
ruby-rugments 1.0.0~beta8-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 820 kB
  • sloc: ruby: 10,293; makefile: 2
file content (72 lines) | stat: -rw-r--r-- 1,560 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
module Rugments
  module Lexers
    load_const :SassCommon, '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