rouge 4.0.1 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/lib/rouge/demos/cisco_ios +19 -0
- data/lib/rouge/guessers/disambiguation.rb +7 -0
- data/lib/rouge/lexers/cisco_ios.rb +83 -0
- data/lib/rouge/lexers/cpp.rb +5 -1
- data/lib/rouge/lexers/csharp.rb +13 -12
- data/lib/rouge/lexers/dart.rb +6 -6
- data/lib/rouge/lexers/dot.rb +1 -0
- data/lib/rouge/lexers/ghc_cmm.rb +1 -1
- data/lib/rouge/lexers/javascript.rb +30 -0
- data/lib/rouge/lexers/jinja.rb +10 -10
- data/lib/rouge/lexers/liquid.rb +164 -164
- data/lib/rouge/lexers/mosel.rb +0 -4
- data/lib/rouge/lexers/openedge.rb +581 -376
- data/lib/rouge/lexers/php.rb +5 -3
- data/lib/rouge/lexers/python.rb +27 -8
- data/lib/rouge/lexers/ruby.rb +2 -1
- data/lib/rouge/lexers/rust.rb +7 -6
- data/lib/rouge/lexers/shell.rb +6 -2
- data/lib/rouge/lexers/twig.rb +9 -9
- data/lib/rouge/lexers/yaml.rb +1 -3
- data/lib/rouge/themes/github.rb +137 -62
- data/lib/rouge/version.rb +1 -1
- data/lib/rouge.rb +3 -5
- metadata +5 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 239a3d42bfd3954d0e6f97efe4265a99cfa719bc2d0815a3fbfa1d47cb58fa66
         | 
| 4 | 
            +
              data.tar.gz: 54cccb6161415559baa8a6d8003f9bf9c9c3eb8f241b4c21234c96f1b3d9a148
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 1463511e91aee04d120e090808e232ac5d07435971b3072716046bcc6d43bf5f86c3ef9c1f11b2cfdefded88259951d299f6b476437744ac0861e3dc0516b55f
         | 
| 7 | 
            +
              data.tar.gz: a4aba9526815bf9d28a6ae7e0d02e3df29b250fa76b53d1c7bca0500cdcc8bd641198db02448e495bea510ac9b3bc1b42fb09ddc3e76dc1d501594074e7602fd
         | 
    
        data/Gemfile
    CHANGED
    
    
| @@ -0,0 +1,19 @@ | |
| 1 | 
            +
            interface FastEthernet0.20
         | 
| 2 | 
            +
                encapsulation dot1Q 20
         | 
| 3 | 
            +
                no ip route-cache
         | 
| 4 | 
            +
                bridge-group 1
         | 
| 5 | 
            +
                no bridge-group 1 source-learning
         | 
| 6 | 
            +
                bridge-group 1 spanning-disabled
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            ! Supports shortened versions of config words, too
         | 
| 9 | 
            +
            inter gi0.10
         | 
| 10 | 
            +
            encap dot1q 10 native
         | 
| 11 | 
            +
            inter gi0
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            banner login # Authenticate yourself! #
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            ! Supports #, $ and % to delimit banners, and multiline
         | 
| 16 | 
            +
            banner motd $
         | 
| 17 | 
            +
            Attention!
         | 
| 18 | 
            +
            We will be having scheduled system maintenance on this device.
         | 
| 19 | 
            +
            $
         | 
| @@ -129,6 +129,7 @@ module Rouge | |
| 129 129 |  | 
| 130 130 | 
             
                  disambiguate '*.cls' do
         | 
| 131 131 | 
             
                    next TeX if matches?(/\A\s*(?:\\|%)/)
         | 
| 132 | 
            +
                    next OpenEdge if matches?(/(no\-undo|BLOCK\-LEVEL|ROUTINE\-LEVEL|&ANALYZE\-SUSPEND)/i)
         | 
| 132 133 | 
             
                    next Apex
         | 
| 133 134 | 
             
                  end
         | 
| 134 135 |  | 
| @@ -139,6 +140,12 @@ module Rouge | |
| 139 140 |  | 
| 140 141 | 
             
                    Puppet
         | 
| 141 142 | 
             
                  end
         | 
| 143 | 
            +
                  
         | 
| 144 | 
            +
                  disambiguate '*.p' do
         | 
| 145 | 
            +
                    next Prolog if contains?(':-')
         | 
| 146 | 
            +
                    next Prolog if matches?(/\A\w+(\(\w+\,\s*\w+\))*\./)
         | 
| 147 | 
            +
                    next OpenEdge
         | 
| 148 | 
            +
                  end
         | 
| 142 149 | 
             
                end
         | 
| 143 150 | 
             
              end
         | 
| 144 151 | 
             
            end
         | 
| @@ -0,0 +1,83 @@ | |
| 1 | 
            +
            # -*- coding: utf-8 -*- #
         | 
| 2 | 
            +
            # frozen_string_literal: true
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            # Based on/regexes mostly from Brandon Bennett's pygments-routerlexers:
         | 
| 5 | 
            +
            # https://github.com/nemith/pygments-routerlexers
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            module Rouge
         | 
| 8 | 
            +
              module Lexers
         | 
| 9 | 
            +
                class CiscoIos < RegexLexer
         | 
| 10 | 
            +
                  title 'Cisco IOS'
         | 
| 11 | 
            +
                  desc 'Cisco IOS configuration lexer'
         | 
| 12 | 
            +
                  tag 'cisco_ios'
         | 
| 13 | 
            +
                  filenames '*.cfg'
         | 
| 14 | 
            +
                  mimetypes 'text/x-cisco-conf'
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                  state :root do
         | 
| 17 | 
            +
                    rule %r/^!.*/, Comment::Single
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                    rule %r/^(version\s+)(.*)$/ do
         | 
| 20 | 
            +
                      groups Keyword, Num::Float
         | 
| 21 | 
            +
                    end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                    rule %r/(desc*r*i*p*t*i*o*n*)(.*?)$/ do
         | 
| 24 | 
            +
                      groups Keyword, Comment::Single
         | 
| 25 | 
            +
                    end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                    rule %r/^(inte*r*f*a*c*e*|controller|router \S+|voice translation-\S+|voice-port|line)(.*)$/ do
         | 
| 28 | 
            +
                      groups Keyword::Type, Name::Function
         | 
| 29 | 
            +
                    end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                    rule %r/(password|secret)(\s+[57]\s+)(\S+)/ do
         | 
| 32 | 
            +
                      groups Keyword, Num, String::Double
         | 
| 33 | 
            +
                    end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                    rule %r/(permit|deny)/, Operator::Word
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                    rule %r/^(banner\s+)(motd\s+|login\s+)([#$%])/ do
         | 
| 38 | 
            +
                      groups Keyword, Name::Function, Str::Delimiter
         | 
| 39 | 
            +
                      push :cisco_ios_text
         | 
| 40 | 
            +
                    end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                    rule %r/^(dial-peer\s+\S+\s+)(\S+)(.*?)$/ do
         | 
| 43 | 
            +
                      groups Keyword, Name::Attribute, Keyword
         | 
| 44 | 
            +
                    end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                    rule %r/^(vlan\s+)(\d+)$/ do
         | 
| 47 | 
            +
                      groups Keyword, Name::Attribute
         | 
| 48 | 
            +
                    end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                    # IPv4 Address/Prefix
         | 
| 51 | 
            +
                    rule %r/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(\/\d{1,2})?/, Num
         | 
| 52 | 
            +
             | 
| 53 | 
            +
                    # NSAP
         | 
| 54 | 
            +
                    rule %r/49\.\d{4}\.\d{4}\.\d{4}\.\d{4}\.\d{2}/, Num
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                    # MAC Address
         | 
| 57 | 
            +
                    rule %r/[a-f0-9]{4}\.[a-f0-9]{4}\.[a-f0-9]{4}/, Num::Hex
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                    rule %r/^(\s*no\s+)(\S+)/ do
         | 
| 60 | 
            +
                      groups Keyword::Constant, Keyword
         | 
| 61 | 
            +
                    end
         | 
| 62 | 
            +
             | 
| 63 | 
            +
                    rule %r/^[^\n\r]\s*\S+/, Keyword
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                    # Obfuscated Passwords
         | 
| 66 | 
            +
                    rule  %r/\*+/, Name::Entity
         | 
| 67 | 
            +
             | 
| 68 | 
            +
                    rule %r/(?<= )\d+(?= )/, Num
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                    # Newline catcher, avoid errors on empty lines
         | 
| 71 | 
            +
                    rule %r/\n+/m, Text
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                    # This one goes last, a text catch-all
         | 
| 74 | 
            +
                    rule %r/./, Text
         | 
| 75 | 
            +
                  end
         | 
| 76 | 
            +
             | 
| 77 | 
            +
                  state :cisco_ios_text do
         | 
| 78 | 
            +
                    rule %r/[^#$%]/, Text
         | 
| 79 | 
            +
                    rule %r/[#$%]/, Str::Delimiter, :pop!
         | 
| 80 | 
            +
                  end
         | 
| 81 | 
            +
                end
         | 
| 82 | 
            +
              end
         | 
| 83 | 
            +
            end
         | 
    
        data/lib/rouge/lexers/cpp.rb
    CHANGED
    
    | @@ -71,7 +71,11 @@ module Rouge | |
| 71 71 | 
             
                    rule %r/\bnullptr\b/, Name::Builtin
         | 
| 72 72 | 
             
                    rule %r/(?:u8|u|U|L)?R"([a-zA-Z0-9_{}\[\]#<>%:;.?*\+\-\/\^&|~!=,"']{,16})\(.*?\)\1"/m, Str
         | 
| 73 73 | 
             
                    rule %r/(::|<=>)/, Operator
         | 
| 74 | 
            -
                    rule %r/[{ | 
| 74 | 
            +
                    rule %r/[{]/, Punctuation
         | 
| 75 | 
            +
                    rule %r/}/ do
         | 
| 76 | 
            +
                      token Punctuation
         | 
| 77 | 
            +
                      pop! if in_state?(:function) # pop :function
         | 
| 78 | 
            +
                    end
         | 
| 75 79 | 
             
                  end
         | 
| 76 80 |  | 
| 77 81 | 
             
                  state :classname do
         | 
    
        data/lib/rouge/lexers/csharp.rb
    CHANGED
    
    | @@ -27,19 +27,19 @@ module Rouge | |
| 27 27 | 
             
                    static switch this throw true try typeof unchecked unsafe
         | 
| 28 28 | 
             
                    virtual void volatile while
         | 
| 29 29 | 
             
                    add alias async await get global partial remove set value where
         | 
| 30 | 
            -
                    yield nameof
         | 
| 31 | 
            -
                    ascending by descending equals from group in into join let | 
| 32 | 
            -
                    orderby select
         | 
| 30 | 
            +
                    yield nameof notnull
         | 
| 31 | 
            +
                    ascending by descending equals from group in init into join let
         | 
| 32 | 
            +
                    on orderby select unmanaged when and not or with
         | 
| 33 33 | 
             
                  )
         | 
| 34 34 |  | 
| 35 35 | 
             
                  keywords_type = %w(
         | 
| 36 | 
            -
                    bool byte char decimal double dynamic float int long  | 
| 37 | 
            -
                    sbyte short string uint ulong ushort var
         | 
| 36 | 
            +
                    bool byte char decimal double dynamic float int long nint nuint
         | 
| 37 | 
            +
                    object sbyte short string uint ulong ushort var
         | 
| 38 38 | 
             
                  )
         | 
| 39 39 |  | 
| 40 40 | 
             
                  cpp_keywords = %w(
         | 
| 41 41 | 
             
                    if endif else elif define undef line error warning region
         | 
| 42 | 
            -
                    endregion pragma
         | 
| 42 | 
            +
                    endregion pragma nullable
         | 
| 43 43 | 
             
                  )
         | 
| 44 44 |  | 
| 45 45 | 
             
                  state :whitespace do
         | 
| @@ -81,14 +81,15 @@ module Rouge | |
| 81 81 | 
             
                    rule %r/@"(""|[^"])*"/m, Str
         | 
| 82 82 | 
             
                    rule %r/"(\\.|.)*?["\n]/, Str
         | 
| 83 83 | 
             
                    rule %r/'(\\.|.)'/, Str::Char
         | 
| 84 | 
            -
                    rule %r/ | 
| 84 | 
            +
                    rule %r/0b[_01]+[lu]?/i, Num
         | 
| 85 | 
            +
                    rule %r/0x[_0-9a-f]+[lu]?/i, Num
         | 
| 85 86 | 
             
                    rule %r(
         | 
| 86 | 
            -
                      [0-9]
         | 
| 87 | 
            -
                      ([.][0-9]*)? # decimal
         | 
| 88 | 
            -
                      (e[+-][0-9] | 
| 89 | 
            -
                      [ | 
| 87 | 
            +
                      [0-9](?:[_0-9]*[0-9])?
         | 
| 88 | 
            +
                      ([.][0-9](?:[_0-9]*[0-9])?)? # decimal
         | 
| 89 | 
            +
                      (e[+-]?[0-9](?:[_0-9]*[0-9])?)? # exponent
         | 
| 90 | 
            +
                      [fldum]? # type
         | 
| 90 91 | 
             
                    )ix, Num
         | 
| 91 | 
            -
                    rule %r/\b(?:class|struct|interface)\b/, Keyword, :class
         | 
| 92 | 
            +
                    rule %r/\b(?:class|record|struct|interface)\b/, Keyword, :class
         | 
| 92 93 | 
             
                    rule %r/\b(?:namespace|using)\b/, Keyword, :namespace
         | 
| 93 94 | 
             
                    rule %r/^#[ \t]*(#{cpp_keywords.join('|')})\b.*?\n/,
         | 
| 94 95 | 
             
                      Comment::Preproc
         | 
    
        data/lib/rouge/lexers/dart.rb
    CHANGED
    
    | @@ -12,16 +12,16 @@ module Rouge | |
| 12 12 | 
             
                  mimetypes 'text/x-dart'
         | 
| 13 13 |  | 
| 14 14 | 
             
                  keywords = %w(
         | 
| 15 | 
            -
                    as assert await break case catch continue default do else finally for
         | 
| 16 | 
            -
                     | 
| 15 | 
            +
                    as assert await break case catch continue default do else finally for if
         | 
| 16 | 
            +
                    in is new rethrow return super switch this throw try while when with yield
         | 
| 17 17 | 
             
                  )
         | 
| 18 18 |  | 
| 19 19 | 
             
                  declarations = %w(
         | 
| 20 | 
            -
                    abstract async dynamic const covariant external extends factory final get
         | 
| 21 | 
            -
                     | 
| 20 | 
            +
                    abstract base async dynamic const covariant external extends factory final get implements
         | 
| 21 | 
            +
                    inline interface late native on operator required sealed set static sync typedef var
         | 
| 22 22 | 
             
                  )
         | 
| 23 23 |  | 
| 24 | 
            -
                  types = %w(bool Comparable double Dynamic enum Function int List Map Never Null num Object Pattern Set String Symbol Type Uri void)
         | 
| 24 | 
            +
                  types = %w(bool Comparable double Dynamic enum Function int List Map Never Null num Object Pattern Record Set String Symbol Type Uri void)
         | 
| 25 25 |  | 
| 26 26 | 
             
                  imports = %w(import deferred export library part\s*of part source)
         | 
| 27 27 |  | 
| @@ -53,7 +53,7 @@ module Rouge | |
| 53 53 | 
             
                    rule %r/(?:#{declarations.join('|')})\b/, Keyword::Declaration
         | 
| 54 54 | 
             
                    rule %r/(?:#{types.join('|')})\b/, Keyword::Type
         | 
| 55 55 | 
             
                    rule %r/(?:true|false|null)\b/, Keyword::Constant
         | 
| 56 | 
            -
                    rule %r/(?:class| | 
| 56 | 
            +
                    rule %r/(?:class|mixin)\b/, Keyword::Declaration, :class
         | 
| 57 57 | 
             
                    rule %r/(?:#{imports.join('|')})\b/, Keyword::Namespace, :import
         | 
| 58 58 | 
             
                    rule %r/(\.)(#{id})/ do
         | 
| 59 59 | 
             
                      groups Operator, Name::Attribute
         | 
    
        data/lib/rouge/lexers/dot.rb
    CHANGED
    
    
    
        data/lib/rouge/lexers/ghc_cmm.rb
    CHANGED
    
    | @@ -22,7 +22,7 @@ module Rouge | |
| 22 22 | 
             
                  ws = %r(\s|//.*?\n|/[*](?:[^*]|(?:[*][^/]))*[*]+/)mx
         | 
| 23 23 |  | 
| 24 24 | 
             
                  # Make sure that this is not a preprocessor macro, e.g. `#if` or `#define`.
         | 
| 25 | 
            -
                  id = %r(( | 
| 25 | 
            +
                  id = %r((?!\#[a-zA-Z])[\w#\$%_']+)
         | 
| 26 26 |  | 
| 27 27 | 
             
                  complex_id = %r(
         | 
| 28 28 | 
             
                    (?:[\w#$%_']|\(\)|\(,\)|\[\]|[0-9])*
         | 
| @@ -177,6 +177,28 @@ module Rouge | |
| 177 177 | 
             
                      push :expr_start
         | 
| 178 178 | 
             
                    end
         | 
| 179 179 |  | 
| 180 | 
            +
                    rule %r/(class)((?:\s|\\\s)+)/ do
         | 
| 181 | 
            +
                      groups Keyword::Declaration, Text
         | 
| 182 | 
            +
                      push :classname
         | 
| 183 | 
            +
                    end
         | 
| 184 | 
            +
             | 
| 185 | 
            +
                    rule %r/([\p{Nl}$_]*\p{Lu}[\p{Word}]*)[ \t]*(?=(\(.*\)))/m, Name::Class
         | 
| 186 | 
            +
             | 
| 187 | 
            +
                    rule %r/(function)((?:\s|\\\s)+)(#{id})/ do
         | 
| 188 | 
            +
                      groups Keyword::Declaration, Text, Name::Function
         | 
| 189 | 
            +
                    end
         | 
| 190 | 
            +
             | 
| 191 | 
            +
                    rule %r/function(?=(\(.*\)))/, Keyword::Declaration # For anonymous functions
         | 
| 192 | 
            +
             | 
| 193 | 
            +
                    rule %r/(#{id})[ \t]*(?=(\(.*\)))/m do |m|
         | 
| 194 | 
            +
                      if self.class.keywords.include? m[1]
         | 
| 195 | 
            +
                        # "if" in "if (...)" or "switch" in "switch (...)" are recognized as keywords.
         | 
| 196 | 
            +
                        token Keyword
         | 
| 197 | 
            +
                      else
         | 
| 198 | 
            +
                        token Name::Function
         | 
| 199 | 
            +
                      end
         | 
| 200 | 
            +
                    end
         | 
| 201 | 
            +
             | 
| 180 202 | 
             
                    rule %r/[{}]/, Punctuation, :statement
         | 
| 181 203 |  | 
| 182 204 | 
             
                    rule id do |m|
         | 
| @@ -220,6 +242,14 @@ module Rouge | |
| 220 242 | 
             
                    rule %r/'/, Str::Delimiter, :pop!
         | 
| 221 243 | 
             
                  end
         | 
| 222 244 |  | 
| 245 | 
            +
                  state :classname do
         | 
| 246 | 
            +
                    rule %r/(#{id})((?:\s|\\\s)+)(extends)((?:\s|\\\s)+)/ do
         | 
| 247 | 
            +
                      groups Name::Class, Text, Keyword::Declaration, Text
         | 
| 248 | 
            +
                    end
         | 
| 249 | 
            +
             | 
| 250 | 
            +
                    rule id, Name::Class, :pop!
         | 
| 251 | 
            +
                  end
         | 
| 252 | 
            +
             | 
| 223 253 | 
             
                  # braced parts that aren't object literals
         | 
| 224 254 | 
             
                  state :statement do
         | 
| 225 255 | 
             
                    rule %r/case\b/ do
         | 
    
        data/lib/rouge/lexers/jinja.rb
    CHANGED
    
    | @@ -14,25 +14,25 @@ module Rouge | |
| 14 14 | 
             
                            'text/html+django', 'text/html+jinja'
         | 
| 15 15 |  | 
| 16 16 | 
             
                  def self.keywords
         | 
| 17 | 
            -
                     | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 17 | 
            +
                    @keywords ||= %w(as context do else extends from ignore missing
         | 
| 18 | 
            +
                                     import include reversed recursive scoped
         | 
| 19 | 
            +
                                     autoescape endautoescape block endblock call endcall
         | 
| 20 | 
            +
                                     filter endfilter for endfor if endif macro endmacro
         | 
| 21 | 
            +
                                     set endset trans endtrans with endwith without)
         | 
| 22 22 | 
             
                  end
         | 
| 23 23 |  | 
| 24 24 | 
             
                  def self.tests
         | 
| 25 | 
            -
                     | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 25 | 
            +
                    @tests ||= %w(callable defined divisibleby equalto escaped even iterable
         | 
| 26 | 
            +
                                  lower mapping none number odd sameas sequence string
         | 
| 27 | 
            +
                                  undefined upper)
         | 
| 28 28 | 
             
                  end
         | 
| 29 29 |  | 
| 30 30 | 
             
                  def self.pseudo_keywords
         | 
| 31 | 
            -
                     | 
| 31 | 
            +
                    @pseudo_keywords ||= %w(true false none True False None)
         | 
| 32 32 | 
             
                  end
         | 
| 33 33 |  | 
| 34 34 | 
             
                  def self.word_operators
         | 
| 35 | 
            -
                     | 
| 35 | 
            +
                    @word_operators ||= %w(is in and or not)
         | 
| 36 36 | 
             
                  end
         | 
| 37 37 |  | 
| 38 38 | 
             
                  state :root do
         |