diff options
author | June McEnroe <june@causal.agency> | 2020-12-28 22:58:29 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-12-28 22:58:29 -0500 |
commit | fe8ed38249d7dd6c857408238d71f311621cee3e (patch) | |
tree | 06bb3367dc231169c9a7840d1b5523691c7d5915 /bin/hilex/ansi.c | |
parent | Add mdoc lexer (diff) | |
download | src-fe8ed38249d7dd6c857408238d71f311621cee3e.tar.gz src-fe8ed38249d7dd6c857408238d71f311621cee3e.zip |
Generate Tag tokens for mdoc headings
Diffstat (limited to '')
-rw-r--r-- | bin/hilex/ansi.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/bin/hilex/ansi.c b/bin/hilex/ansi.c index fab9c2ed..4b8e1b69 100644 --- a/bin/hilex/ansi.c +++ b/bin/hilex/ansi.c @@ -20,8 +20,9 @@ #include "hilex.h" -static const char *Color[ClassCap] = { +static const char *SGR[ClassCap] = { [Keyword] = "37", + [Tag] = "4", [Macro] = "32", [Comment] = "34", [String] = "36", @@ -30,15 +31,15 @@ static const char *Color[ClassCap] = { static void format(const char *opts[], enum Class class, const char *text) { (void)opts; - if (!Color[class]) { + if (!SGR[class]) { printf("%s", text); return; } // Set color on each line for piping to less -R: for (const char *nl; (nl = strchr(text, '\n')); text = &nl[1]) { - printf("\33[%sm%.*s\33[m\n", Color[class], (int)(nl - text), text); + printf("\33[%sm%.*s\33[m\n", SGR[class], (int)(nl - text), text); } - if (*text) printf("\33[%sm%s\33[m", Color[class], text); + if (*text) printf("\33[%sm%s\33[m", SGR[class], text); } const struct Formatter FormatANSI = { .format = format }; |