This file is indexed.

/usr/lib/ruby/vendor_ruby/rugments/theme.rb is in ruby-rugments 1.0.0~beta8-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
module Rugments
  class Theme
    include Token::Tokens

    class Style < Hash
      def initialize(theme, hsh = {})
        super()
        @theme = theme
        merge!(hsh)
      end

      [:fg, :bg].each do |mode|
        define_method mode do
          return self[mode] unless @theme
          @theme.palette(self[mode]) if self[mode]
        end
      end

      def render(selector, &b)
        return enum_for(:render, selector).to_a.join("\n") unless b

        return if empty?

        yield "#{selector} {"
        rendered_rules.each do |rule|
          yield "  #{rule};"
        end
        yield '}'
      end

      def rendered_rules(&b)
        return enum_for(:rendered_rules) unless b
        yield "color: #{fg}" if fg
        yield "background-color: #{bg}" if bg
        yield 'font-weight: bold' if self[:bold]
        yield 'font-style: italic' if self[:italic]
        yield 'text-decoration: underline' if self[:underline]

        (self[:rules] || []).each(&b)
      end
    end

    def styles
      @styles ||= self.class.styles.dup
    end

    @palette = {}
    def self.palette(arg = {})
      @palette ||= InheritableHash.new(superclass.palette)

      if arg.is_a? Hash
        @palette.merge! arg
        @palette
      else
        case arg
        when /#[0-9a-f]+/i
          arg
        else
          @palette[arg] || fail("not in palette: #{arg.inspect}")
        end
      end
    end

    @styles = {}
    def self.styles
      @styles ||= InheritableHash.new(superclass.styles)
    end

    def self.render(opts = {}, &b)
      new(opts).render(&b)
    end

    class << self
      def style(*tokens)
        style = tokens.last.is_a?(Hash) ? tokens.pop : {}

        style = Style.new(self, style)

        tokens.each do |tok|
          styles[tok] = style
        end
      end

      def get_own_style(token)
        token.token_chain.each do |anc|
          return styles[anc] if styles[anc]
        end

        nil
      end

      def get_style(token)
        get_own_style(token) || base_style
      end

      def base_style
        styles[Token::Tokens::Text]
      end

      def name(n = nil)
        return @name if n.nil?

        @name = n.to_s
        Theme.registry[@name] = self
      end

      def find(n)
        registry[n.to_s]
      end

      def registry
        @registry ||= {}
      end
    end
  end

  module HasModes
    def mode(arg = :absent)
      return @mode if arg == :absent

      @modes ||= {}
      @modes[arg] ||= get_mode(arg)
    end

    def get_mode(mode)
      return self if self.mode == mode

      new_name = "#{name}.#{mode}"
      Class.new(self) { name(new_name); mode!(mode) }
    end

    def mode!(arg)
      @mode = arg
      send("make_#{arg}!")
    end
  end

  class CSSTheme < Theme
    def initialize(opts = {})
      @scope = opts[:scope] || '.highlight'
    end

    def render(&b)
      return enum_for(:render).to_a.join("\n") unless b

      # shared styles for tableized line numbers
      yield "#{@scope} table td { padding: 5px; }"
      yield "#{@scope} table pre { margin: 0; }"

      styles.each do |tok, style|
        style.render(css_selector(tok), &b)
      end
    end

    def render_base(selector, &b)
      self.class.base_style.render(selector, &b)
    end

    def style_for(tok)
      self.class.get_style(tok)
    end

    private

    def css_selector(token)
      inflate_token(token).map do |tok|
        fail "unknown token: #{tok.inspect}" if tok.shortname.nil?

        single_css_selector(tok)
      end.join(', ')
    end

    def single_css_selector(token)
      return @scope if token == Text

      "#{@scope} .#{token.shortname}"
    end

    # yield all of the tokens that should be styled the same
    # as the given token.  Essentially this recursively all of
    # the subtokens, except those which are more specifically
    # styled.
    def inflate_token(tok, &b)
      return enum_for(:inflate_token, tok) unless block_given?

      yield tok
      tok.sub_tokens.each do |(_, st)|
        next if styles[st]

        inflate_token(st, &b)
      end
    end
  end
end


require_relative 'themes/thankful_eyes'
require_relative 'themes/colorful'
require_relative 'themes/base16'
require_relative 'themes/github'
require_relative 'themes/monokai'
require_relative 'themes/monokai_sublime'