Sha256: 74e311d2e09c344364b2b976d041c24934e4203067e677f84e690b4e2ed35a2d
Contents?: true
Size: 1.75 KB
Versions: 4
Compression:
Stored size: 1.75 KB
Contents
# -*- coding: utf-8 -*- # # frozen_string_literal: true module Rouge module Lexers class TeX < RegexLexer title "TeX" desc "The TeX typesetting system" tag 'tex' aliases 'TeX', 'LaTeX', 'latex' filenames '*.tex', '*.aux', '*.toc', '*.sty', '*.cls' mimetypes 'text/x-tex', 'text/x-latex' def self.detect?(text) return true if text =~ /\A\s*\\(documentclass|input|documentstyle|relax|ProvidesPackage|ProvidesClass)/ 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
Version data entries
4 entries across 4 versions & 2 rubygems
Version | Path |
---|---|
rouge-3.4.1 | lib/rouge/lexers/tex.rb |
rouge-3.4.0 | lib/rouge/lexers/tex.rb |
rouge-alda-3.3.0 | lib/rouge/lexers/tex.rb |
rouge-3.3.0 | lib/rouge/lexers/tex.rb |