summaryrefslogtreecommitdiff
path: root/vendor/bundle/ruby/3.4.0/gems/rouge-4.5.2/lib/rouge/lexers/codeowners.rb
blob: 7f07911fa701beac9d44ff597fa96b7bc7a04dfe (plain)
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
# -*- coding: utf-8 -*- #
# frozen_string_literal: true

module Rouge
  module Lexers
    class Codeowners < RegexLexer
      title 'CODEOWNERS'
      desc 'Code Owners syntax (https://docs.gitlab.com/ee/user/project/codeowners/reference.html)'
      tag 'codeowners'
      filenames 'CODEOWNERS'

      state :root do
        rule %r/[ \t\r\n]+/, Text::Whitespace
        rule %r/^\s*#.*$/, Comment::Single

        rule %r(
          (\^?\[(?!\d+\])[^\]]+\])
          (\[\d+\])?
        )x do
          groups Name::Namespace, Literal::Number
        end

        rule %r/\S*@\S+/, Name::Function

        rule %r/[\p{Word}\.\/\-\*]+/, Name
        rule %r/.*\\[\#\s]/, Name
      end
    end
  end
end