/usr/lib/ruby/vendor_ruby/rugments/lexers/tex.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 | module Rugments
module Lexers
class TeX < RegexLexer
title 'TeX'
desc 'The TeX typesetting system'
tag 'tex'
aliases 'TeX', 'LaTeX', 'latex'
filenames '*.tex', '*.aux', '*.toc'
mimetypes 'text/x-tex', 'text/x-latex'
def self.analyze_text(text)
return 1 if text =~ /\A\s*\\documentclass/
return 1 if text =~ /\A\s*\\input/
return 1 if text =~ /\A\s*\\documentstyle/
return 1 if text =~ /\A\s*\\relax/
end
command = /\\([a-z]+|\s+|.)/i
state :general do
rule /%.*$/, Comment
rule /[{}&_^]/, Punctuation
end
state :root do
rule /\\\[/, Punctuation, :displaymath
rule /\\\(/, Punctuation, :inlinemath
rule /\$\$/, Punctuation, :displaymath
rule /\$/, Punctuation, :inlinemath
rule /\\(begin|end)\{.*?\}/, Name::Tag
rule /(\\verb)\b(\S)(.*?)(\2)/ do |_m|
groups Name::Builtin, Keyword::Pseudo, Str::Other, Keyword::Pseudo
end
rule command, Keyword, :command
mixin :general
rule /[^\\$%&_^{}]+/, Text
end
state :math do
rule command, Name::Variable
mixin :general
rule /[0-9]+/, Num
rule /[-=!+*\/()\[\]]/, Operator
rule /[^=!+*\/()\[\]\\$%&_^{}0-9-]+/, Name::Builtin
end
state :inlinemath do
rule /\\\)/, Punctuation, :pop!
rule /\$/, Punctuation, :pop!
mixin :math
end
state :displaymath do
rule /\\\]/, Punctuation, :pop!
rule /\$\$/, Punctuation, :pop!
rule /\$/, Name::Builtin
mixin :math
end
state :command do
rule /\[.*?\]/, Name::Attribute
rule /\*/, Keyword
rule(//) { pop! }
end
end
end
end
|