Hello community, here is the log from the commit of package rubygem-rouge for openSUSE:Factory checked in at 2017-12-07 13:50:57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-rouge (Old) and /work/SRC/openSUSE:Factory/.rubygem-rouge.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-rouge" Thu Dec 7 13:50:57 2017 rev:7 rq:533347 version:3.0.0 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-rouge/rubygem-rouge.changes 2017-09-13 22:35:50.229132943 +0200 +++ /work/SRC/openSUSE:Factory/.rubygem-rouge.new/rubygem-rouge.changes 2017-12-07 13:50:58.531525016 +0100 @@ -1,0 +2,6 @@ +Wed Oct 11 06:16:11 UTC 2017 - co...@suse.com + +- updated to version 3.0.0 + no changelog found + +------------------------------------------------------------------- Old: ---- rouge-2.2.1.gem New: ---- rouge-3.0.0.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-rouge.spec ++++++ --- /var/tmp/diff_new_pack.5rix2d/_old 2017-12-07 13:50:59.159502145 +0100 +++ /var/tmp/diff_new_pack.5rix2d/_new 2017-12-07 13:50:59.163501999 +0100 @@ -24,13 +24,13 @@ # Name: rubygem-rouge -Version: 2.2.1 +Version: 3.0.0 Release: 0 %define mod_name rouge %define mod_full_name %{mod_name}-%{version} BuildRoot: %{_tmppath}/%{name}-%{version}-build +BuildRequires: %{ruby >= 2.0} BuildRequires: %{rubygem gem2rpm} -BuildRequires: %{ruby} BuildRequires: ruby-macros >= 5 BuildRequires: update-alternatives Url: http://rouge.jneen.net/ ++++++ rouge-2.2.1.gem -> rouge-3.0.0.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Gemfile new/Gemfile --- old/Gemfile 2017-08-22 03:21:26.000000000 +0200 +++ new/Gemfile 2017-09-22 03:09:40.000000000 +0200 @@ -3,12 +3,12 @@ gemspec gem 'bundler', '~> 1.15' -gem 'rake', '~> 12.0' +gem 'rake' -gem 'minitest', '~> 4.0' -gem 'wrong' +gem 'minitest', '>= 5.0' +gem 'minitest-power_assert' -gem 'rubocop', '~> 0.49.1' if RUBY_VERSION >= '2.0.0' +gem 'rubocop', '~> 0.49.1' # don't try to install redcarpet under jruby gem 'redcarpet', :platforms => :ruby Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/cli.rb new/lib/rouge/cli.rb --- old/lib/rouge/cli.rb 2017-08-22 03:21:26.000000000 +0200 +++ new/lib/rouge/cli.rb 2017-09-22 03:09:40.000000000 +0200 @@ -13,9 +13,9 @@ def file case input when '-' - IO.new($stdin.fileno, 'r:utf-8') + IO.new($stdin.fileno, 'rt:bom|utf-8') when String - File.new(input, 'r:utf-8') + File.new(input, 'rt:bom|utf-8') when ->(i){ i.respond_to? :read } input end @@ -44,6 +44,7 @@ yield %| help #{Help.desc}| yield %| style #{Style.desc}| yield %| list #{List.desc}| + yield %| guess #{Guess.desc}| yield %| version #{Version.desc}| yield %|| yield %|See `rougify help <command>` for more info.| @@ -97,6 +98,8 @@ Style when 'list' List + when 'guess' + Guess end end @@ -375,6 +378,37 @@ end end + class Guess < CLI + def self.desc + "guess the languages of file" + end + + def self.parse(args) + new(input_file: args.shift) + end + + attr_reader :input_file, :input_source + + def initialize(opts) + @input_file = opts[:input_file] || '-' + @input_source = FileReader.new(@input_file).read + end + + def lexers + Lexer.guesses( + filename: input_file, + source: input_source, + ) + end + + def run + lexers.each do |l| + puts "{ tag: #{l.tag.inspect}, title: #{l.title.inspect}, desc: #{l.desc.inspect} }" + end + end + end + + private_class_method def self.normalize_syntax(argv) out = [] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/guessers/disambiguation.rb new/lib/rouge/guessers/disambiguation.rb --- old/lib/rouge/guessers/disambiguation.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/rouge/guessers/disambiguation.rb 2017-09-22 03:09:40.000000000 +0200 @@ -0,0 +1,88 @@ +module Rouge + module Guessers + class Disambiguation < Guesser + include Util + include Lexers + + def initialize(filename, source) + @filename = File.basename(filename) + @source = source + end + + def filter(lexers) + return lexers if lexers.size == 1 + return lexers if lexers.size == Lexer.all.size + + @analyzer = TextAnalyzer.new(get_source(@source)) + + self.class.disambiguators.each do |disambiguator| + next unless disambiguator.match?(@filename) + + filtered = disambiguator.decide!(self) + return filtered if filtered + end + + return lexers + end + + def contains?(text) + return @analyzer.include?(text) + end + + def matches?(re) + return !!(@analyzer =~ re) + end + + @disambiguators = [] + def self.disambiguate(*patterns, &decider) + @disambiguators << Disambiguator.new(patterns, &decider) + end + + def self.disambiguators + @disambiguators + end + + class Disambiguator + include Util + + def initialize(patterns, &decider) + @patterns = patterns + @decider = decider + end + + def decide!(guesser) + out = guesser.instance_eval(&@decider) + case out + when Array then out + when nil then nil + else [out] + end + end + + def match?(filename) + @patterns.any? { |p| test_glob(p, filename) } + end + end + + disambiguate '*.pl' do + next Perl if contains?('my $') + next Prolog if contains?(':-') + next Prolog if matches?(/\A\w+(\(\w+\,\s*\w+\))*\./) + end + + disambiguate '*.h' do + next ObjectiveC if matches?(/@(end|implementation|protocol|property)\b/) + next ObjectiveC if contains?('@"') + + C + end + + disambiguate '*.m' do + next ObjectiveC if matches?(/@(end|implementation|protocol|property)\b/) + next ObjectiveC if contains?('@"') + + next Matlab if matches?(/^\s*?%/) + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/guessers/glob_mapping.rb new/lib/rouge/guessers/glob_mapping.rb --- old/lib/rouge/guessers/glob_mapping.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/guessers/glob_mapping.rb 2017-09-22 03:09:40.000000000 +0200 @@ -3,6 +3,8 @@ # This class allows for custom behavior # with glob -> lexer name mappings class GlobMapping < Guesser + include Util + def self.by_pairs(mapping, filename) glob_map = {} mapping.each do |(glob, lexer_name)| @@ -29,18 +31,13 @@ collect_best(lexers) do |lexer| score = (@glob_map[lexer.name] || []).map do |pattern| - if test_pattern(pattern, basename) + if test_glob(pattern, basename) # specificity is better the fewer wildcards there are -pattern.scan(/[*?\[]/).size end end.compact.min end end - - private - def test_pattern(pattern, path) - File.fnmatch?(pattern, path, File::FNM_DOTMATCH | File::FNM_CASEFOLD) - end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/guessers/modeline.rb new/lib/rouge/guessers/modeline.rb --- old/lib/rouge/guessers/modeline.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/guessers/modeline.rb 2017-09-22 03:09:40.000000000 +0200 @@ -1,6 +1,8 @@ module Rouge module Guessers class Modeline < Guesser + include Util + # [jneen] regexen stolen from linguist EMACS_MODELINE = /-\*-\s*(?:(?!mode)[\w-]+\s*:\s*(?:[\w+-]+)\s*;?\s*)*(?:mode\s*:)?\s*([\w+-]+)\s*(?:;\s*(?!mode)[\w-]+\s*:\s*[\w+-]+\s*)*;?\s*-\*-/i @@ -25,10 +27,9 @@ # don't bother reading the stream if we've already decided return lexers if lexers.size == 1 - source_text = @source - source_text = source_text.read if source_text.respond_to? :read + source_text = get_source(@source) - lines = source_text.split(/\r?\n/) + lines = source_text.split(/\n/) search_space = (lines.first(@lines) + lines.last(@lines)).join("\n") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/guessers/source.rb new/lib/rouge/guessers/source.rb --- old/lib/rouge/guessers/source.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/guessers/source.rb 2017-09-22 03:09:40.000000000 +0200 @@ -1,6 +1,8 @@ module Rouge module Guessers class Source < Guesser + include Util + attr_reader :source def initialize(source) @source = source @@ -11,27 +13,15 @@ # we've already filtered to 1 return lexers if lexers.size == 1 - # If we're filtering against *all* lexers, we only use confident return - # values from analyze_text. But if we've filtered down already, we can trust - # the analysis more. - threshold = lexers.size < 10 ? 0 : 0.5 - - source_text = case @source - when String - @source - when ->(s){ s.respond_to? :read } - @source.read - else - raise 'invalid source' - end + source_text = get_source(@source) Lexer.assert_utf8!(source_text) source_text = TextAnalyzer.new(source_text) - collect_best(lexers, threshold: threshold) do |lexer| - next unless lexer.methods(false).include? :analyze_text - lexer.analyze_text(source_text) + collect_best(lexers) do |lexer| + next unless lexer.methods(false).include? :detect? + lexer.detect?(source_text) ? 1 : nil end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/guessers/util.rb new/lib/rouge/guessers/util.rb --- old/lib/rouge/guessers/util.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/rouge/guessers/util.rb 2017-09-22 03:09:40.000000000 +0200 @@ -0,0 +1,32 @@ +module Rouge + module Guessers + module Util + module SourceNormalizer + UTF8_BOM = "\xEF\xBB\xBF" + UTF8_BOM_RE = /\A#{UTF8_BOM}/ + + # @param [String,nil] source + # @return [String,nil] + def self.normalize(source) + source.sub(UTF8_BOM_RE, '').gsub(/\r\n/, "\n") + end + end + + def test_glob(pattern, path) + File.fnmatch?(pattern, path, File::FNM_DOTMATCH | File::FNM_CASEFOLD) + end + + # @param [String,IO] source + # @return [String] + def get_source(source) + if source.respond_to?(:to_str) + SourceNormalizer.normalize(source.to_str) + elsif source.respond_to?(:read) + SourceNormalizer.normalize(source.read) + else + raise ArgumentError, "Invalid source: #{source.inspect}" + end + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexer.rb new/lib/rouge/lexer.rb --- old/lib/rouge/lexer.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexer.rb 2017-09-22 03:09:40.000000000 +0200 @@ -22,7 +22,9 @@ new(opts).lex(stream, &b) end - # Given a string, return the correct lexer class. + # Given a name in string, return the correct lexer class. + # @param [String] name + # @return [Class<Rouge::Lexer>,nil] def find(name) registry[name.to_s] end @@ -42,6 +44,7 @@ # markdown lexer for highlighting internal code blocks. # def find_fancy(str, code=nil, additional_options={}) + if str && !str.include?('?') && str != 'guess' lexer_class = find(str) return lexer_class && lexer_class.new(additional_options) @@ -109,7 +112,7 @@ def demo(arg=:absent) return @demo = arg unless arg == :absent - @demo = File.read(demo_file, encoding: 'utf-8') + @demo = File.read(demo_file, mode: 'rt:bom|utf-8') end # @return a list of all lexers. @@ -133,6 +136,7 @@ guessers << Guessers::Filename.new(filename) if filename guessers << Guessers::Modeline.new(source) if source guessers << Guessers::Source.new(source) if source + guessers << Guessers::Disambiguation.new(filename, source) if source && filename Guesser.guess(guessers, Lexer.all) end @@ -147,16 +151,23 @@ # The source itself, which, if guessing by mimetype or filename # fails, will be searched for shebangs, <!DOCTYPE ...> tags, and # other hints. + # @param [Proc] fallback called if multiple lexers are detected. + # If omitted, Guesser::Ambiguous is raised. # - # @see Lexer.analyze_text + # @see Lexer.detect? # @see Lexer.guesses - def guess(info={}) + # @return [Class<Rouge::Lexer>] + def guess(info={}, &fallback) lexers = guesses(info) return Lexers::PlainText if lexers.empty? return lexers[0] if lexers.size == 1 - raise Guesser::Ambiguous.new(lexers) + if fallback + fallback.call(lexers) + else + raise Guesser::Ambiguous.new(lexers) + end end def guess_by_mimetype(mt) @@ -425,16 +436,14 @@ # @abstract # - # Return a number between 0 and 1 indicating the likelihood that - # the text given should be lexed with this lexer. The default - # implementation returns 0. Values under 0.5 will only be used - # to disambiguate filename or mimetype matches. + # Return true if there is an in-text indication (such as a shebang + # or DOCTYPE declaration) that this lexer should be used. # # @param [TextAnalyzer] text # the text to be analyzed, with a couple of handy methods on it, # like {TextAnalyzer#shebang?} and {TextAnalyzer#doctype?} - def self.analyze_text(text) - 0 + def self.detect?(text) + false end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/apiblueprint.rb new/lib/rouge/lexers/apiblueprint.rb --- old/lib/rouge/lexers/apiblueprint.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/apiblueprint.rb 2017-09-22 03:09:40.000000000 +0200 @@ -11,10 +11,6 @@ filenames '*.apib' mimetypes 'text/vnd.apiblueprint' - def self.analyze_text(text) - return 1 if text.start_with?('FORMAT: 1A\n') - end - prepend :root do # Metadata rule(/(\S+)(:\s*)(.*)$/) do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/awk.rb new/lib/rouge/lexers/awk.rb --- old/lib/rouge/lexers/awk.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/awk.rb 2017-09-22 03:09:40.000000000 +0200 @@ -10,8 +10,8 @@ filenames '*.awk' mimetypes 'application/x-awk' - def self.analyze_text(text) - return 1 if text.shebang?('awk') + def self.detect?(text) + return true if text.shebang?('awk') end id = /[$a-zA-Z_][a-zA-Z0-9_]*/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/biml.rb new/lib/rouge/lexers/biml.rb --- old/lib/rouge/lexers/biml.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/biml.rb 2017-09-22 03:09:40.000000000 +0200 @@ -8,8 +8,8 @@ tag 'biml' filenames '*.biml' - def self.analyze_text(text) - return 1 if text =~ /<\s*Biml\b/ + def self.detect?(text) + return true if text =~ /<\s*Biml\b/ end prepend :root do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/c.rb new/lib/rouge/lexers/c.rb --- old/lib/rouge/lexers/c.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/c.rb 2017-09-22 03:09:40.000000000 +0200 @@ -55,11 +55,6 @@ ) end - # high priority for filename matches - def self.analyze_text(*) - 0.3 - end - def self.builtins @builtins ||= [] end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/coffeescript.rb new/lib/rouge/lexers/coffeescript.rb --- old/lib/rouge/lexers/coffeescript.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/coffeescript.rb 2017-09-22 03:09:40.000000000 +0200 @@ -11,8 +11,8 @@ title "CoffeeScript" desc 'The Coffeescript programming language (coffeescript.org)' - def self.analyze_text(text) - return 1 if text.shebang? 'coffee' + def self.detect?(text) + return true if text.shebang? 'coffee' end def self.keywords diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/coq.rb new/lib/rouge/lexers/coq.rb --- old/lib/rouge/lexers/coq.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/coq.rb 2017-09-22 03:09:40.000000000 +0200 @@ -8,10 +8,6 @@ tag 'coq' mimetypes 'text/x-coq' - def self.analyze_text(text) - return 0.3 if text.include? "Require" - end - def self.gallina @gallina ||= Set.new %w( as fun if in let match then else return end Type Set Prop diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/diff.rb new/lib/rouge/lexers/diff.rb --- old/lib/rouge/lexers/diff.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/diff.rb 2017-09-22 03:09:40.000000000 +0200 @@ -9,10 +9,10 @@ filenames '*.diff', '*.patch' mimetypes 'text/x-diff', 'text/x-patch' - def self.analyze_text(text) - return 1 if text.start_with?('Index: ') - return 1 if text.start_with?('diff ') - return 0.9 if text.start_with?('--- ') + def self.detect?(text) + return true if text.start_with?('Index: ') + return true if text =~ %r(\Adiff[^\n]*?\ba/[^\n]*\bb/) + return true if text =~ /(---|[+][+][+]).*?\n(---|[+][+][+])/ end state :root do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/digdag.rb new/lib/rouge/lexers/digdag.rb --- old/lib/rouge/lexers/digdag.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/digdag.rb 2017-09-22 03:09:40.000000000 +0200 @@ -11,10 +11,6 @@ mimetypes 'application/x-digdag' - def self.analyze_text(text) - # disable YAML.analyze_text - end - # http://docs.digdag.io/operators.html # as of digdag v0.9.10 KEYWORD_PATTERN = Regexp.union(%w( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/erb.rb new/lib/rouge/lexers/erb.rb --- old/lib/rouge/lexers/erb.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/erb.rb 2017-09-22 03:09:40.000000000 +0200 @@ -11,10 +11,6 @@ filenames '*.erb', '*.erubis', '*.rhtml', '*.eruby' - def self.analyze_text(text) - return 0.4 if text =~ /<%.*%>/ - end - def initialize(opts={}) @ruby_lexer = Ruby.new(opts) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/erlang.rb new/lib/rouge/lexers/erlang.rb --- old/lib/rouge/lexers/erlang.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/erlang.rb 2017-09-22 03:09:40.000000000 +0200 @@ -11,10 +11,6 @@ mimetypes 'text/x-erlang', 'application/x-erlang' - def self.analyze_text(text) - return 0.3 if text =~ /^-module[(]\w+[)][.]/ - end - keywords = %w( after begin case catch cond end fun if let of query receive try when diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/factor.rb new/lib/rouge/lexers/factor.rb --- old/lib/rouge/lexers/factor.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/factor.rb 2017-09-22 03:09:40.000000000 +0200 @@ -9,8 +9,8 @@ filenames '*.factor' mimetypes 'text/x-factor' - def self.analyze_text(text) - return 1 if text.shebang? 'factor' + def self.detect?(text) + return true if text.shebang? 'factor' end def self.builtins diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/gherkin.rb new/lib/rouge/lexers/gherkin.rb --- old/lib/rouge/lexers/gherkin.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/gherkin.rb 2017-09-22 03:09:40.000000000 +0200 @@ -12,8 +12,8 @@ filenames '*.feature' mimetypes 'text/x-gherkin' - def self.analyze_text(text) - return 1 if text.shebang? 'cucumber' + def self.detect?(text) + return true if text.shebang? 'cucumber' end # self-modifying method that loads the keywords file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/go.rb new/lib/rouge/lexers/go.rb --- old/lib/rouge/lexers/go.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/go.rb 2017-09-22 03:09:40.000000000 +0200 @@ -11,10 +11,6 @@ mimetypes 'text/x-go', 'application/x-go' - def self.analyze_text(text) - return 0 - end - # Characters WHITE_SPACE = /[\s\t\r\n]+/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/groovy.rb new/lib/rouge/lexers/groovy.rb --- old/lib/rouge/lexers/groovy.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/groovy.rb 2017-09-22 03:09:40.000000000 +0200 @@ -11,8 +11,8 @@ ws = %r((?:\s|//.*?\n|/[*].*?[*]/)+) - def self.analyze_text(text) - return 1 if text.shebang?(/groovy/) + def self.detect?(text) + return true if text.shebang?(/groovy/) end def self.keywords diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/haml.rb new/lib/rouge/lexers/haml.rb --- old/lib/rouge/lexers/haml.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/haml.rb 2017-09-22 03:09:40.000000000 +0200 @@ -16,10 +16,6 @@ filenames '*.haml' mimetypes 'text/x-haml' - def self.analyze_text(text) - return 0.1 if text.start_with? '!!!' - end - option 'filters[filter_name]', 'Mapping of lexers to use for haml :filters' attr_reader :filters # @option opts :filters diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/haskell.rb new/lib/rouge/lexers/haskell.rb --- old/lib/rouge/lexers/haskell.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/haskell.rb 2017-09-22 03:09:40.000000000 +0200 @@ -11,8 +11,8 @@ filenames '*.hs' mimetypes 'text/x-haskell' - def self.analyze_text(text) - return 1 if text.shebang?('runhaskell') + def self.detect?(text) + return true if text.shebang?('runhaskell') end reserved = %w( @@ -148,7 +148,7 @@ state :character do rule /\\/ do token Str::Escape - push :character_end + goto :character_end push :escape end @@ -174,7 +174,7 @@ rule /\^[\]\[A-Z@\^_]/, Str::Escape, :pop! rule /#{ascii.join('|')}/, Str::Escape, :pop! rule /o[0-7]+/i, Str::Escape, :pop! - rule /x[\da-f]/i, Str::Escape, :pop! + rule /x[\da-f]+/i, Str::Escape, :pop! rule /\d+/, Str::Escape, :pop! rule /\s+\\/, Str::Escape, :pop! end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/html.rb new/lib/rouge/lexers/html.rb --- old/lib/rouge/lexers/html.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/html.rb 2017-09-22 03:09:40.000000000 +0200 @@ -9,9 +9,9 @@ filenames '*.htm', '*.html', '*.xhtml' mimetypes 'text/html', 'application/xhtml+xml' - def self.analyze_text(text) - return 1 if text.doctype?(/\bhtml\b/i) - return 1 if text =~ /<\s*html\b/ + def self.detect?(text) + return true if text.doctype?(/\bhtml\b/i) + return true if text =~ /<\s*html\b/ end start do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/idlang.rb new/lib/rouge/lexers/idlang.rb --- old/lib/rouge/lexers/idlang.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/idlang.rb 2017-09-22 03:09:40.000000000 +0200 @@ -10,12 +10,6 @@ tag 'idlang' filenames '*.idl' - def self.analyze_text(text) - # Does there exist a statement that starts with 'pro' or - # 'function'? - return 0.4 if text =~ /^\s+(pro|function)\z/ - end - name = /[_A-Z]\w*/i kind_param = /(\d+|#{name})/ exponent = /[dDeE][+-]\d+/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/ini.rb new/lib/rouge/lexers/ini.rb --- old/lib/rouge/lexers/ini.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/ini.rb 2017-09-22 03:09:40.000000000 +0200 @@ -11,10 +11,6 @@ filenames '*.ini', '*.INI', '*.gitconfig' mimetypes 'text/x-ini' - def self.analyze_text(text) - return 0.1 if text =~ /\A\[[\w\-.]+\]\s*[\w\-]+=\w+/ - end - identifier = /[\w\-.]+/ state :basic do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/io.rb new/lib/rouge/lexers/io.rb --- old/lib/rouge/lexers/io.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/io.rb 2017-09-22 03:09:40.000000000 +0200 @@ -9,8 +9,8 @@ mimetypes 'text/x-iosrc' filenames '*.io' - def self.analyze_text(text) - return 1 if text.shebang? 'io' + def self.detect?(text) + return true if text.shebang? 'io' end def self.constants diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/javascript.rb new/lib/rouge/lexers/javascript.rb --- old/lib/rouge/lexers/javascript.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/javascript.rb 2017-09-22 03:09:40.000000000 +0200 @@ -18,7 +18,7 @@ mimetypes 'application/javascript', 'application/x-javascript', 'text/javascript', 'text/x-javascript' - def self.analyze_text(text) + def self.detect?(text) return 1 if text.shebang?('node') return 1 if text.shebang?('jsc') # TODO: rhino, spidermonkey, etc diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/julia.rb new/lib/rouge/lexers/julia.rb --- old/lib/rouge/lexers/julia.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/julia.rb 2017-09-22 03:09:40.000000000 +0200 @@ -10,8 +10,8 @@ filenames '*.jl' mimetypes 'text/x-julia', 'application/x-julia' - def self.analyze_text(text) - 1 if text.shebang? 'julia' + def self.detect?(text) + return true if text.shebang? 'julia' end BUILTINS = /\b(?: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/kotlin.rb new/lib/rouge/lexers/kotlin.rb --- old/lib/rouge/lexers/kotlin.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/kotlin.rb 2017-09-22 03:09:40.000000000 +0200 @@ -3,8 +3,10 @@ module Rouge module Lexers class Kotlin < RegexLexer + # https://kotlinlang.org/docs/reference/grammar.html + title "Kotlin" - desc "Kotlin <http://kotlinlang.org>" + desc "Kotlin Programming Language (http://kotlinlang.org)" tag 'kotlin' filenames '*.kt' @@ -41,26 +43,23 @@ rule %r'"(\\\\|\\"|[^"\n])*["\n]'m, Str rule %r"'\\.'|'[^\\]'", Str::Char rule %r"[0-9](\.[0-9]+)?([eE][+-][0-9]+)?[flFL]?|0[xX][0-9a-fA-F]+[Ll]?", Num - rule %r'(companion)(\s+)(object)' do + rule %r'\b(companion)(\s+)(object)\b' do groups Keyword, Text, Keyword end - rule %r'(class|data\s+class|interface|object)(\s+)' do + rule %r'\b(class|data\s+class|interface|object)(\s+)' do groups Keyword::Declaration, Text push :class end - rule %r'(package|import)(\s+)' do + rule %r'\b(package|import)(\s+)' do groups Keyword, Text push :package end - rule %r'(val|var)(\s+)' do + rule %r'\b(val|var)(\s+)' do groups Keyword::Declaration, Text push :property end - rule %r'(fun)(\s+)' do - groups Keyword, Text - push :function - end - rule /(?:#{keywords.join('|')})\b/, Keyword + rule %r/\bfun\b/, Keyword + rule /\b(?:#{keywords.join('|')})\b/, Keyword rule id, Name end @@ -75,10 +74,6 @@ state :property do rule id, Name::Property, :pop! end - - state :function do - rule id, Name::Function, :pop! - end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/lasso.rb new/lib/rouge/lexers/lasso.rb --- old/lib/rouge/lexers/lasso.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/lasso.rb 2017-09-22 03:09:40.000000000 +0200 @@ -14,12 +14,9 @@ option :start_inline, 'Whether to start inline instead of requiring <?lasso or [' - def self.analyze_text(text) - rv = 0.0 - rv += 1 if text.shebang?('lasso9') - rv += 0.4 if text =~ /<\?(lasso(script)?|=)|no_square_brackets|noprocess/i - rv += 0.2 if text =~ /define(_tag|_type|\s)/i - return rv + def self.detect?(text) + return true if text.shebang?('lasso9') + return true if text =~ /\A.*?<\?(lasso(script)?|=)/ end def initialize(*) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/llvm.rb new/lib/rouge/lexers/llvm.rb --- old/lib/rouge/lexers/llvm.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/llvm.rb 2017-09-22 03:09:40.000000000 +0200 @@ -10,10 +10,6 @@ filenames '*.ll' mimetypes 'text/x-llvm' - def self.analyze_text(text) - return 0.1 if text =~ /\A%\w+\s=\s/ - end - string = /"[^"]*?"/ identifier = /([-a-zA-Z$._][-a-zA-Z$._0-9]*|#{string})/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/lua.rb new/lib/rouge/lexers/lua.rb --- old/lib/rouge/lexers/lua.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/lua.rb 2017-09-22 03:09:40.000000000 +0200 @@ -19,8 +19,8 @@ super(opts) end - def self.analyze_text(text) - return 1 if text.shebang? 'lua' + def self.detect?(text) + return true if text.shebang? 'lua' end def self.builtins diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/make.rb new/lib/rouge/lexers/make.rb --- old/lib/rouge/lexers/make.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/make.rb 2017-09-22 03:09:40.000000000 +0200 @@ -10,10 +10,6 @@ filenames '*.make', 'Makefile', 'makefile', 'Makefile.*', 'GNUmakefile' mimetypes 'text/x-makefile' - def self.analyze_text(text) - return 0.6 if text =~ /^\.PHONY:/ - end - bsd_special = %w( include undef error warning if else elif endif for endfor ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/matlab.rb new/lib/rouge/lexers/matlab.rb --- old/lib/rouge/lexers/matlab.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/matlab.rb 2017-09-22 03:09:40.000000000 +0200 @@ -10,10 +10,6 @@ filenames '*.m' mimetypes 'text/x-matlab', 'application/x-matlab' - def self.analyze_text(text) - return 0.4 if text =~ /^\s*% / # % comments are a dead giveaway - end - def self.keywords @keywords = Set.new %w( break case catch classdef continue else elseif end for function diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/moonscript.rb new/lib/rouge/lexers/moonscript.rb --- old/lib/rouge/lexers/moonscript.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/moonscript.rb 2017-09-22 03:09:40.000000000 +0200 @@ -22,8 +22,8 @@ @disabled_modules = list_option(:disabled_modules) end - def self.analyze_text(text) - return 1 if text.shebang? 'moon' + def self.detect?(text) + return true if text.shebang? 'moon' end def builtins diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/mosel.rb new/lib/rouge/lexers/mosel.rb --- old/lib/rouge/lexers/mosel.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/mosel.rb 2017-09-22 03:09:40.000000000 +0200 @@ -11,9 +11,9 @@ filenames '*.mos' mimetypes 'text/x-mosel' - - def self.analyze_text(text) - return 1 if text =~ /^\s*(model|package)\s+/ + + def self.detect?(text) + return true if text =~ /^\s*(model|package)\s+/ end id = /[a-zA-Z_][a-zA-Z0-9_]*/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/nasm.rb new/lib/rouge/lexers/nasm.rb --- old/lib/rouge/lexers/nasm.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/nasm.rb 2017-09-22 03:09:40.000000000 +0200 @@ -106,11 +106,6 @@ ) end - # high priority for filename matches - def self.analyze_text(*) - 0.3 - end - def self.builtins @builtins ||= [] end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/objective_c.rb new/lib/rouge/lexers/objective_c.rb --- old/lib/rouge/lexers/objective_c.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/objective_c.rb 2017-09-22 03:09:40.000000000 +0200 @@ -29,20 +29,6 @@ @builtins ||= %w(YES NO nil) end - def self.analyze_text(text) - return 1 if text =~ /@(end|implementation|protocol|property)\b/ - - id = /[a-z$_][a-z0-9$_]*/i - return 0.4 if text =~ %r( - \[ \s* #{id} \s+ - (?: - #{id} \s* \] - | #{id}? : - ) - )x - return 0.4 if text.include? '@"' - end - id = /[a-z$_][a-z0-9$_]*/i prepend :statements do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/perl.rb new/lib/rouge/lexers/perl.rb --- old/lib/rouge/lexers/perl.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/perl.rb 2017-09-22 03:09:40.000000000 +0200 @@ -12,9 +12,8 @@ filenames '*.pl', '*.pm' mimetypes 'text/x-perl', 'application/x-perl' - def self.analyze_text(text) - return 1 if text.shebang? 'perl' - return 0.4 if text.include? 'my $' + def self.detect?(text) + return true if text.shebang? 'perl' end keywords = %w( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/php.rb new/lib/rouge/lexers/php.rb --- old/lib/rouge/lexers/php.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/php.rb 2017-09-22 03:09:40.000000000 +0200 @@ -75,10 +75,8 @@ ) end - def self.analyze_text(text) - return 1 if text.shebang?('php') - return 0.3 if /<\?(?!xml)/ =~ text - 0 + def self.detect?(text) + return true if text.shebang?('php') end state :root do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/plist.rb new/lib/rouge/lexers/plist.rb --- old/lib/rouge/lexers/plist.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/plist.rb 2017-09-22 03:09:40.000000000 +0200 @@ -8,10 +8,6 @@ mimetypes 'text/x-plist', 'application/x-plist' - def self.analyze_text(text) - return 0.6 if text.start_with?("// !$*UTF8*$!") - end - state :whitespace do rule /\s+/, Text::Whitespace end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/praat.rb new/lib/rouge/lexers/praat.rb --- old/lib/rouge/lexers/praat.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/praat.rb 2017-09-22 03:09:40.000000000 +0200 @@ -10,8 +10,8 @@ filenames '*.praat', '*.proc', '*.psc' - def self.analyze_text(text) - return 1 if text.shebang? 'praat' + def self.detect?(text) + return true if text.shebang? 'praat' end keywords = %w( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/prolog.rb new/lib/rouge/lexers/prolog.rb --- old/lib/rouge/lexers/prolog.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/prolog.rb 2017-09-22 03:09:40.000000000 +0200 @@ -10,11 +10,6 @@ filenames '*.pro', '*.P', '*.prolog', '*.pl' mimetypes 'text/x-prolog' - def self.analyze_text(text) - return 0.1 if text =~ /\A\w+(\(\w+\,\s*\w+\))*\./ - return 0.1 if text.include? ':-' - end - state :basic do rule /\s+/, Text rule /^#.*/, Comment::Single diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/properties.rb new/lib/rouge/lexers/properties.rb --- old/lib/rouge/lexers/properties.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/properties.rb 2017-09-22 03:09:40.000000000 +0200 @@ -10,10 +10,6 @@ filenames '*.properties' mimetypes 'text/x-java-properties' - def self.analyze_text(text) - return 0.1 if text =~ /\A\[[\w.-]+\]\s*\w+=\w+/ - end - identifier = /[\w.-]+/ state :basic do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/puppet.rb new/lib/rouge/lexers/puppet.rb --- old/lib/rouge/lexers/puppet.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/puppet.rb 2017-09-22 03:09:40.000000000 +0200 @@ -9,9 +9,9 @@ aliases 'pp' filenames '*.pp' - def self.analyze_text(text) - return 1 if text.shebang? 'puppet-apply' - return 1 if text.shebang? 'puppet' + def self.detect?(text) + return true if text.shebang? 'puppet-apply' + return true if text.shebang? 'puppet' end def self.keywords diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/python.rb new/lib/rouge/lexers/python.rb --- old/lib/rouge/lexers/python.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/python.rb 2017-09-22 03:09:40.000000000 +0200 @@ -10,8 +10,8 @@ filenames '*.py', '*.pyw', '*.sc', 'SConstruct', 'SConscript', '*.tac' mimetypes 'text/x-python', 'application/x-python' - def self.analyze_text(text) - return 1 if text.shebang?(/pythonw?(3|2(\.\d)?)?/) + def self.detect?(text) + return true if text.shebang?(/pythonw?(3|2(\.\d)?)?/) end def self.keywords diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/q.rb new/lib/rouge/lexers/q.rb --- old/lib/rouge/lexers/q.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/q.rb 2017-09-22 03:09:40.000000000 +0200 @@ -32,10 +32,6 @@ ] end - def self.analyze_text(text) - return 0 - end - state :root do # q allows a file to start with a shebang rule /#!(.*?)$/, Comment::Preproc, :top diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/r.rb new/lib/rouge/lexers/r.rb --- old/lib/rouge/lexers/r.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/r.rb 2017-09-22 03:09:40.000000000 +0200 @@ -43,8 +43,8 @@ trigamma trunc unclass untracemem UseMethod xtfrm ) - def self.analyze_text(text) - return 1 if text.shebang? 'Rscript' + def self.detect?(text) + return true if text.shebang? 'Rscript' end state :root do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/racket.rb new/lib/rouge/lexers/racket.rb --- old/lib/rouge/lexers/racket.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/racket.rb 2017-09-22 03:09:40.000000000 +0200 @@ -9,10 +9,11 @@ filenames '*.rkt', '*.rktd', '*.rktl' mimetypes 'text/x-racket', 'application/x-racket' - def self.analyze_text(text) - text = text.strip - return 1 if text.start_with? '#lang racket' - return 0.6 if text =~ %r(\A#lang [a-z/-]+$)i + def self.detect?(text) + text =~ /\A#lang\s*(.*?)$/ + lang_attr = $1 + return false unless lang_attr + return true if lang_attr =~ /racket|scribble/ end def self.keywords diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/ruby.rb new/lib/rouge/lexers/ruby.rb --- old/lib/rouge/lexers/ruby.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/ruby.rb 2017-09-22 03:09:40.000000000 +0200 @@ -13,8 +13,8 @@ mimetypes 'text/x-ruby', 'application/x-ruby' - def self.analyze_text(text) - return 1 if text.shebang? 'ruby' + def self.detect?(text) + return true if text.shebang? 'ruby' end state :symbols do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/rust.rb new/lib/rouge/lexers/rust.rb --- old/lib/rouge/lexers/rust.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/rust.rb 2017-09-22 03:09:40.000000000 +0200 @@ -10,8 +10,8 @@ filenames '*.rs' mimetypes 'text/x-rust' - def self.analyze_text(text) - return 1 if text.shebang? 'rustc' + def self.detect?(text) + return true if text.shebang? 'rustc' end def self.keywords diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/sed.rb new/lib/rouge/lexers/sed.rb --- old/lib/rouge/lexers/sed.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/sed.rb 2017-09-22 03:09:40.000000000 +0200 @@ -10,8 +10,8 @@ filenames '*.sed' mimetypes 'text/x-sed' - def self.analyze_text(text) - return 1 if text.shebang? 'sed' + def self.detect?(text) + return true if text.shebang? 'sed' end class Regex < RegexLexer diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/shell.rb new/lib/rouge/lexers/shell.rb --- old/lib/rouge/lexers/shell.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/shell.rb 2017-09-22 03:09:40.000000000 +0200 @@ -13,8 +13,8 @@ mimetypes 'application/x-sh', 'application/x-shellscript' - def self.analyze_text(text) - text.shebang?(/(ba|z|k)?sh/) ? 1 : 0 + def self.detect?(text) + return true if text.shebang?(/(ba|z|k)?sh/) end KEYWORDS = %w( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/smarty.rb new/lib/rouge/lexers/smarty.rb --- old/lib/rouge/lexers/smarty.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/smarty.rb 2017-09-22 03:09:40.000000000 +0200 @@ -10,17 +10,6 @@ filenames '*.tpl', '*.smarty' mimetypes 'application/x-smarty', 'text/x-smarty' - def self.analyze_text(text) - rv = 0.0 - rv += 0.15 if text =~ /\{if\s+.*?\}.*?\{\/if\}/ - rv += 0.15 if text =~ /\{include\s+file=.*?\}/ - rv += 0.15 if text =~ /\{foreach\s+.*?\}.*?\{\/foreach\}/ - rv += 0.01 if text =~ /\{\$.*?\}/ - return rv - end - - - def self.builtins @builtins ||= %w( append assign block call capture config_load debug extends diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/sml.rb new/lib/rouge/lexers/sml.rb --- old/lib/rouge/lexers/sml.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/sml.rb 2017-09-22 03:09:40.000000000 +0200 @@ -28,10 +28,6 @@ id = /[\w']+/i symbol = %r([!%&$#/:<=>?@\\~`^|*+-]+) - def self.analyze_text(text) - return 0 - end - state :whitespace do rule /\s+/m, Text rule /[(][*]/, Comment, :comment diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/tap.rb new/lib/rouge/lexers/tap.rb --- old/lib/rouge/lexers/tap.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/tap.rb 2017-09-22 03:09:40.000000000 +0200 @@ -9,10 +9,6 @@ mimetypes 'text/x-tap', 'application/x-tap' - def self.analyze_text(text) - return 0 - end - state :root do # A TAP version may be specified. rule /^TAP version \d+\n/, Name::Namespace diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/tcl.rb new/lib/rouge/lexers/tcl.rb --- old/lib/rouge/lexers/tcl.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/tcl.rb 2017-09-22 03:09:40.000000000 +0200 @@ -9,10 +9,10 @@ filenames '*.tcl' mimetypes 'text/x-tcl', 'text/x-script.tcl', 'application/x-tcl' - def self.analyze_text(text) - return 1 if text.shebang? 'tclsh' - return 1 if text.shebang? 'wish' - return 1 if text.shebang? 'jimsh' + def self.detect?(text) + return true if text.shebang? 'tclsh' + return true if text.shebang? 'wish' + return true if text.shebang? 'jimsh' end KEYWORDS = %w( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/tex.rb new/lib/rouge/lexers/tex.rb --- old/lib/rouge/lexers/tex.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/tex.rb 2017-09-22 03:09:40.000000000 +0200 @@ -11,8 +11,8 @@ filenames '*.tex', '*.aux', '*.toc', '*.sty', '*.cls' mimetypes 'text/x-tex', 'text/x-latex' - def self.analyze_text(text) - return 1 if text =~ /\A\s*\\(documentclass|input|documentstyle|relax|ProvidesPackage|ProvidesClass)/ + def self.detect?(text) + return true if text =~ /\A\s*\\(documentclass|input|documentstyle|relax|ProvidesPackage|ProvidesClass)/ end command = /\\([a-z]+|\s+|.)/i diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/toml.rb new/lib/rouge/lexers/toml.rb --- old/lib/rouge/lexers/toml.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/toml.rb 2017-09-22 03:09:40.000000000 +0200 @@ -10,10 +10,6 @@ filenames '*.toml' mimetypes 'text/x-toml' - def self.analyze_text(text) - return 0.1 if text =~ /\A\[[\w.]+\]\s*\w+\s*=\s*("\w+")+/ - end - identifier = /[\w.\S]+/ state :basic do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/tulip.rb new/lib/rouge/lexers/tulip.rb --- old/lib/rouge/lexers/tulip.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/tulip.rb 2017-09-22 03:09:40.000000000 +0200 @@ -9,9 +9,8 @@ mimetypes 'text/x-tulip', 'application/x-tulip' - def self.analyze_text(text) - return 1 if text.shebang? 'tulip' - return 0 + def self.detect?(text) + return true if text.shebang? 'tulip' end id = /[a-z][\w-]*/i diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/turtle.rb new/lib/rouge/lexers/turtle.rb --- old/lib/rouge/lexers/turtle.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/turtle.rb 2017-09-22 03:09:40.000000000 +0200 @@ -12,29 +12,21 @@ 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 @@ -53,7 +45,7 @@ rule /\[/, Punctuation rule /\]/, Punctuation rule /\^\^/, Punctuation - + rule /<[^>]*>/, Name::Label rule /base\b/i, Keyword::Declaration @@ -65,7 +57,6 @@ rule /[^:;<>#\@"\(\).\[\]\{\} ]+:/, Name::Namespace rule /[^:;<>#\@"\(\).\[\]\{\} ]+/, Name - end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/vue.rb new/lib/rouge/lexers/vue.rb --- old/lib/rouge/lexers/vue.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/vue.rb 2017-09-22 03:09:41.000000000 +0200 @@ -15,10 +15,6 @@ @js = Javascript.new(options) end - def self.analyze_text(text) - return 0 - end - def lookup_lang(lang) case lang when 'html' then HTML diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/wollok.rb new/lib/rouge/lexers/wollok.rb --- old/lib/rouge/lexers/wollok.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/wollok.rb 2017-09-22 03:09:41.000000000 +0200 @@ -8,10 +8,6 @@ tag 'wollok' filenames *%w(*.wlk *.wtest *.wpgm) - def self.analyze_text(_text) - 0.3 - end - keywords = %w(new super return if else var const override constructor) entity_name = /[a-zA-Z][a-zA-Z0-9]*/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/xml.rb new/lib/rouge/lexers/xml.rb --- old/lib/rouge/lexers/xml.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/xml.rb 2017-09-22 03:09:41.000000000 +0200 @@ -15,12 +15,10 @@ application/atom+xml ) - def self.analyze_text(text) - return 0.9 if text.doctype? - return 0.8 if text =~ /\A<\?xml\b/ - start = text[0..1000] - return 0.6 if start =~ %r(<xml\b) - return 0.3 if start =~ %r(<.+?>.*?</.+?>)m + def self.detect?(text) + return false if text.doctype?(/html/) + return true if text =~ /\A<\?xml\b/ + return true if text.doctype? end state :root do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/lexers/yaml.rb new/lib/rouge/lexers/yaml.rb --- old/lib/rouge/lexers/yaml.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/lexers/yaml.rb 2017-09-22 03:09:41.000000000 +0200 @@ -10,9 +10,9 @@ aliases 'yml' filenames '*.yaml', '*.yml' - def self.analyze_text(text) + def self.detect?(text) # look for the %YAML directive - return 1 if text =~ /\A\s*%YAML/m + return true if text =~ /\A\s*%YAML/m end SPECIAL_VALUES = Regexp.union(%w(true false null)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge/version.rb new/lib/rouge/version.rb --- old/lib/rouge/version.rb 2017-08-22 03:21:27.000000000 +0200 +++ new/lib/rouge/version.rb 2017-09-22 03:09:41.000000000 +0200 @@ -2,6 +2,6 @@ module Rouge def self.version - "2.2.1" + "3.0.0" end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rouge.rb new/lib/rouge.rb --- old/lib/rouge.rb 2017-08-22 03:21:26.000000000 +0200 +++ new/lib/rouge.rb 2017-09-22 03:09:40.000000000 +0200 @@ -41,13 +41,6 @@ load load_dir.join('rouge/text_analyzer.rb') load load_dir.join('rouge/token.rb') -load load_dir.join('rouge/guesser.rb') -load load_dir.join('rouge/guessers/glob_mapping.rb') -load load_dir.join('rouge/guessers/modeline.rb') -load load_dir.join('rouge/guessers/filename.rb') -load load_dir.join('rouge/guessers/mimetype.rb') -load load_dir.join('rouge/guessers/source.rb') - load load_dir.join('rouge/lexer.rb') load load_dir.join('rouge/regex_lexer.rb') load load_dir.join('rouge/template_lexer.rb') @@ -57,6 +50,15 @@ Rouge::Lexers.load_lexer(Pathname.new(f).relative_path_from(lexers_dir).to_s) end +load load_dir.join('rouge/guesser.rb') +load load_dir.join('rouge/guessers/util.rb') +load load_dir.join('rouge/guessers/glob_mapping.rb') +load load_dir.join('rouge/guessers/modeline.rb') +load load_dir.join('rouge/guessers/filename.rb') +load load_dir.join('rouge/guessers/mimetype.rb') +load load_dir.join('rouge/guessers/source.rb') +load load_dir.join('rouge/guessers/disambiguation.rb') + load load_dir.join('rouge/formatter.rb') load load_dir.join('rouge/formatters/html.rb') load load_dir.join('rouge/formatters/html_table.rb') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2017-08-22 03:21:26.000000000 +0200 +++ new/metadata 2017-09-22 03:09:40.000000000 +0200 @@ -1,14 +1,14 @@ --- !ruby/object:Gem::Specification name: rouge version: !ruby/object:Gem::Version - version: 2.2.1 + version: 3.0.0 platform: ruby authors: - Jeanine Adkisson autorequire: bindir: bin cert_chain: [] -date: 2017-08-22 00:00:00.000000000 Z +date: 2017-09-22 00:00:00.000000000 Z dependencies: [] description: Rouge aims to a be a simple, easy-to-extend drop-in replacement for pygments. email: @@ -163,11 +163,13 @@ - lib/rouge/formatters/null.rb - lib/rouge/formatters/terminal256.rb - lib/rouge/guesser.rb +- lib/rouge/guessers/disambiguation.rb - lib/rouge/guessers/filename.rb - lib/rouge/guessers/glob_mapping.rb - lib/rouge/guessers/mimetype.rb - lib/rouge/guessers/modeline.rb - lib/rouge/guessers/source.rb +- lib/rouge/guessers/util.rb - lib/rouge/lexer.rb - lib/rouge/lexers/abap.rb - lib/rouge/lexers/actionscript.rb @@ -340,7 +342,7 @@ requirements: - - ">=" - !ruby/object:Gem::Version - version: '0' + version: '2.0' required_rubygems_version: !ruby/object:Gem::Requirement requirements: - - ">=" @@ -348,7 +350,7 @@ version: '0' requirements: [] rubyforge_project: rouge -rubygems_version: 2.6.11 +rubygems_version: 2.6.13 signing_key: specification_version: 4 summary: A pure-ruby colorizer based on pygments diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rouge.gemspec new/rouge.gemspec --- old/rouge.gemspec 2017-08-22 03:21:27.000000000 +0200 +++ new/rouge.gemspec 2017-09-22 03:09:41.000000000 +0200 @@ -15,4 +15,5 @@ s.files = Dir['Gemfile', 'LICENSE', 'rouge.gemspec', 'lib/**/*.rb', 'lib/**/*.yml', 'bin/rougify', 'lib/rouge/demos/*'] s.executables = %w(rougify) s.licenses = ['MIT', 'BSD-2-Clause'] + s.required_ruby_version = '>= 2.0' end