diff --git a/src/gmnlm.c b/src/gmnlm.c
index 82d7abc15562ad7ee4fe5f7e5349be477f719ae5..cb7e2843798f66f596e071823d9e41153a555fcc 100644
--- a/src/gmnlm.c
+++ b/src/gmnlm.c
@@ -19,6 +19,14 @@ #include <gmni/tofu.h>
#include <gmni/url.h>
#include "util.h"
+#define ANSI_COLOR_RED "\x1b[31m"
+#define ANSI_COLOR_GREEN "\x1b[32m"
+#define ANSI_COLOR_YELLOW "\x1b[33m"
+#define ANSI_COLOR_BLUE "\x1b[34m"
+#define ANSI_COLOR_MAGENTA "\x1b[35m"
+#define ANSI_COLOR_CYAN "\x1b[36m"
+#define ANSI_COLOR_RESET "\x1b[0m"
struct link {
char *url;
struct link *next;
@@ -767,7 +775,7 @@ if (searching) {
out = fopen("/dev/null", "w+");
}
char *text = NULL;
int row = 0, col = 0;
struct gemini_token tok;
@@ -776,20 +784,20 @@ while (text != NULL || gemini_parser_next(&p, &tok) == 0) {
repeat:
switch (tok.token) {
case GEMINI_TEXT:
col += fprintf(out, " ");
col += fprintf(out, " ");
if (text == NULL) {
text = tok.text;
}
break;
case GEMINI_LINK:
if (text == NULL) {
col += fprintf(out, "%d) ", nlinks++);
col += fprintf(out, "%2d> %s", nlinks++, ANSI_COLOR_CYAN);
text = trim_ws(tok.link.text ? tok.link.text : tok.link.url);
*next = calloc(1, sizeof(struct link));
(*next)->url = strdup(trim_ws(tok.link.url));
next = &(*next)->next;
} else {
col += fprintf(out, " ");
col += fprintf(out, " ");
}
break;
case GEMINI_PREFORMATTED_BEGIN:
@@ -799,6 +807,7 @@ case GEMINI_PREFORMATTED_END:
continue; // Not used
case GEMINI_PREFORMATTED_TEXT:
if (text == NULL) {
fprintf(out, " ");
text = tok.preformatted;
}
break;
@@ -807,34 +816,33 @@ if (!browser->page_title) {
browser->page_title = strdup(tok.heading.title);
}
if (text == NULL) {
for (int n = tok.heading.level; n; --n) {
col += fprintf(out, "#");
}
switch (tok.heading.level) {
case 1:
col += fprintf(out, " ");
col += fprintf(out, "%s%s", " # ", ANSI_COLOR_RED);
break;
case 2:
col += fprintf(out, "%s%s", " ## ", ANSI_COLOR_YELLOW);
break;
case 3:
col += fprintf(out, " ");
col += fprintf(out, "%s%s", "### ", ANSI_COLOR_GREEN);
break;
}
text = trim_ws(tok.heading.title);
} else {
col += fprintf(out, " ");
col += fprintf(out, " ");
}
break;
case GEMINI_LIST_ITEM:
if (text == NULL) {
col += fprintf(out, " %s ",
col += fprintf(out, " %s ",
browser->unicode ? "•" : "*");
text = trim_ws(tok.list_item);
} else {
col += fprintf(out, " ");
col += fprintf(out, " ");
}
break;
case GEMINI_QUOTE:
col += fprintf(out, " %s ",
col += fprintf(out, " %s ",
browser->unicode ? "┃" : ">");
if (text == NULL) {
text = trim_ws(tok.quote_text);
@@ -878,6 +886,7 @@ ++row;
}
++row; col = 0;
fprintf(out, ANSI_COLOR_RESET);
if (browser->pagination && row >= ws.ws_row - 4) {
char prompt[4096];
char *end = NULL;
text/gemini
This content has been proxied by September (ba2dc).