1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-02-09 13:23:51 +02:00

516 Commits

Author SHA1 Message Date
Alec Thomas
40b7a9135a Upgrade project to Go 1.19 and switch to alecthomas/assert/v2 2022-10-18 08:55:38 +11:00
Thomas Voss
b7c7bdbe65
Add a lexer for sed (#682) 2022-10-07 18:19:15 -07:00
Maxime Mangel
5559bcca67 Add support for F# open static class 2022-10-06 19:38:59 +11:00
mhmdanas
396f5726a4 fix: parse all of @foo.bar as a Python decorator 2022-10-06 11:23:23 +11:00
mhmdanas
750df9844d style: reformat Whiley expected testdata
Running `RECORD=true go test ./lexers` reformats this file for me.
2022-10-06 11:22:29 +11:00
smf007
d0d94c2169 Revise the fortran lexer to correctly flag whitespace for "DO CONCURRENT" and "GO TO", and to correctly flag the word boundary of keywords. 2022-10-06 11:16:01 +11:00
Jelle Hulter
c56819b5da
Fixed OpenEdgeABL String literals (#652)
When OpenEdge ABL runs on Windows, the tilde is used as an escape character instead of a backslash as in most common programming languages. On UNIX platforms, the backslash is also an escape character. But because we cannot know the running platform, it seems better to only use the tilde as a backslash character. (source: https://knowledgebase.progress.com/articles/Article/P27229)
2022-10-05 17:15:25 -07:00
KOBAYASHI Yū
65c601bb6f
Add HLSL language support (#675) 2022-10-05 17:12:32 -07:00
silverwind
1da7ff5150 Add .pylintrc to ini lexer
Reference: https://pylint.pycqa.org/en/latest/user_guide/usage/run.html#command-line-options
2022-10-06 09:07:06 +11:00
silverwind
9ac9b1158f
Add .mts,.cts to typescript lexer (#677)
See https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-7.html#new-file-extensions
2022-09-30 03:11:20 -07:00
Martin Winandy
a238967fc0
Improve properties file lexer (#671) 2022-09-07 16:34:23 -07:00
Martin Winandy
a531e40eee
Add lexer for properties files (#670) 2022-09-02 23:43:41 -07:00
exploide
e1a35d4eea transact-sql: added functions string_agg and concat_ws to lexer 2022-08-29 08:06:33 +10:00
Masahiro Mori
4fa270a0e5
Update GAS lexer (#661) 2022-08-22 03:29:10 -07:00
Koki Fukuda
cde381803a Update mcfunction lexer to support newer spec of commands 2022-08-19 18:28:50 +10:00
Ole Herman Schumacher Elgesem
6538430570 cfengine3: Removed rule attempting to highlight variable names
This rule is problematic for 2 reasons:
* The regex is buggy, it doesn't work for more advanced cases
  when there are other attributes before slist, or string, or
  whatever the type is.
* In the context of CFEngine policy language, it's just a bit
  confusing. Yes, they are variable names, but they are also
  quoted strings, and what we call promisers. It looks better,
  more consistent and less confusing if they are highlighted
  in the same way as other strings and promisers.

Signed-off-by: Ole Herman Schumacher Elgesem <ole.elgesem@northern.tech>
2022-08-13 07:20:32 +10:00
silverwind
111921a080 Add cjs to Javascript lexer
.cjs is used to indicate a CommonJS in Node.js and other tools
2022-07-30 09:57:55 +10:00
silverwind
96fe58e6b1
Add BSDmakefile to make lexer (#654) 2022-07-20 14:20:15 -07:00
silverwind
3b326bebb1 Add Dockerfile.* to docker lexer 2022-07-13 14:26:31 -07:00
Mubashshir
5ce1d5dd69 lexers: Add BIND DNS Zone lexer
Closes #623
Signed-off-by: Mubashshir <ahmubashshir@gmail.com>
2022-06-27 01:18:15 -07:00
Danila Fedorin
f941d464e2 Add Chapel Lexer 2022-06-23 10:53:42 +10:00
smf007
298b727472 Revise fortran fixed format lexer to recognize comments using the "!" mark in columns 1-5 and columns > 6. Remove incorrect "0" label being a comment. 2022-06-21 12:23:23 +10:00
smf007
9a038fbcb1 Revise fortran lexer to be consistent with the current version in pygments 2022-06-19 12:43:06 +10:00
Siavash Askari Nasr
806ca29650
Add V lexer (#640) 2022-06-04 06:00:44 -07:00
Derek Ellis
d13d611a2d Add value keyword for Kotlin 2022-05-20 22:04:24 -07:00
Maxime Mangel
7cc13cf232
Add support for F# package reference + Fix CommentPreproc detection (#631) 2022-04-27 03:01:16 +10:00
David Pearce
073a30b897
Add Whiley Lexer (#628)
This is a fairly simple lexer for Whiley which covers the main things (e.g.
keywords, literals, etc).
2022-04-22 17:16:30 +10:00
Patrice Chalin
d070b1cd8d Fix for C# identifiers with leading underscores 2022-04-22 08:50:32 +10:00
mhmdanas
7bfe2f41c6 fix: add Dart required keyword 2022-03-04 20:38:24 +11:00
Ole Herman Schumacher Elgesem
4bc1957345
CFEngine 3: Added syntax highlighting for macros, promise keyword, and different string literals (#604)
The new promise keyword is used in the same places as bundle and
body, to declare new promise types in CFEngine 3.

See, for example:

f126ede5e6/libpromises/cf3parse.y (L44-L57)

f126ede5e6/libpromises/cf3lex.l (L102-L106)

CFEngine 3 supports 3 symbols for string literals:
single quotation marks, double quotation marks, and
backticks (grave accent).

See:
https://docs.cfengine.com/docs/3.18/reference-language-concepts-variables.html#quoting
2022-02-10 13:26:37 +11:00
Alec Thomas
cc2dd5b8ad Version 2 of Chroma
This cleans up the API in general, removing a bunch of deprecated stuff,
cleaning up circular imports, etc.

But the biggest change is switching to an optional XML format for the
regex lexer.

Having lexers defined only in Go is not ideal for a couple of reasons.
Firstly, it impedes a significant portion of contributors who use Chroma
in Hugo, but don't know Go. Secondly, it bloats the binary size of any
project that imports Chroma.

Why XML? YAML is an abomination and JSON is not human editable. XML
also compresses very well (eg. Go template lexer XML compresses from
3239 bytes to 718).

Why a new syntax format? All major existing formats rely on the
Oniguruma regex engine, which is extremely complex and for which there
is no Go port.

Why not earlier? Prior to the existence of fs.FS this was not a viable
option.

Benchmarks:

    $ hyperfine --warmup 3 \
        './chroma.master --version' \
        './chroma.xml-pre-opt --version' \
        './chroma.xml --version'
    Benchmark 1: ./chroma.master --version
      Time (mean ± σ):       5.3 ms ±   0.5 ms    [User: 3.6 ms, System: 1.4 ms]
      Range (min … max):     4.2 ms …   6.6 ms    233 runs

    Benchmark 2: ./chroma.xml-pre-opt --version
      Time (mean ± σ):      50.6 ms ±   0.5 ms    [User: 52.4 ms, System: 3.6 ms]
      Range (min … max):    49.2 ms …  51.5 ms    51 runs

    Benchmark 3: ./chroma.xml --version
      Time (mean ± σ):       6.9 ms ±   1.1 ms    [User: 5.1 ms, System: 1.5 ms]
      Range (min … max):     5.7 ms …  19.9 ms    196 runs

    Summary
      './chroma.master --version' ran
        1.30 ± 0.23 times faster than './chroma.xml --version'
        9.56 ± 0.83 times faster than './chroma.xml-pre-opt --version'

A slight increase in init time, but I think this is okay given the
increase in flexibility.

And binary size difference:

    $ du -h lexers.test*
    $ du -sh chroma*                                                                                                                                                                                                                                                                                                                                                                                                                                                             951371ms
    8.8M	chroma.master
    7.8M	chroma.xml
    7.8M	chroma.xml-pre-opt

Benchmarks:

    $ hyperfine --warmup 3 \
        './chroma.master --version' \
        './chroma.xml-pre-opt --version' \
        './chroma.xml --version'
    Benchmark 1: ./chroma.master --version
      Time (mean ± σ):       5.3 ms ±   0.5 ms    [User: 3.6 ms, System: 1.4 ms]
      Range (min … max):     4.2 ms …   6.6 ms    233 runs

    Benchmark 2: ./chroma.xml-pre-opt --version
      Time (mean ± σ):      50.6 ms ±   0.5 ms    [User: 52.4 ms, System: 3.6 ms]
      Range (min … max):    49.2 ms …  51.5 ms    51 runs

    Benchmark 3: ./chroma.xml --version
      Time (mean ± σ):       6.9 ms ±   1.1 ms    [User: 5.1 ms, System: 1.5 ms]
      Range (min … max):     5.7 ms …  19.9 ms    196 runs

    Summary
      './chroma.master --version' ran
        1.30 ± 0.23 times faster than './chroma.xml --version'
        9.56 ± 0.83 times faster than './chroma.xml-pre-opt --version'

Incompatible changes:

- (*RegexLexer).SetAnalyser: changed from func(func(text string) float32) *RegexLexer to func(func(text string) float32) Lexer
- (*TokenType).UnmarshalJSON: removed
- Lexer.AnalyseText: added
- Lexer.SetAnalyser: added
- Lexer.SetRegistry: added
- MustNewLazyLexer: removed
- MustNewLexer: changed from func(*Config, Rules) *RegexLexer to func(*Config, func() Rules) *RegexLexer
- Mutators: changed from func(...Mutator) MutatorFunc to func(...Mutator) Mutator
- NewLazyLexer: removed
- NewLexer: changed from func(*Config, Rules) (*RegexLexer, error) to func(*Config, func() Rules) (*RegexLexer, error)
- Pop: changed from func(int) MutatorFunc to func(int) Mutator
- Push: changed from func(...string) MutatorFunc to func(...string) Mutator
- TokenType.MarshalJSON: removed
- Using: changed from func(Lexer) Emitter to func(string) Emitter
- UsingByGroup: changed from func(func(string) Lexer, int, int, ...Emitter) Emitter to func(int, int, ...Emitter) Emitter
2022-01-27 15:22:00 +11:00
silverwind
4ba9a05fee Add mariadb aliases
Fixes: https://github.com/alecthomas/chroma/issues/590
2022-01-16 10:29:45 +11:00
Alec Thomas
36bdd4b988 Benchmark Java instead of Go. 2022-01-12 21:49:38 +11:00
Jelle Hulter
b01c8fcab6
Added OpenEdgeABL lexer (#585) 2022-01-04 03:22:50 +11:00
James
decf9d3229
Highlight MSBuild project files for C#, F#, and C++ as XML. (#584) 2022-01-02 18:16:11 +11:00
Martin Stühmer
3bdc3fbe7a
Removed mimetype for the Lexer bicep (#574) 2021-12-20 18:12:21 +11:00
Tobias Neitzel
ac2891ff2a
Add support for more complex command prompts (#583)
The bashsession lexer did only recognized command prompts starting with
one of the characters '#$%>'. This commit adds support for a prefixed
block of the form `[.*@.*]`, which is a common layout for command prompts.
2021-12-20 18:04:05 +11:00
MsK`
d38fcfcce0 fixed scheme characters 2021-12-13 14:36:15 +11:00
Nicolas Jeannerod
06f476d11a
Add lexer for Typed and Untyped Plutus Core (#579) 2021-12-02 21:23:30 +11:00
Joseph Schorr
0fcd2d8e0e Add lexer/detector for zed
Reference: https://docs.authzed.com/reference/schema-lang

Used by project SpiceDB (https://github.com/authzed/spicedb), a database system for managing security-critical permissions checking, inspired by Google's Zanzibar paper
2021-10-27 15:18:05 +11:00
Martin Stühmer
202379826e
feat: Added .bicep lexer #562 (#564) 2021-10-23 21:48:00 +11:00
Guillaume Corré
175c35e532 Handle enclosing backtick in Kotlin lexer for identifiers, close #565 2021-10-23 08:50:29 +11:00
Martin Stühmer
4c36740e5e
Refinement of the C# lexer (#563) 2021-10-21 14:03:33 +11:00
Tom Lebreux
22ed667b6d Add binary number to go lexer 2021-09-28 07:50:31 +10:00
Tom Lebreux
785554e8b1 Add sieve lexer
Generated by pygments2chroma.py
2021-09-28 07:50:06 +10:00
Alec Thomas
07a127dd74 Test for compiling all lexer patterns. 2021-09-27 14:19:39 +10:00
Steven Penny
23160b3058 lexers/internal: remove danwakefield/fnmatch
This package appears to be old and unmaintained, and it gets pulled into the
go.sum of every single package importing Chroma. Also fnmatch doesnt seem to do
any error checking on the pattern, while the standard package does. Also, the
standard package path/filepath is already imported, so it appears not to cost
anything to change it.
2021-09-27 13:37:55 +10:00
Patrice Chalin
7259f5b254 BashSession lexer 2021-09-19 15:09:58 +10:00
Siavash Askari Nasr
4d7154e8c7 Raku: Fix unterminated heredoc fixes #547
- Fix heredoc
- Move testdata to raku directory
- Add testdata for unterminated heredoc
2021-09-19 08:41:00 +10:00
Guillermo León
82795e1420 Update to the last version of microsoft grammar file 2021-09-18 18:20:49 +10:00