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

44 Commits

Author SHA1 Message Date
xjzi
cbe8b53db7 Add Modus Operandi (light) theme 2022-10-06 09:11:33 +11:00
xjzi
5b957aac0a Add Modus Vivendi (dark) theme 2022-10-06 09:11:33 +11:00
Hemanta Sapkota
3f86ac7554 Add Gruvbox light theme 2022-08-25 21:26:57 +10:00
Aniket Teredesai
c13ff147a3 fix(styles/github-dark): update definitions, reformat 2022-07-28 08:10:02 +10:00
Aniket Teredesai
c714e84613
add(styles/github-dark): github's dark colorscheme for chroma (#653) 2022-07-19 00:37:37 -07:00
Spence Churchill
f7893bced9 add an average rgb scheme 2022-04-20 18:16:07 +10:00
sk-rama
33fa61166f Update friendly.go
Remove italic style for chroma.LiteralStringInterpol. 
Purpose: For python it make a mistake in code style
2022-01-27 15:43: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
pu
0b2b5eec0a
Add[styles/gruvbox]: vim gruvbox theme for chroma (#592) 2022-01-14 00:18:06 +11:00
Yang Yang
3f5761f9fe Fix background color of xcode-dark style 2021-11-30 19:03:01 +11:00
Stefan van der Walt
7cefa29980
Add WitchHazel by Thea Flowers (#570)
https://witchhazel.thea.codes/
2021-11-09 19:12:41 +11:00
Dmitry Titov
02951cec42
Implement 1S:Enterprise (#545) 2021-09-04 10:20:45 +10:00
Ville Skyttä
4b989ea3b2 feat(styles/dracula): use official green and red for inserted and deleted
Green and red are the de facto colors used to represent inserted and
deleted lines. This changes the red that was already used for deleted to
use the official Dracula red, getting rid of an unofficial color, and
changes the inserted color from foreground white to green, to make
insertions stand out from headings and such.
2021-05-27 08:55:14 +10:00
Soubik Bhui
8513d9997e
Add new style - "hr" (#513) 2021-05-22 21:49:56 +10:00
Siavash Askari Nasr
2bcdf19ee2 [doom-one] Change style of NameAttribute
it was close to operator's color
2021-05-11 22:51:48 +10:00
Siavash Askari Nasr
f6d1db5fa5 Change some colors, Add a new variation 2021-05-02 17:24:08 +10:00
Siavash Askari Nasr
1231145de8 Add doom-one style 2021-05-02 17:24:08 +10:00
Daichi Hayashi
9dc3c8c529
Add new style called "xcode-dark" (#460) 2021-03-24 07:33:54 +11:00
Govind Gnanakumar
b20de6333c Create new style - "vulcan"
This is a new theme / style, inspired by Doom Emacs's One Doom Theme
2021-02-08 18:25:03 +11:00
Diego Henrique Oliveira
6e272cfd92 Introduce the Nord theme
This commit adds the Nord theme as an option. This theme is fully
documented in the official website: https://www.nordtheme.com
2020-12-06 11:05:56 +11:00
zeitchef
e3a674cca9 Add base16-snazzy style 2020-10-29 19:59:52 +11:00
toshimaru
a5a6d529d0 Use chroma.StyleEntries instead of map 2019-08-15 13:07:48 +10:00
Jos512
abbe00cecd Provide some default styles for RRT (fixes #212) (#219) 2019-01-23 18:48:27 +11:00
Alec Thomas
da5ac60d8c Add golangci-lint and fix all lint issues. 2018-12-31 22:46:59 +11:00
Kaushal Modi
371820dad6 Assign .gl class to GenericUnderline; add CSS rules for the same
'l' in gl is for under(l)ine, as the "gu" class is taken by
GenericSubheading.

- Rules for GenericUnderline are added to all the styles
- Make "Underline" style insert "text-decoration: underline" in CSS.

Fixes https://github.com/alecthomas/chroma/issues/159.
2018-08-01 17:28:52 -04:00
German Lashevich
33cc533118 New styles from solarized styles family 2018-04-21 09:03:12 +10:00
Alec Thomas
cbc3d5b9f0 Implement special name mappings for EmacsLisp.
Fixes #43.
2017-09-27 21:32:45 +10:00
Alec Thomas
bc2d6680e4 Run gofmt -s over the codebase. 2017-09-26 22:05:55 +10:00
Alec Thomas
c39abfb916 Squish the GitHub style a bit. 2017-09-26 22:05:55 +10:00
Abe Estrada
0f9e25c566 Add 'dracula' style
Converted from https://github.com/dracula/pygments
2017-09-25 21:11:21 -06:00
Alec Thomas
bdc1124369 Switch to Pygments-style CSS class names.
Add GitHub theme + CSS to style importer.
2017-09-25 21:46:25 +10:00
Alec Thomas
237eebbe1a A naive YAML lexer.
Does not try to be smart in anyway. Instead, just highlights what it
can. Used this reference: https://learnxinyminutes.com/docs/yaml/

Fixes #13.
2017-09-24 21:47:05 +10:00
Alec Thomas
d5083b3f7c Big changes to the style and colour APIs.
- Styles now use a builder system, to enforce immutability of styles.
- Corrected and cleaned up how style inheritance works.
- Added a brightening function to colours
- HTML formatter will now automatically pick line and highlight colours
  if they are not provided in the style. This is done by slightly
  darkening or lightening.

Fixes #21.
2017-09-23 22:09:46 +10:00
Alec Thomas
551f7cee9a Return errors for invalid styles, rather than panicking. 2017-09-21 12:52:08 +10:00
Alec Thomas
4c6dba0fc4 Add "monokailight" style. 2017-09-21 12:28:03 +10:00
Alec Thomas
a72960340e Add test to pre-compile all regexes. 2017-09-19 14:15:33 +10:00
Alec Thomas
d80c30ae4e Sort formatters and styles Names(). 2017-09-19 11:31:51 +10:00
Alec Thomas
57c8e08560 Add CMake. 2017-09-18 19:29:14 +10:00
Alec Thomas
d12529ae61 HTML formatter + import all Pygments styles. 2017-07-20 00:01:29 -07:00
Alec Thomas
7a7b85b4b3 Add protobuf and thrift. 2017-06-07 19:47:59 +10:00
Alec Thomas
7ae55eb265 Wire up content sniffing. 2017-06-07 19:47:59 +10:00
Alec Thomas
7b6a07b9bb Revert to using CIE76 for style colour matching.
Some testing showed RGB distance was *really* bad.
2017-06-07 19:47:59 +10:00
Alec Thomas
d852022f8d Move style and formatter API into chroma package. 2017-06-07 19:47:59 +10:00
Alec Thomas
5749aebe42 Generalise and support 8, 256 and 16m colour terminals. 2017-06-07 19:47:59 +10:00