Skip to content

Commit 15f2498

Browse files
scopalecthomas
authored andcommitted
lexers: add one for groff
Generated from Pygments one, some filename extensions added.
1 parent 8bba42c commit 15f2498

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ C | C, C#, C++, Caddyfile, Caddyfile Directives, Cap'n Proto, Cassandra CQL, Cey
4141
D | D, Dart, Diff, Django/Jinja, Docker, DTD, Dylan
4242
E | EBNF, Elixir, Elm, EmacsLisp, Erlang
4343
F | Factor, Fish, Forth, Fortran, FSharp
44-
G | GAS, GDScript, Genshi, Genshi HTML, Genshi Text, Gherkin, GLSL, Gnuplot, Go, Go HTML Template, Go Text Template, GraphQL, Groovy
44+
G | GAS, GDScript, Genshi, Genshi HTML, Genshi Text, Gherkin, GLSL, Gnuplot, Go, Go HTML Template, Go Text Template, GraphQL, Groff, Groovy
4545
H | Handlebars, Haskell, Haxe, HCL, Hexdump, HLB, HTML, HTTP, Hy
4646
I | Idris, Igor, INI, Io
4747
J | J, Java, JavaScript, JSON, Julia, Jungle

Diff for: lexers/g/groff.go

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package g
2+
3+
import (
4+
. "github.com/alecthomas/chroma" // nolint
5+
"github.com/alecthomas/chroma/lexers/internal"
6+
)
7+
8+
// Groff lexer.
9+
var Groff = internal.Register(MustNewLazyLexer(
10+
&Config{
11+
Name: "Groff",
12+
Aliases: []string{"groff", "nroff", "man"},
13+
Filenames: []string{"*.[1-9]", "*.1p", "*.3pm", "*.man"},
14+
MimeTypes: []string{"application/x-troff", "text/troff"},
15+
},
16+
func() Rules {
17+
return Rules{
18+
"root": {
19+
{`(\.)(\w+)`, ByGroups(Text, Keyword), Push("request")},
20+
{`\.`, Punctuation, Push("request")},
21+
{`[^\\\n]+`, Text, Push("textline")},
22+
Default(Push("textline")),
23+
},
24+
"textline": {
25+
Include("escapes"),
26+
{`[^\\\n]+`, Text, nil},
27+
{`\n`, Text, Pop(1)},
28+
},
29+
"escapes": {
30+
{`\\"[^\n]*`, Comment, nil},
31+
{`\\[fn]\w`, LiteralStringEscape, nil},
32+
{`\\\(.{2}`, LiteralStringEscape, nil},
33+
{`\\.\[.*\]`, LiteralStringEscape, nil},
34+
{`\\.`, LiteralStringEscape, nil},
35+
{`\\\n`, Text, Push("request")},
36+
},
37+
"request": {
38+
{`\n`, Text, Pop(1)},
39+
Include("escapes"),
40+
{`"[^\n"]+"`, LiteralStringDouble, nil},
41+
{`\d+`, LiteralNumber, nil},
42+
{`\S+`, LiteralString, nil},
43+
{`\s+`, Text, nil},
44+
},
45+
}
46+
},
47+
))

0 commit comments

Comments
 (0)