diff options
author | Jeffrey B. Arnold <jeffrey.arnold@gmail.com> | 2012-08-19 17:44:24 -0400 |
---|---|---|
committer | Jeffrey B. Arnold <jeffrey.arnold@gmail.com> | 2012-08-19 17:44:24 -0400 |
commit | ba903b2335e334b19b6bda69fd730f0c2beb5b0a (patch) | |
tree | b43a020ad421d159039d12ab0d40f5eef07f2de5 | |
parent | 66e5f39fd2817633090df4320ceaeb18da1efd55 (diff) | |
download | pygments-ba903b2335e334b19b6bda69fd730f0c2beb5b0a.tar.gz |
BugsLexer, JagsLexer, StanLexer: fixed filenames, added analyse_text functions
-rw-r--r-- | pygments/lexers/_mapping.py | 6 | ||||
-rw-r--r-- | pygments/lexers/math.py | 22 | ||||
-rw-r--r-- | tests/examplefiles/example.bug (renamed from tests/examplefiles/example.bugs) | 0 |
3 files changed, 23 insertions, 5 deletions
diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py index 7329f6c8..c8a224f9 100644 --- a/pygments/lexers/_mapping.py +++ b/pygments/lexers/_mapping.py @@ -43,7 +43,7 @@ LEXERS = { 'BooLexer': ('pygments.lexers.dotnet', 'Boo', ('boo',), ('*.boo',), ('text/x-boo',)), 'BrainfuckLexer': ('pygments.lexers.other', 'Brainfuck', ('brainfuck', 'bf'), ('*.bf', '*.b'), ('application/x-brainfuck',)), 'BroLexer': ('pygments.lexers.other', 'Bro', ('bro',), ('*.bro',), ()), - 'BugsLexer': ('pygments.lexers.math', 'BUGS', ('bugs', 'winbugs', 'openbugs'), ('*.bugs',), ()), + 'BugsLexer': ('pygments.lexers.math', 'BUGS', ('bugs', 'winbugs', 'openbugs'), ('*.bug',), ()), 'CLexer': ('pygments.lexers.compiled', 'C', ('c',), ('*.c', '*.h', '*.idc'), ('text/x-chdr', 'text/x-csrc')), 'CMakeLexer': ('pygments.lexers.text', 'CMake', ('cmake',), ('*.cmake', 'CMakeLists.txt'), ('text/x-cmake',)), 'CObjdumpLexer': ('pygments.lexers.asm', 'c-objdump', ('c-objdump',), ('*.c-objdump',), ('text/x-c-objdump',)), @@ -126,7 +126,7 @@ LEXERS = { 'IokeLexer': ('pygments.lexers.jvm', 'Ioke', ('ioke', 'ik'), ('*.ik',), ('text/x-iokesrc',)), 'IrcLogsLexer': ('pygments.lexers.text', 'IRC logs', ('irc',), ('*.weechatlog',), ('text/x-irclog',)), 'JadeLexer': ('pygments.lexers.web', 'Jade', ('jade', 'JADE'), ('*.jade',), ('text/x-jade',)), - 'JagsLexer': ('pygments.lexers.math', 'JAGS', ('jags',), ('*.jags',), ()), + 'JagsLexer': ('pygments.lexers.math', 'JAGS', ('jags',), ('*.bug', '*.jags'), ()), 'JavaLexer': ('pygments.lexers.jvm', 'Java', ('java',), ('*.java',), ('text/x-java',)), 'JavascriptDjangoLexer': ('pygments.lexers.templates', 'JavaScript+Django/Jinja', ('js+django', 'javascript+django', 'js+jinja', 'javascript+jinja'), (), ('application/x-javascript+django', 'application/x-javascript+jinja', 'text/x-javascript+django', 'text/x-javascript+jinja', 'text/javascript+django', 'text/javascript+jinja')), 'JavascriptErbLexer': ('pygments.lexers.templates', 'JavaScript+Ruby', ('js+erb', 'javascript+erb', 'js+ruby', 'javascript+ruby'), (), ('application/x-javascript+ruby', 'text/x-javascript+ruby', 'text/javascript+ruby')), @@ -225,7 +225,7 @@ LEXERS = { 'RubyConsoleLexer': ('pygments.lexers.agile', 'Ruby irb session', ('rbcon', 'irb'), (), ('text/x-ruby-shellsession',)), 'RubyLexer': ('pygments.lexers.agile', 'Ruby', ('rb', 'ruby', 'duby'), ('*.rb', '*.rbw', 'Rakefile', '*.rake', '*.gemspec', '*.rbx', '*.duby'), ('text/x-ruby', 'application/x-ruby')), 'RustLexer': ('pygments.lexers.compiled', 'Rust', ('rust',), ('*.rs', '*.rc'), ('text/x-rustsrc',)), - 'SLexer': ('pygments.lexers.math', 'S', ('splus', 's', 'r'), ('*.S', '*.R'), ('text/S-plus', 'text/S', 'text/R')), + 'SLexer': ('pygments.lexers.math', 'S', ('splus', 's', 'r'), ('*.S', '*.R', '.Rhistory', '.Rprofile'), ('text/S-plus', 'text/S', 'text/x-r-source', 'text/x-r', 'text/x-R', 'text/x-r-history', 'text/x-r-profile')), 'SMLLexer': ('pygments.lexers.functional', 'Standard ML', ('sml',), ('*.sml', '*.sig', '*.fun'), ('text/x-standardml', 'application/x-standardml')), 'SassLexer': ('pygments.lexers.web', 'Sass', ('sass', 'SASS'), ('*.sass',), ('text/x-sass',)), 'ScalaLexer': ('pygments.lexers.jvm', 'Scala', ('scala',), ('*.scala',), ('text/x-scala',)), diff --git a/pygments/lexers/math.py b/pygments/lexers/math.py index dd22e66e..658b346c 100644 --- a/pygments/lexers/math.py +++ b/pygments/lexers/math.py @@ -1096,7 +1096,7 @@ class BugsLexer(RegexLexer): name = 'BUGS' aliases = ['bugs', 'winbugs', 'openbugs'] - filenames = ['*.bugs'] + filenames = ['*.bug'] _FUNCTIONS = [ # Scalar functions @@ -1181,6 +1181,11 @@ class BugsLexer(RegexLexer): ] } + def analyse_text(text): + if re.match(r"^\s*model\s*{", text): + return 0.7 + else: + return 0 class JagsLexer(RegexLexer): """ @@ -1191,7 +1196,7 @@ class JagsLexer(RegexLexer): name = 'JAGS' aliases = ['jags'] - filenames = ['*.jags'] + filenames = ['*.bug', '*.jags'] ## JAGS _FUNCTIONS = [ @@ -1273,6 +1278,16 @@ class JagsLexer(RegexLexer): ] } + def analyse_text(text): + if re.search(r'^\s*model\s*\{', text, re.M): + if re.search(r'^\s*data\s*\{', text, re.M): + return 0.9 + elif re.search(r'^\s*var', text, re.M): + return 0.9 + else: + return 0.3 + else: + return 0 class StanLexer(RegexLexer): """ @@ -1387,3 +1402,6 @@ class StanLexer(RegexLexer): (r'}', Punctuation, '#pop'), ] } + + def analyse_text(text): + return re.match('^\s*\\parameters\s*\{', text) diff --git a/tests/examplefiles/example.bugs b/tests/examplefiles/example.bug index b5b2fe7f..b5b2fe7f 100644 --- a/tests/examplefiles/example.bugs +++ b/tests/examplefiles/example.bug |