diff options
| author | Matěj Cepl <mcepl@cepl.eu> | 2025-03-24 10:11:05 -0400 |
|---|---|---|
| committer | Randy Palamar <randy@rnpnr.xyz> | 2025-06-13 09:25:20 -0600 |
| commit | 16e31ceb717c943584cb75d0e28c21e356a54076 (patch) | |
| tree | 2d07cf6b6c2e7502d8be0214b1a2484aeeaf409b /lua/lexers/output.lua | |
| parent | f694179d1153eecc50c1179cf5ee8233639f9eba (diff) | |
| download | vis-16e31ceb717c943584cb75d0e28c21e356a54076.tar.gz vis-16e31ceb717c943584cb75d0e28c21e356a54076.tar.xz | |
lua/lexers: update to scintillua 6.5
This is an amalgamation of the following upstream commits:
- Overhauled API documentation for lexer.lua.
- Fixed Markdown to allow code fence blocks to be indented.
- Use GitHub Pages' Primer theme for documentation.
Build static pages with Jekyll, like GitHub Pages does.
- Migrated systemd lexer.
Thanks to Matěj Cepl.
- Migrated Lisp lexer and highlight character escapes.
Thanks to Matěj Cepl.
- Migrated rpmspec lexer and made some improvements.
Thanks to Matěj Cepl.
- Modernized reST lexer.
Thanks to Matěj Cepl.
- Markdown lexer should just tag the start of a blockquote.
The quote's contents may contain markdown.
- Output lexer can highlight CSI color sequences.
- Allow lexers to define their own fold functions.
- Added custom folder for Markdown headers.
- Added `lexer.line_start`, `lexer.line_end` and `lexer.text_range()`.
- Fixed Markdown lexer to not lex some continuation lines as code.
- Fixed SciTE not using Scintillua's markdown lexer.
- Markdown lexer should not highlight secondary paragraphs in list items as code blocks.
- Have SciTE recognize CMakeLists.txt.
Diffstat (limited to 'lua/lexers/output.lua')
| -rw-r--r-- | lua/lexers/output.lua | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lua/lexers/output.lua b/lua/lexers/output.lua index 797ee97..0dd3f38 100644 --- a/lua/lexers/output.lua +++ b/lua/lexers/output.lua @@ -7,7 +7,7 @@ local lexer = lexer local starts_line = lexer.starts_line -local P, S = lpeg.P, lpeg.S +local P, S, R = lpeg.P, lpeg.S, lpeg.R local lex = lexer.new(..., {lex_by_line = true}) @@ -94,6 +94,19 @@ lex:add_rule('perl', starts_line(message((lexer.nonnewline - ' at ')^1)) * text( lex:add_rule('cmake', starts_line(text('CMake Error at ')) * c_filename * colon * line * colon * mark_error) -lex:add_rule('any_line', lex:tag(lexer.DEFAULT, lexer.to_eol())) +-- CSI sequences, including colors. +local csi = P('\x1B[') +local non_csi_seq = text((lexer.nonnewline - csi)^1) +local colors = {'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'} +local csi_color = P(false) +for i, name in ipairs(colors) do + local bold, color = '1;', tostring(30 + i - 1) + csi_color = csi_color + + (lex:tag('csi', csi * bold * color * 'm') * lex:tag('csi.' .. name .. '.bright', non_csi_seq)) + + (lex:tag('csi', csi * color * 'm') * lex:tag('csi.' .. name, non_csi_seq)) +end +local csi_seq = #csi * (csi_color + lex:tag('csi', csi * (lexer.nonnewline - R('@~'))^0 * R('@~'))) + +lex:add_rule('any_line', (non_csi_seq + csi_seq)^1) return lex |
