Commit Graph

277 Commits

Author SHA1 Message Date
Benno Schulenberg 81e5b57d74 syntax: xml: colorize user-defined entities differently
Also improve two comments.
2022-04-04 12:08:23 +02:00
Benno Schulenberg b568705eec syntax: xml: colorize /> properly, and colorize prolog tags differently
Use lightgrey for the prolog tags, as they normally are unimportant
boiler-plate stuff.  Comments are likely to be more relevant.

Any /> is part of the tag itself, not of the attributes.
2022-04-04 10:01:49 +02:00
Benno Schulenberg 89bb88e4f5 syntaxes: fold a couple of regexes together, and improve a few comments 2022-02-16 13:07:11 +01:00
Benno Schulenberg bdf8e41a72 syntax: nanorc: colorize each of the fourteen new color names as valid 2021-12-12 12:01:45 +01:00
Benno Schulenberg 7ab903f072 syntax: debian: remove file -- Debian itself will have to handle it
The syntax is useful only for users of Debian and its derivatives.
2021-12-12 11:45:21 +01:00
Benno Schulenberg 266ed0612f syntax: gentoo: remove file -- Gentoo itself will have to handle it
The file contained two syntaxes (each of them fairly large) that are
useful only for Gentoo users.  I don't think the file should have been
distributed with nano ever, as the syntaxes are just a dead weight for
the users of all other distributions.
2021-12-12 11:34:19 +01:00
Benno Schulenberg 27af34a853 syntax: default: colorize comments as one of the last things
So that URLs in comments don't get specially colored.
2021-12-10 12:32:17 +01:00
Benno Schulenberg 44836e77be syntax: nanorc: colorize a trailing comment when it begins with non-hex
That is: colorize text after a blank-plus-hash as a comment when there
is at least one non-hexadecimal character among the first three.

This relaxes the demand that a trailing comment should have a blank
after the hash too, as implemented by commit 90946c5e two weeks ago.
2021-12-07 16:51:35 +01:00
Benno Schulenberg 5cec57719b syntax: sql: add a few more missing keywords, like TRUE and FALSE
Also, don't first scare-color stuff between double quotes, as it
seems some dialects put certain calculations between them too.
2021-12-07 12:27:11 +01:00
Benno Schulenberg d6f101daef syntax: sql: colorize keywords regardless of case, and tweak the colors
Make types a bluish green, for more contrast with strings, so that the
latter can be made greener, for more contrast with the yellow keywords.
Make the main keywords bluer and less bright, and unbold and soften the
yellow ones.  Soften the comments too.

Reference for case-insensitivity:
  https://www.postgresql.org/docs/14/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
2021-12-07 10:21:23 +01:00
Benno Schulenberg 350cdd9827 syntax: sql: colorize strings differently than types
Also, colorize comments more readably (on a dark background), and
schemas less yelling, and languages more distinct from keywords.

And add a few more keywords, like IS and NULL.
2021-12-04 12:13:19 +01:00
Benno Schulenberg 5dc48d54f2 syntax: sql: add more missing keywords, like INNER and OUTER JOIN
Also, fold two other regexes together, for conciseness.
2021-12-03 12:52:05 +01:00
Benno Schulenberg 41975265bf syntax: sql: add some missing keywords, like ALL and ANY and OR
Also, combine some keywords that can only occur together.
And drop a few that are probably rare, like LARGE OBJECT.

Reference:
  https://www.postgresql.org/docs/14/bookindex.html

And use a more readable color -- blue is too dark on a black base.
2021-12-03 12:21:17 +01:00
Benno Schulenberg 598f13107d syntax: sql: add two missing data types -- xml and tsquery
References:
  https://www.postgresql.org/docs/14/datatype-xml.html
  https://www.postgresql.org/docs/14/datatype-textsearch.html#DATATYPE-TSQUERY
2021-12-03 12:21:17 +01:00
Benno Schulenberg 248ebf9117 syntax: sql: colorize only single-quoted things as strings
SQL does not know double-quoted strings.  Double quotes can be used
around identifiers, to prevent them being interpreted as keywords.

References:
  https://www.postgresql.org/docs/14/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS
  https://www.postgresql.org/docs/14/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
2021-12-03 12:21:17 +01:00
Benno Schulenberg 8aaa57a573 syntax: default: colorize dates, URLs, and nano's release motto
And change the color for control codes, to be more visible.
2021-11-30 10:32:08 +01:00
Benno Schulenberg 19e743c7e4 tweaks: condense the regexes for Types in the SQL syntax 2021-11-30 10:11:21 +01:00
Benno Schulenberg 56aacb3e32 syntax: sql: colorize as flow control only keywords that clearly are such
Drop things that were recolored afterward (like CLASS and DEFAULT).
Also, move these coloring rules to after the other keywords so that
things like "END IF" will stay colored as a whole.

Reference:
  https://www.postgresql.org/docs/current/plpgsql-control-structures.html
2021-11-30 10:11:21 +01:00
Benno Schulenberg f2c9aed16c syntax: sql: remove alien stuff -- it was copied mostly from ruby syntax
Regular expressions in SQL are not written between // or %r{},
strings are not written between <> or %Q{} or anything similar,
and comments do not start with # -- and officially not with //
either, but some dialects seem to allow it.

This fixes https://savannah.gnu.org/bugs/?61381.

Bug existed since version 2.4.2, since the SQL syntax was included.
2021-11-30 10:11:21 +01:00
Benno Schulenberg 27aff84f74 syntax: nanorc: paint arguments of 'include' and 'extendsyntax' specially
The path after 'include' is not a regex and does not need to be quoted;
when it's unquoted, colorize it specially, instead of leaving it red.

The syntax name after 'extendsyntax' should be brightgreen, like after
'syntax', but it's better that the subsequent commands have their own
special color.
2021-11-29 11:18:15 +01:00
Benno Schulenberg 90946c5e9e syntax: nanorc: avoid colorizing #rgb codes as if they were comments
Demand that trailing comments (which are not really supported anyway)
have a space or tab after their hash mark.
2021-11-23 12:02:03 +01:00
Brad Town 9a778f9a00 docs: add a description of the hexadecimal #rgb color specification
Also, update the syntax to colorize these codes the same as color names.

Signed-off-by: Brad Town <brad@bradtown.com>
2021-11-23 11:56:06 +01:00
Benno Schulenberg 3b5f650621 tweaks: use a color closer to the rest of the string, to reduce contrast
On my normal machine, 'peach' harmonizes nicely with 'brightgreen',
but on another there is a large, jarring contrast.
2021-11-16 16:32:47 +01:00
Benno Schulenberg f757c4a512 syntaxes: colorize hex more strictly by using character class [:xdigit:]
In UTF-8 locales, the ranges A-F and a-f include several accented
characters beyond "ABCDEF" and "abcdef", such as the Croat č and ć.

This fixes https://savannah.gnu.org/bugs/?61487.

Bug existed since the beginning of each of the syntaxes,
for the C syntax since version 1.3.6, commit 159bdfdc.
2021-11-15 16:17:31 +01:00
Benno Schulenberg 06ad77895f syntax: python: colorize backslash escapes, such as \n and \xef
Reference: https://docs.python.org/3/reference/lexical_analysis.html
2021-11-15 15:30:21 +01:00
Benno Schulenberg a623f5836c docs: explain the effect of --zero / -0 / 'set zero'
Also, colorize 'set zero' as valid option in a nanorc file.
2021-11-09 16:31:04 +01:00
Benno Schulenberg fab4d0afcb tweaks: reshuffle a coloring rule, to have related ones together
(We don't want the rule for control codes after the rule for comments,
because then control codes in commented-out binds would stand out.)
2021-11-03 17:35:52 +01:00
Benno Schulenberg d9e42cb274 syntax: nanorc: require whitespace before the start= and end= keywords
Also, drop the unneeded and mistaken 'end=' in the first regex, as
a coloring rule with just end="something" is not valid.  And drop
the requirement for having trailing whitespace or nothing at all,
as it does not constitute a useful restriction.

Also, fold two regexes together, for economy.
2021-11-03 17:33:45 +01:00
Benno Schulenberg 4d9be13316 syntax: nanorc: add 'execute' menu for unbind, and drop a bad constraint
The coloring rule for 'unbind' still checked for the old 'extcmd' and
'externalcmd' menu names.  And not coloring binds and unbinds as valid
when followed by something other than a comment was overrestrictive,
because the bind or unbind command would work just fine.

(Nano silently allows trailing garbage on any line without a regex.)

Also, take the opportunity to order the menu names in the bind and
unbind rules in the same way.

This fixes https://savannah.gnu.org/bugs/?61419,
and fixes https://savannah.gnu.org/bugs/?61420.

First bug existed since version 5.0, commit d9106abf.
Second bug existed since version 2.3.3, commit 9c11ba93.
2021-11-03 16:57:27 +01:00
Benno Schulenberg 52d4b96639 docs: mark options -z, --suspendable, and 'set suspendable' as obsolete 2021-10-31 10:55:07 +01:00
Benno Schulenberg b46c8c586b build: include the YAML syntax file among the distributed files
(It would be much better if the build rules automatically included
any *.nanorc files in the syntax/ directory into the tarball...)

This fixes https://savannah.gnu.org/bugs/?61391.
Reported-by: John Prokos <jprokos@gmail.com>

Bug existed since version 5.9, commit c2790a8a.
2021-10-27 11:58:52 +02:00
Benno Schulenberg 0e1d45dc36 tweaks: fold some regexes together, and trim or improve some comments
Also, trim some whitespace and group one rule better.

Also, fix a stray closing parenthesis in the JSON syntax,
and add the missing slash to the possible escaped characters.
(Reference: https://www.json.org/json-en.html.)

Also, improve the ending of multiline strings in the Rust syntax.
2021-10-27 11:25:45 +02:00
Benno Schulenberg 1cd92458e9 tweaks: swap two parts of specific regexes, for consistency with others
This order makes more sense to me: first the part that allows
almost everything, and then the special case.
2021-10-27 11:20:07 +02:00
Benno Schulenberg 7bd68365ec syntaxes: avoid coloring "this\" as if it were a valid string
A backslash should not be allowed inside a quoted string unless
it is used to escape another character.

This fixes https://savannah.gnu.org/bugs/?61389.

Bug existed since each of these syntaxes was introduced.

(Awk and Fortran do not know include files with names between
angled brackets, so those regexes are dropped in the bargain.)
2021-10-26 14:35:40 +02:00
Benno Schulenberg 485eb18d83 syntaxes: use one regex for coloring quoted strings, to avoid overlap
Quoted strings cannot start within another quoted string and end after
that other string has ended.  Therefore single-quoted and double-quoted
strings should (as much as possible) be colorized by a single rule, so
that overlapping colorations are avoided.

(This also fixes a double typo in the PHP syntax (\. --> \\.) that has
been there since the PHP syntax was added in 2008, commit 90ee8ee4.)

This fixes https://savannah.gnu.org/bugs/?61387.

Bug existed since each of these syntaxes was introduced,
the oldest ones around 2006, a few others around 2015.

The one that got it right was the Lua syntax from 2011.
2021-10-26 13:28:33 +02:00
Benno Schulenberg 375b30507e syntax: ruby: colorize embedded documentation as a comment
Vim and Emacs do this too.

Reference:
  https://en.wikibooks.org/wiki/Ruby_Programming/Syntax/Lexicology

Also, when colorizing double-hashed comments specially anyway,
avoid colorizing ##.* as a single-hashed comment.
2021-10-25 13:45:21 +02:00
Benno Schulenberg 7691527f35 tweaks: remove redundant parentheses, trim comments, fold some regexes 2021-10-25 12:45:45 +02:00
Benno Schulenberg 3313fac8eb tweaks: remove redundant pair of parentheses, and swap two alternatives 2021-10-25 12:45:45 +02:00
Benno Schulenberg e52c81f5db syntax: nanorc: improve the file-matching regex
The "\.?" part was pointless.  It says that the string "nanorc"
*might* be preceded with a period.  Sure, but if the period is
absent, then anything else may be there too, so the optional
period gives zero restriction.

The restriction should be: either the filename has the extension
".nanorc" OR the full filename is "nanorc".  So the "nanorc" part
must be preceded by either a period or a slash.

(However, in the times of commits 3dc0e23e and dc9c40a5, fifteen
and eighteen years ago, it was still the user-provided filename
that was matched against the regex, not the full-path filename.
The latter method arrived in commit ec8d51be, six years ago.)
2021-10-25 12:44:28 +02:00
Benno Schulenberg d57bfc057f syntax: rust: do not colorize as string the text between two strings
Strings may not contain a double quote unless it is escaped.

Reference:
  https://doc.rust-lang.org/reference/tokens.html#string-literals

(This will still not colorize multi-line strings with an unescaped
newline, will still colorize "this\" as if it were a valid string,
and will still miscolor things when there is another string after
the closing quote of a two-line string.  But those things can't
be helped -- line-based regexes cannot emulate a full parser.)

This fixes https://savannah.gnu.org/bugs/?61361.
Reported-by: Elias Jonsson <e@ejon.eu>

Bug existed since version 2.6.1, since the Rust syntax was introduced.
2021-10-22 10:44:49 +02:00
Benno Schulenberg 0dbe857ba2 syntaxes: undouble the backslash within bracket expressions
Within a bracket expression, the backslash is not special,
so it does not need to be escaped.

The double backslashes within brackets were found with:

  grep -o  '\[[^][]*\\\\[^][]*\]'  syntax{,/extra}/*rc

Also, incorporate the square brackets into some bracket expressions
by listing the closing bracket first, saving a separate regex for
those two brackets.
2021-10-18 12:14:05 +02:00
Benno Schulenberg 483538f8f3 syntax: email: use a character class, as \s does not work inside brackets
This fixes https://savannah.gnu.org/bugs/?61347.

Bug existed since version 4.9.3, commit 4f9bebdd.
2021-10-18 11:52:05 +02:00
Benno Schulenberg b9f472a905 syntax: texinfo: be more precise in colorizing @commands
An @command must either start at the beginning of the line and be
followed by whitespace or EOL, or it must be followed by a brace.
Colorizing just any "@text" string colored too much.
2021-10-17 12:25:01 +02:00
Benno Schulenberg badf3edc55 syntax: texinfo: colorize the special @-plus-punctuation commands too
Also, allow an @} and another @command{} within a pair of braces,
colorize only the valid @-commands with uppercase in their names,
unbold enclosed command arguments, colorize the directory entries
for the manual, and properly colorize also the comments that use
the full @comment command.

Reference:
  https://www.gnu.org/software/texinfo/manual/texinfo/html_node/Command-List.html

Testing was done with:
  info texinfo @-C "Command List" --output=list
  sed -i -e "s/^'//" -e "s/'$//" list
  nano list -Ytexinfo
2021-10-16 17:03:45 +02:00
Benno Schulenberg 4ac932bd21 syntaxes: drop three redundant end-of-line anchors
Also fold two regexes into one, for conciseness.
2021-10-15 10:17:28 +02:00
Benno Schulenberg 2f216281e7 syntax: yaml: allow slash and period in key names
Some Yaml files use path names and sometimes version numbers as keys,
even though / and . are not officially in the character set allowed
for key names (just like underscore is not), as far as I understand.

Also, do not colorize any backslash escapes as invalid
because some of them occur sometimes in value strings.

Also, colorize only the valid double-exclamation tags.
2021-10-03 15:38:43 +02:00
Benno Schulenberg 9459030d66 syntax: yaml: allow any character in tags except whitespace
This will colorize also invalid tags, but the rules are too complicated
to catch in a simple regex.

See https://yaml.org/spec/1.2.2/#691-node-tags.
2021-10-03 10:41:03 +02:00
Benno Schulenberg f545735638 syntax: yaml: colorize the two known directives
See https://yaml.org/spec/1.2.2/#68-directives.

Also, recognize a Yaml file from a %YAML directive on the first line.
2021-10-03 10:14:04 +02:00
Benno Schulenberg 675ad6386d syntax: yaml: colorize the question mark of complex mappings too
See https://yaml.org/spec/1.2.2/#22-structures, example 2.11.

Also make the dash more visible by bolding it.
2021-10-02 17:15:50 +02:00
Benno Schulenberg 6ce3487b65 syntax: yaml: colorize backslash-escaped characters as valid or invalid
See https://yaml.org/spec/1.2.2/#57-escaped-characters.

Also prevent an escaped double quote from breaking the coloring of
a string, and allow hyphens in an anchor.
2021-10-02 17:15:32 +02:00