scopatz / nanorc

Improved Nano Syntax Highlighting Files
Other
3.05k stars 556 forks source link

.nanorc regex errors on nano 2.8+ #164

Open chrcoluk opened 6 years ago

chrcoluk commented 6 years ago

Here is contents of the file. No errors in 2.7.4

2.8+ says bad regex.

Any idea if its a bug or just some tightening up of criteria that has caught out legit bad regex?, thanks.

`set tabsize 4

Here is an example for Bourne shell scripts.

syntax "sh" ".sh$" header "^#!./(ba|k|pdk)?sh[-0-9_]" icolor brightgreen "^[0-9A-Z]+()" color green "[:<:][[:>:]]" color green "({|}|(|)|\;|]|[|`|\|\$|<|>|!|=|&||)" color green "-[Ldefgruwx][[:>:]]" color green "-(eq|ne|gt|lt|ge|le|s|n|z)[[:>:]]" color brightcyan "[:<:][[:>:]]" icolor brightred "\${?[0-9A-Z!@#$?-]+}?" color cyan "(^|[[:space:]])#.$" color brightyellow ""(\.|[^"])"" "'(\.|[^'])'"

trailing whitespace

color ,green "[[:space:]]+$"

multiples of eight spaces at the start a line

(after zero or more tabs) should be a tab

color ,green "^([TAB]*[ ]{8})+"

highlight indents that have an odd number of spaces

color ,red "^(([ ]{2})+|(TAB+))*[ ]{1}[^ ]{1}"

Here is an example for PHP

syntax "php" ".php[2345s~]?$"

php markings

color brightgreen "(<\?(php)?|\?>)"

functions

color white "[[:<:]][a-z_]*("

types

color green "[:<:][[:>:]]"

structure

color brightyellow "[:<:][[:>:]]"

control flow

color magenta "[:<:][[:>:]]"

strings

color brightyellow "<[^= ]>" ""(.|[^"])""

comments

color cyan "//." color cyan start="/*" end="\/"

color blue start="<" end=">"

color red "&[^;[[:space:]]]*;"

Trailing whitespace

color ,green "[[:space:]]+$"

Here is an example for Perl.

syntax "perl" ".p[lm]$" header "^#!./perl[-0-9._]" color red "[:<:]|d(bm(close|open)|efined|elete|ie|o|ump)|e(ach|of|val|x(ec|ists|it|p))|f(cntl|ileno|lock|ork))[[:>:]]" "[:<:]|([gs]et|end)(pw|gr|host|net|proto|serv)ent|getsock(name|opt)|gmtime|goto|grep|hex|index|int|ioctl|join)[[:>:]]" "[:<:]|rindex|rmdir|s|scalar|seek(dir)?)[[:>:]]" "[:<:][[:>:]]" "[:<:][[:>:]]" color magenta "[:<:][[:>:]]" icolor cyan start="[$@%]" end="( |[^0-9A-Z_]|-)" color yellow ""."|qq|.|" color white "[sm]/./" color white start="(^use| = new)" end=";" color green "#." color yellow start="<< 'STOP'" end="STOP"

Here is a short example for HTML.

syntax "html" ".html$" color brightcyan start="<" end=">" color red "&[^;[[:space:]]]*;"

CMake syntax highlighter for GNU Nano

syntax "cmake" "(CMakeLists.txt|.cmake)$"

icolor green "^[[:space:]][A-Z0-9_]+" icolor brightyellow "^[[:space:]](include|include_directories|include_external_msproject)[[:>:]]"

icolor brightgreen "^[[:space:]]*[:<:][[:>:]]" color brightgreen "[:<:][[:>:]][[:space:]]" color brightgreen "[[:space:]][:<:][[:>:]][[:space:]]"

icolor brightred "^[[:space:]]*[:<:]"

icolor cyan start="\$({|ENV{)" end="}" color magenta "[:<:][[:>:]]"

icolor brightcyan "^([[:space:]])?#." icolor brightcyan "[[:space:]]#.*" color ,green "[[:space:]]+$"

unattributed syntax highlighting example from wiki.linuxhelp.net/

syntax "makefile" "Makefile[^/]$" color red "[:=]" color magenta "[:<:][[:>:]]" color brightcyan "\$+[{(][a-zA-Z0-9_-]+[})]" color brightcyan "^[^ ]+:" color green "#.$"

Here is an example for css files.

syntax "css" ".css$" color brightred "." color brightyellow start="{" end="}" color brightwhite start=":" end="([;^{]|$)" color brightcyan ":active|:focus|:hover|:link|:visited|:link|:after|:before|$" color brightcyan start="\/*" end="\*/" color green ";|:|{|}"

Here is an example for patch files.

syntax "patch" ".(patch|diff)$" color brightgreen "^+." color green "^+++." color brightcyan "^ ." color brightred "^-." color red "^---." color brightyellow "^@@." color magenta "^diff.*"

Here is an example for Ruby.

syntax "ruby" ".rb$" header "^#!./ruby[-0-9._]"

Asciibetical list of reserved words

color yellow "[:<:][[:>:]]"

Constants

color brightcyan "(\$|@|@@)?[[:<:]][A-Z]+[0-9A-Z_a-z]*"

Ruby "symbols"

icolor magenta "([ ]|^):[0-9A-Z_]+[[:>:]]"

Some unique things we want to stand out

color brightyellow "[:<:][[:>:]]"

Regular expressions

color brightmagenta "/([^/]|(\/))/[iomx]" "%r{([^}]|(\}))}[iomx]"

Shell command expansion is in backticks or like %x{this}. These are

"double-quotish" (to use a perlism).

color brightcyan "[^]`" "%x{[^}]}"

Strings, double-quoted

color green ""([^"]|(\"))"" "%[QW]?{[^}]}" "%[QW]?([^)])" "%[QW]?<[^>]>" "%[QW]?[[^]]]" "%[QW]?\$[^$]\$" "%[QW]?\^[^^]\^" "%[QW]?![^!]!"

Expression substitution. These go inside double-quoted strings,

"like #{this}".

color brightgreen "#{[^}]*}"

Strings, single-quoted

color green "'([^']|(\'))'" "%[qw]{[^}]}" "%[qw]([^)])" "%[qw]<[^>]>" "%[qw][[^]]]" "%[qw]\$[^$]\$" "%[qw]\^[^^]\^" "%[qw]![^!]!"

Comments

color cyan "#[^{].$" "#$" color brightcyan "##[^{].$" "##$"

"Here" docs

color green start="<<-?'?EOT'?" end="^EOT"

Some common markers

color brightcyan "(XXX|TODO|FIXME|\?\?\?)"

Here is an example for xml files.

syntax "xml" ".([jrs]html?|sgml?|xml|xslt?)$" color green start="<" end=">" color cyan "<[^> ]+" color cyan ">" color yellow start="<!DOCTYPE" end="[/]?>" color yellow start="" color red "&[^;]*;"

trailing whitespace

color ,green "[[:space:]]+$"

multiples of eight spaces at the start a line

(after zero or more tabs) should be a tab

color ,green "^([TAB]*[ ]{8})+"

highlight indents that have an odd number of spaces

color ,red "^(([ ]{2})+|(TAB+))*[ ]{1}[^ ]{1}"`

scopatz commented 6 years ago

Pull requests welcome!