Op 27-09-2021 om 02:22 schreef Otto Kekäläinen:
> I tested this today, but unfortunately the yaml.nanorc seems to have
> syntax errors:
> 
> Error in /usr/share/nano/yaml.nanorc on line 6: A syntax name must be quoted

The syntax file is from git, so it is meant for a modern nano (5.0 or later).

Attached is a version that should work on older nanos (but shows too much
bold and some other colors than the intended ones, and is fully readable
only on a terminal with a dark background).

Benno
## Syntax highlighting for YAML files.

## Original author:  Benno Schulenberg
## License:  GPL version 3 or newer

#### (Adjusted to work on older nanos.)

syntax "yaml" "\.ya?ml$"
header "^---"

tabgives "  "
comment "#"

# Keys:
color brightgreen "(\w|-)+:( |$)"
color brightgreen "\[(\w|[, -])+\]:( |$)"

# Values (booleans, numbers, octal/hex, dates, strings):
color brightmagenta "[:,] +(Y(es)?|No?|y(es)?|no?|[Tt]rue|[Ff]alse|[Oo](n|ff))( 
*[]}]|, | +#|$)"
color brightmagenta "[:,] +[+-]?[0-9]+(\.([0-9]+)?)?( *[]}]|, | +#|$)"
color brightmagenta " 0(o[0-7]+|x[0-9ABCDEFabcdef]+)( *[]}]|, | +#|$)"
color white "[:,]( |$)"
color brightmagenta " [12][0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])"
color brightmagenta "("[^"]+"|'[^']+')"

# Anchors and references:
color brightred " [&*]\w+( |$)"

# Symbols:
color brightblue "^(---|\.\.\.)( |$)" " [|>]([1-9]?[+-]|[+-][1-9]?)?$"
color yellow "(^ *- |[]{}[])"

# Types:
color green " !!(binary|bool|float|int|map|null|omap|seq|set|str)( |$)"
color green " !(\w|-)+( |$)"

# Mistakes (control codes, missing space, trailing space):
color ,red "[[:cntrl:]]|[:,][^ ]| *$"

# Comments:
color cyan "(^| )#.*"

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

Reply via email to