Re: [PATCH] syntax: add highlighting for TOML files

Benno Schulenberg <[email protected]> Sun, 22 Feb 2026 13:45:33 +0100
Newsgroups gmane.editors.nano.devel
Message-ID <[email protected]>
Op 22-02-2026 om 11:29 schreef Benno Schulenberg:
>> +color magenta "\<[0-9]+(\.[0-9]+)?\>"
>> +color brightgreen "\<(true|false)\>"
>> +color magenta "\<[0-9]{4}-[0-9]{2}-[0-9]{2}\>"
> 
> Magenta is a rather dark color -- not a good choice in my opinion.

After looking at https://toml.io/en/, I quite like the color scheme
in that "TOML Example" document.  So attached is a modified version
of your patch that comes somewhat close to that scheme.  Do you find
it acceptable?

(One change is: colorizing also the brackets that envelop table headers,
like on https://en.wikipedia.org/wiki/TOML and https://toml.io/en/  --
I find it easier on the eyes, and it helps to distinguish these brackets
from the ones that envelop arrays.)


Benno
0001-syntax-toml-new-file-coloring-rules-for-TOML-files.patch (text/x-patch, 1.5 KB)
From 8db8f1b1b656425ac89132e8648f7c53d8c5cfae Mon Sep 17 00:00:00 2001
From: Vincent Yang <[email protected]>
Date: Sun, 22 Feb 2026 14:12:18 +0800
Subject: [PATCH] syntax: toml: new file -- coloring rules for TOML files

Reference: https://toml.io/en/v1.1.0

Signed-off-by: ...
---
 syntax/Makefile.am |  1 +
 syntax/toml.nanorc | 28 ++++++++++++++++++++++++++++
 2 files changed, 29 insertions(+)
 create mode 100644 syntax/toml.nanorc

diff --git a/syntax/Makefile.am b/syntax/Makefile.am
index 4d992f90..0ed86cf9 100644
--- a/syntax/Makefile.am
+++ b/syntax/Makefile.am
@@ -36,6 +36,7 @@ pkgdata_DATA =	asm.nanorc \
 		tcl.nanorc \
 		tex.nanorc \
 		texinfo.nanorc \
+		toml.nanorc \
 		xml.nanorc \
 		yaml.nanorc
 
diff --git a/syntax/toml.nanorc b/syntax/toml.nanorc
new file mode 100644
index 00000000..85e7e1bd
--- /dev/null
+++ b/syntax/toml.nanorc
@@ -0,0 +1,28 @@
+## Syntax highlighting for TOML files.
+
+## Original author:  Vincent Yang
+## License:  GPL version 3 or newer
+
+syntax toml "\.toml$"
+comment "#"
+
+# Values
+color sage "\<([0-9]+(\.[0-9]+)?|[0-9]{4}-[0-9]{2}-[0-9]{2}[0-9:T-]*)\>"
+color lime "\<(true|false)\>"
+
+# Strings
+color latte ""([^"]|\\.)*"|''([^']|\\.)*''"
+color latte start="\"\"\"" end="\"\"\""
+color latte start="'''" end="'''"
+
+# Keys
+color sky "^[[:space:]]*[^= "][^=]*"
+
+# Table headers
+color orange "^[[:space:]]*(\[[^][]+\]|\[\[[^][]+\]\])"
+
+# Comments
+color italic,cyan "(^|[[:blank:]])#.*"
+
+# Trailing whitespace
+color ,red "[[:space:]]+$"
-- 
2.53.0
OpenPGP_signature.asc (application/pgp-signature, 840 B)
-----BEGIN PGP SIGNATURE-----

wsF5BAABCAAjFiEEFo5vQpe/16ea/USWUUu+Lrjhlh8FAmma+m4FAwAAAAAACgkQUUu+Lrjhlh/i
ehAAtcbznP3mzN0HNaqxvnLtw6BYbPaLHodvsCFCKnD+phi2RXWF8OZjj0DyMQPLBZ4CDwbXRlEp
wBuhPtPXdGmYZ1TPFTNpT0Yyt0MRJIkcKNHPlRSyE7vqsAdnxf/BQAgkzCkT5vUgbs8Z9sn9tUOV
YUYEq6nhHEOZCBG5JXGxoSD2KwdfRWK9vFrIVfiU0Bs2JTJ+5xM6CPfjaWJidREvxEzeZD2piXqV
PuAGoZcEb5IoBQvzGMDkyOG1Vp6y78XVyGTQPswvJw+eL81e3s1+x7OqVbLVU98LxR9DgfVZu1FD
/Gj6xMXPaxCCE/8qVVBFK8rjcMf2Z+7QG8Hroh8fmgzKNGDNhEUYLMeRGYAkkI6uTskXrami2dAs
Kxl5tCBsa5pdwh2GSPg/RS0ZBweyOBYM/27NxDi25NSHllfjh+ybj4nMSDNK9UWXY7+xyo1O/Nh9
tsqGZFhDV4GG9DxbPWyNCFl2dD2UFrO5mxoncngkmlt8CRChhPjvXan3LQ2QcTK/5LgLLt6vuQLg
y6euzZCJ8TpF60wAG3uiMJiP18fPO7x7ShqzyAfWOK6CDKoGsH0H8Fm17iWU04Qu9UkYKOqawac5
FCj/kqA4g88oQJrkdeL1eCiQqMroUqBN8FAj+dZphj17jecYoizWEBO/03INfr4PWLDyzbPA93SJ
g2o=
=I3vA
-----END PGP SIGNATURE-----