Skip to content

Commit 1f6994a

Browse files
authored
Merge pull request #45 from davidhcefx/jsx
feat(jsx): Add JSX highlighting
2 parents 6b11b66 + 5a453e8 commit 1f6994a

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

jsx.nanorc

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
### JavaScript XML files (derived from JavaScript)
2+
3+
syntax "JSX" "\.jsx$"
4+
header "^#!.*\/(env +)node"
5+
comment "//"
6+
7+
## Default
8+
color white "^.+$"
9+
10+
## HTML tags
11+
color orange start="<" end=">"
12+
## HTML Attributes
13+
color magenta "[[:space:]](abbr|accept(-charset)?|accesskey|action|[av]?link|alt|archive|axis|background|(bg)?color|border)="
14+
color magenta "[[:space:]](cell(padding|spacing)|char(off|set)?|checked|cite|class(id)?|compact|code(base|tag)?|cols(pan)?)="
15+
color magenta "[[:space:]](content(editable)?|contextmenu|coords|data|datetime|declare|defer|dir|enctype)="
16+
color magenta "[[:space:]](for|frame(border)?|headers|height|hidden|href(lang)?|hspace|http-equiv|id|ismap)="
17+
color magenta "[[:space:]](label|lang|longdesc|margin(height|width)|maxlength|media|method|multiple)="
18+
color magenta "[[:space:]](name|nohref|noresize|noshade|object|on(click|focus|load|mouseover|keypress)|profile|readonly|rel|rev)="
19+
color magenta "[[:space:]](rows(pan)?|rules|scheme|scope|scrolling|shape|size|span|src|standby|start|style|summary|pattern)="
20+
color magenta "[[:space:]](tabindex|target|text|title|type|usemap|v?align|value(type)?|vspace|width|xmlns|xml:space)="
21+
color magenta "[[:space:]](required|disabled|selected)[[:space:]=>]"
22+
23+
## Decimal, octal and hexadecimal numbers
24+
color yellow "\<[-+]?([1-9][0-9]*|0[0-7]*|0x[0-9a-fA-F]+)([uU][lL]?|[lL][uU]?)?\>"
25+
26+
## Floating point number with at least one digit before decimal point
27+
color yellow "\<[-+]?([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([EePp][+-]?[0-9]+)?[fFlL]?"
28+
color yellow "\<[-+]?([0-9]+[EePp][+-]?[0-9]+)[fFlL]?"
29+
30+
## Keywords
31+
color green "\<(break|case|catch|continue|default|delete|do|else|finally)\>"
32+
color green "\<(for|function|if|in|instanceof|new|return|switch)\>"
33+
color green "\<(switch|this|throw|try|typeof|var|void|while|with)\>"
34+
color green "\<(import|as|from|export)\>"
35+
color green "\<(const|let|class|extends|of|get|set|await|async|yield)\>"
36+
37+
## Type specifiers
38+
color red "\<(Array|Boolean|Date|Enumerator|Error|Function|Math)\>"
39+
color red "\<(WeakMap|Map|WeakSet|Set|Symbol|Promise)\>"
40+
color red "\<(Number|Object|RegExp|String)\>"
41+
color red "\<(true|false|null|undefined|NaN)\>"
42+
43+
## Function names
44+
color cyan "[A-Za-z_][A-Za-z0-9_]*[[:space:]]*[(]|)"
45+
46+
## Operators
47+
#color red "[-+/*=<>!~%?:&|]"
48+
49+
## String
50+
color brightyellow "L?\"(\\"|[^"])*\""
51+
color brightyellow "L?'(\\'|[^'])*'"
52+
color brightyellow "L?`(\\`|[^`])*`"
53+
color brightwhite,blue start="\$\{" end="\}"
54+
55+
## Regex (will likely mess up with urls)
56+
#color magenta "/[^*]([^/]|(\\/))*[^\\<]/[gim]*"
57+
58+
## Escapes
59+
color yellow "\\[0-7][0-7]?[0-7]?|\\x[0-9a-fA-F]+|\\[bfnrt'"`\?\\]"
60+
61+
## Comments
62+
color brightblue start="/\*" end="\*/"
63+
color brightblue "(^|\s)//.*$"
64+
65+
## Trailing spaces and mixed whitespaces
66+
color ,green "[[:space:]]+$"
67+
color ,red "( + +| + +)"
68+
69+
## Reminders
70+
color brightwhite,yellow "\<(FIXME|TODO|XXX)\>"

nanorc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ include "~/.nano/java.nanorc"
5757
include "~/.nano/jrnl.nanorc"
5858
include "~/.nano/js.nanorc"
5959
include "~/.nano/json.nanorc"
60+
include "~/.nano/jsx.nanorc"
6061
include "~/.nano/julia.nanorc"
6162
include "~/.nano/keymap.nanorc"
6263
include "~/.nano/kickstart.nanorc"

0 commit comments

Comments
 (0)