Sha256: 24fce1be92453f07db8e52ba3928855a5482e9bf474365a7fc16b37da65ade43

Contents?: true

Size: 1.56 KB

Versions: 14

Compression:

Stored size: 1.56 KB

Contents

# -*- coding: utf-8 -*- #

module Rouge
  module Lexers
    class Dot < RegexLexer
      title "DOT"
      desc "graph description language"

      tag 'dot'
      filenames '*.dot'
      mimetypes 'text/vnd.graphviz'

      start do
        @html = HTML.new(options)
      end

      state :comments_and_whitespace do
        rule /\s+/, Text
        rule %r(#.*?\n), Comment::Single
        rule %r(//.*?\n), Comment::Single
        rule %r(/(\\\n)?[*].*?[*](\\\n)?/)m, Comment::Multiline
      end

      state :html do
        rule /[^<>]+/ do
          delegate @html
        end
        rule /<.+?>/m do
          delegate @html
        end
        rule />/, Punctuation, :pop!
      end

      state :ID do
        rule /([a-zA-Z][a-zA-Z_0-9]*)(\s*)(=)/ do |m|
          token Name, m[1]
          token Text, m[2]
          token Punctuation, m[3]
        end
        rule /[a-zA-Z][a-zA-Z_0-9]*/, Name::Variable
        rule /([0-9]+)?\.[0-9]+/, Num::Float
        rule /[0-9]+/, Num::Integer
        rule /"(\\"|[^"])*"/, Str::Double
        rule /</ do
          token Punctuation
          @html.reset!
          push :html
        end
      end

      state :a_list do
        mixin :comments_and_whitespace
        mixin :ID
        rule /[=;,]/, Punctuation
        rule /\]/, Operator, :pop!
      end

      state :root do
        mixin :comments_and_whitespace
        rule /\b(strict|graph|digraph|subgraph|node|edge)\b/i, Keyword
        rule /[{};:=]/, Punctuation
        rule /-[->]/, Operator
        rule /\[/, Operator, :a_list
        mixin :ID
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 5 rubygems

Version Path
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/rouge-2.2.1/lib/rouge/lexers/dot.rb
rouge-3.2.1 lib/rouge/lexers/dot.rb
rouge-3.2.0 lib/rouge/lexers/dot.rb
rouge_ecl-1.0.0 lib/rouge/lexers/dot.rb
rouge_ecl-0.0.1 lib/rouge/lexers/dot.rb
rouge-3.1.1 lib/rouge/lexers/dot.rb
rouge-3.1.0 lib/rouge/lexers/dot.rb
rouge-3.0.0 lib/rouge/lexers/dot.rb
rouge-2.2.1 lib/rouge/lexers/dot.rb
rouge-2.2.0 lib/rouge/lexers/dot.rb
rougegal-2.1.2 lib/rouge/lexers/dot.rb
tdiary-5.0.5 vendor/bundle/gems/rouge-2.1.1/lib/rouge/lexers/dot.rb
rouge-2.1.1 lib/rouge/lexers/dot.rb
rouge-2.1.0 lib/rouge/lexers/dot.rb