Last active
April 20, 2023 11:33
-
-
Save phuhl/d6765e170453376e809cee20723e5b03 to your computer and use it in GitHub Desktop.
A (non-complete) Prismjs syntax highlighting mode for Emacs' Restclient-mode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Author: Philipp Uhl | |
*/ | |
const standardFeatures = { | |
comment: /(^|[\n\r])\s*#.*/, | |
tag: { | |
pattern: /(^|[\n\r])[^ :]+: .*/, | |
inside: { | |
variable: { | |
pattern: / :[a-zA-Z-\d]+/, | |
}, | |
string: { | |
pattern: /([^:\n\r]+: )(.*)/, | |
lookbehind: true, | |
}, | |
}, | |
}, | |
variable: { | |
pattern: /(^|[\n\r]):[a-zA-Z-\d]+/, | |
}, | |
operator: { | |
pattern: /( := )|( = )/, | |
}, | |
}; | |
Prism.languages.restclient = { | |
jsonBody: { | |
pattern: | |
/([\n\r]Content-Type: application\/json\s*[\n\r])([^\n\r]+([\n\r]|\n\r|\r\n))*[\n\r]+([^]*?)(?=([\r\n]\s*#)|$)/, | |
inside: { | |
body: { | |
pattern: /[\n\r]\s*[\n\r].*$/s, | |
inside: Prism.languages.json, | |
}, | |
...standardFeatures, | |
}, | |
}, | |
keyword: { | |
pattern: /(^|[\n\r])(GET|POST|PUT|PATCH|DELETE|HEAD)\s+.*/, | |
alias: "bold", | |
inside: { | |
tag: /\shttp.*$/i, | |
}, | |
}, | |
lispAssignment: { | |
pattern: /(^|[\n\r]):[a-zA-Z-\d]+\s+:=\s*.*$/m, | |
inside: { | |
lisp: { | |
pattern: /(:=\s*)(.*$)/, | |
lookbehind: true, | |
inside: Prism.languages.lisp, | |
}, | |
...standardFeatures, | |
}, | |
}, | |
...standardFeatures, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently missing (but easy to add):