From a08f0da30d4147e1625130fe02ab9ad813704328 Mon Sep 17 00:00:00 2001 From: Paul Chaignon Date: Sat, 7 Feb 2015 19:58:49 +0100 Subject: [PATCH 1/4] Grammar for Mediawiki from TextMate bundle --- .gitmodules | 3 +++ grammars.yml | 2 ++ lib/linguist/languages.yml | 2 +- vendor/grammars/mediawiki.tmbundle | 1 + 4 files changed, 7 insertions(+), 1 deletion(-) create mode 160000 vendor/grammars/mediawiki.tmbundle diff --git a/.gitmodules b/.gitmodules index bb4871bd..73029e34 100644 --- a/.gitmodules +++ b/.gitmodules @@ -597,3 +597,6 @@ [submodule "vendor/grammars/InnoSetup"] path = vendor/grammars/InnoSetup url = https://github.com/idleberg/InnoSetup-Sublime-Text +[submodule "vendor/grammars/mediawiki.tmbundle"] + path = vendor/grammars/mediawiki.tmbundle + url = https://github.com/textmate/mediawiki.tmbundle diff --git a/grammars.yml b/grammars.yml index d7dd24de..b4a9c6e7 100644 --- a/grammars.yml +++ b/grammars.yml @@ -338,6 +338,8 @@ vendor/grammars/matlab.tmbundle: - source.octave vendor/grammars/maven.tmbundle: - text.xml.pom +vendor/grammars/mediawiki.tmbundle/: +- text.html.mediawiki vendor/grammars/mercury-tmlanguage: - source.mercury vendor/grammars/monkey.tmbundle: diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 28fdae5a..9b197fd3 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -1807,7 +1807,7 @@ MediaWiki: wrap: true extensions: - .mediawiki - tm_scope: none + tm_scope: text.html.mediawiki ace_mode: text Mercury: diff --git a/vendor/grammars/mediawiki.tmbundle b/vendor/grammars/mediawiki.tmbundle new file mode 160000 index 00000000..f8dead50 --- /dev/null +++ b/vendor/grammars/mediawiki.tmbundle @@ -0,0 +1 @@ +Subproject commit f8dead507a1aed539376b9fcfde877a855842e8e From 74cd03de0b4a0abd0b6a0d544f35b6b1a2c3dfe0 Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Mon, 9 Feb 2015 09:57:24 -0500 Subject: [PATCH 2/4] Remove old link in docs --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 31021753..026de664 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -33,7 +33,7 @@ Misclassifications can often be solved by either adding a new filename or extens Syntax highlighting in GitHub is performed using TextMate-compatible grammars. These are the same grammars that TextMate, Sublime Text and Atom use. Every language in [languages.yml][languages] is mapped to its corresponding TM `scope`. This scope will be used when picking up a grammar for highlighting. -Assuming your code is being detected as the right language (see [Language Detection](#language-detection) above), in most cases this is due to a bug in the language grammar rather than a bug in Linguist. [`grammars.yml`][grammars] lists all the grammars we use for syntax highlighting on github.com. Find the one corresponding to your code's programming language and submit a bug report upstream. If you can, try to reproduce the highlighting problem in the text editor that the grammar is designed for (TextMate, Sublime Text, or Atom) and include that information in your bug report. +Assuming your code is being detected as the right language, in most cases this is due to a bug in the language grammar rather than a bug in Linguist. [`grammars.yml`][grammars] lists all the grammars we use for syntax highlighting on github.com. Find the one corresponding to your code's programming language and submit a bug report upstream. If you can, try to reproduce the highlighting problem in the text editor that the grammar is designed for (TextMate, Sublime Text, or Atom) and include that information in your bug report. You can also try to fix the bug yourself and submit a Pull Request. [TextMate's documentation](http://manual.macromates.com/en/language_grammars) offers a good introduction on how to work with TextMate-compatible grammars. You can test grammars using [Lightshow](https://lightshow.githubapp.com). From bdc724d5485ea71ab81309f8732fca1416fe37b9 Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Mon, 9 Feb 2015 10:19:36 -0500 Subject: [PATCH 3/4] Detect "use 5.xxx" as Perl --- lib/linguist/heuristics.rb | 2 +- samples/Perl/use5.pl | 3 +++ test/test_heuristics.rb | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 samples/Perl/use5.pl diff --git a/lib/linguist/heuristics.rb b/lib/linguist/heuristics.rb index ee1a3625..a28b054a 100644 --- a/lib/linguist/heuristics.rb +++ b/lib/linguist/heuristics.rb @@ -92,7 +92,7 @@ module Linguist disambiguate "Perl", "Perl6", "Prolog" do |data| if data.include?("use v6") Language["Perl6"] - elsif data.include?("use strict") + elsif data.match(/use strict|use\s+v?5\./) Language["Perl"] elsif data.include?(":-") Language["Prolog"] diff --git a/samples/Perl/use5.pl b/samples/Perl/use5.pl new file mode 100644 index 00000000..de7d248c --- /dev/null +++ b/samples/Perl/use5.pl @@ -0,0 +1,3 @@ +use Mojolicious::Lite; +use 5.20.0; +use experimental 'signatures'; diff --git a/test/test_heuristics.rb b/test/test_heuristics.rb index 3ea4af78..02671b78 100644 --- a/test/test_heuristics.rb +++ b/test/test_heuristics.rb @@ -48,7 +48,7 @@ class TestHeuristcs < Minitest::Test def test_pl_prolog_perl_by_heuristics assert_heuristics({ "Prolog" => "Prolog/turing.pl", - "Perl" => "Perl/perl-test.t", + "Perl" => ["Perl/perl-test.t", "Perl/use5.pl"] }) end From 72acbc567bc2fc09b03efaa6240e16a8f95bc540 Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Mon, 9 Feb 2015 13:37:54 -0500 Subject: [PATCH 4/4] Update Lightshow's URL This is the public URL going forward. The old URL will redirect to the new one. --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 026de664..b1c8a09c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -35,7 +35,7 @@ Syntax highlighting in GitHub is performed using TextMate-compatible grammars. T Assuming your code is being detected as the right language, in most cases this is due to a bug in the language grammar rather than a bug in Linguist. [`grammars.yml`][grammars] lists all the grammars we use for syntax highlighting on github.com. Find the one corresponding to your code's programming language and submit a bug report upstream. If you can, try to reproduce the highlighting problem in the text editor that the grammar is designed for (TextMate, Sublime Text, or Atom) and include that information in your bug report. -You can also try to fix the bug yourself and submit a Pull Request. [TextMate's documentation](http://manual.macromates.com/en/language_grammars) offers a good introduction on how to work with TextMate-compatible grammars. You can test grammars using [Lightshow](https://lightshow.githubapp.com). +You can also try to fix the bug yourself and submit a Pull Request. [TextMate's documentation](http://manual.macromates.com/en/language_grammars) offers a good introduction on how to work with TextMate-compatible grammars. You can test grammars using [Lightshow](https://github-lightshow.herokuapp.com). Once the bug has been fixed upstream, please let us know and we'll pick it up for GitHub.