Sha256: ebd99c2e5160eb8cbc1948372ea1d3c6d4b60978a0932b020cb17e2e4d9fd5da
Contents?: true
Size: 1.99 KB
Versions: 1
Compression:
Stored size: 1.99 KB
Contents
# -*- coding: utf-8 -*- # module Rouge module Lexers class Turtle < RegexLexer title "Turtle/TriG" desc "Terse RDF Triple Language, TriG" tag 'turtle' filenames *%w(*.ttl *.trig) mimetypes *%w( text/turtle application/trig ) def self.analyze_text(text) start = text[0..1000] return 0.5 if start =~ %r(@prefix\b) return 0.5 if start =~ %r(@base\b) return 0.4 if start =~ %r(PREFIX\b)i return 0.4 if start =~ %r(BASE\b)i end state :root do rule /@base\b/, Keyword::Declaration rule /@prefix\b/, Keyword::Declaration rule /true\b/, Keyword::Constant rule /false\b/, Keyword::Constant rule /""".*?"""/m, Literal::String rule /"([^"\\]|\\.)*"/, Literal::String rule /'''.*?'''/m, Literal::String rule /'([^'\\]|\\.)*'/, Literal::String rule /#.*$/, Comment::Single rule /@[^\s,.; ]+/, Name::Attribute rule /[+-]?[0-9]+\.[0-9]*E[+-]?[0-9]+/, Literal::Number::Float rule /[+-]?\.[0-9]+E[+-]?[0-9]+/, Literal::Number::Float rule /[+-]?[0-9]+E[+-]?[0-9]+/, Literal::Number::Float rule /[+-]?[0-9]*\.[0-9]+?/, Literal::Number::Float rule /[+-]?[0-9]+/, Literal::Number::Integer rule /\./, Punctuation rule /,/, Punctuation rule /;/, Punctuation rule /\(/, Punctuation rule /\)/, Punctuation rule /\{/, Punctuation rule /\}/, Punctuation rule /\[/, Punctuation rule /\]/, Punctuation rule /\^\^/, Punctuation rule /<[^>]*>/, Name::Label rule /base\b/i, Keyword::Declaration rule /prefix\b/i, Keyword::Declaration rule /GRAPH\b/, Keyword rule /a\b/, Keyword rule /\s+/, Text::Whitespace rule /[^:;<>#@"\(\).\[\]\{\} ]+:/, Name::Namespace rule /[^:;<>#@"\(\).\[\]\{\} ]+/, Name end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rouge-2.0.6 | lib/rouge/lexers/turtle.rb |