Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add desktop entry lexer #903

Merged
merged 2 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ translators for Pygments lexers and styles.
| A | ABAP, ABNF, ActionScript, ActionScript 3, Ada, Agda, AL, Alloy, Angular2, ANTLR, ApacheConf, APL, AppleScript, ArangoDB AQL, Arduino, ArmAsm, AutoHotkey, AutoIt, Awk |
| B | Ballerina, Bash, Bash Session, Batchfile, BibTeX, Bicep, BlitzBasic, BNF, BQN, Brainfuck |
| C | C, C#, C++, Caddyfile, Caddyfile Directives, Cap'n Proto, Cassandra CQL, Ceylon, CFEngine3, cfstatement, ChaiScript, Chapel, Cheetah, Clojure, CMake, COBOL, CoffeeScript, Common Lisp, Coq, Crystal, CSS, Cython |
| D | D, Dart, Dax, Diff, Django/Jinja, dns, Docker, DTD, Dylan |
| D | D, Dart, Dax, Desktop Entry, Diff, Django/Jinja, dns, Docker, DTD, Dylan |
| E | EBNF, Elixir, Elm, EmacsLisp, Erlang |
| F | Factor, Fennel, Fish, Forth, Fortran, FortranFixed, FSharp |
| G | GAS, GDScript, Genshi, Genshi HTML, Genshi Text, Gherkin, GLSL, Gnuplot, Go, Go HTML Template, Go Text Template, GraphQL, Groff, Groovy |
Expand Down
17 changes: 17 additions & 0 deletions lexers/embedded/desktop_entry.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<lexer>
<config>
<name>Desktop file</name>
<alias>desktop</alias>
<alias>desktop_entry</alias>
<filename>*.desktop</filename>
<mime_type>application/x-desktop</mime_type>
</config>
<rules>
<state name="root">
<rule pattern="^[ \t]*\n"><token type="TextWhitespace"/></rule>
<rule pattern="^(#.*)(\n)"><bygroups><token type="CommentSingle"/><token type="TextWhitespace"/></bygroups></rule>
<rule pattern="(\[[^\]\n]+\])(\n)"><bygroups><token type="Keyword"/><token type="TextWhitespace"/></bygroups></rule>
<rule pattern="([-A-Za-z0-9]+)(\[[^\] \t=]+\])?([ \t]*)(=)([ \t]*)([^\n]*)([ \t\n]*\n)"><bygroups><token type="NameAttribute"/><token type="NameNamespace"/><token type="TextWhitespace"/><token type="Operator"/><token type="TextWhitespace"/><token type="LiteralString"/><token type="TextWhitespace"/></bygroups></rule>
</state>
</rules>
</lexer>
8 changes: 8 additions & 0 deletions lexers/testdata/desktop_entry.actual
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Created with jdDesktopEntryEdit 1.3
[Desktop Entry]
Type=Application
Name=Chroma
Comment= A general purpose syntax highlighter in pure Go
TryExec=chroma
Exec=chroma
Terminal=true
31 changes: 31 additions & 0 deletions lexers/testdata/desktop_entry.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[
{"type":"CommentSingle","value":"# Created with jdDesktopEntryEdit 1.3"},
{"type":"TextWhitespace","value":"\n"},
{"type":"Keyword","value":"[Desktop Entry]"},
{"type":"TextWhitespace","value":"\n"},
{"type":"NameAttribute","value":"Type"},
{"type":"Operator","value":"="},
{"type":"LiteralString","value":"Application"},
{"type":"TextWhitespace","value":"\n"},
{"type":"NameAttribute","value":"Name"},
{"type":"Operator","value":"="},
{"type":"LiteralString","value":"Chroma"},
{"type":"TextWhitespace","value":"\n"},
{"type":"NameAttribute","value":"Comment"},
{"type":"Operator","value":"="},
{"type":"TextWhitespace","value":" "},
{"type":"LiteralString","value":"A general purpose syntax highlighter in pure Go"},
{"type":"TextWhitespace","value":"\n"},
{"type":"NameAttribute","value":"TryExec"},
{"type":"Operator","value":"="},
{"type":"LiteralString","value":"chroma"},
{"type":"TextWhitespace","value":"\n"},
{"type":"NameAttribute","value":"Exec"},
{"type":"Operator","value":"="},
{"type":"LiteralString","value":"chroma"},
{"type":"TextWhitespace","value":"\n"},
{"type":"NameAttribute","value":"Terminal"},
{"type":"Operator","value":"="},
{"type":"LiteralString","value":"true"},
{"type":"TextWhitespace","value":"\n"}
]