commit c3aa884144bb173073c6b973835a266bae27bf1e
parent b54a100d7156ea279641a9e779b7658c42300fe9
Author: René Wagner <rwagner@rw-net.de>
Date: Fri, 9 Apr 2021 21:38:45 +0200
minor improvements in rendering alt text
Diffstat:
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/src/gmnlm.c b/src/gmnlm.c
@@ -639,7 +639,7 @@ do_prompts(const char *prompt, struct browser *browser)
goto exit;
case 'a':
browser->alttext = !browser->alttext;
- fprintf(browser->tty, "Alttext instead of preformatted block is now %s\n", browser->alttext ? "ENABLED" : "DISABLED");
+ fprintf(browser->tty, "Alttext instead of preformatted block is now %s\n\n", browser->alttext ? "ENABLED" : "DISABLED");
result = PROMPT_AGAIN;
goto exit;
case 'b':
@@ -945,7 +945,7 @@ display_gemini(struct browser *browser, struct gemini_response *resp)
fprintf(out, "\n");
char *text = NULL;
int row = 0, col = 0;
- bool no_alttext;
+ bool alttext_printed;
struct gemini_token tok;
struct link **next = &browser->links;
// When your screen is too narrow, more lines will be used for helptext and URL.
@@ -973,20 +973,19 @@ repeat:
}
break;
case GEMINI_PREFORMATTED_BEGIN:
- if (text == NULL && browser->alttext) {
- if (tok.preformatted == NULL) {
- no_alttext = true;
- } else {
- fprintf(out, " A %s", ANSI_COLOR_GRAY);
- text = tok.preformatted;
- }
+ alttext_printed = false;
+ if (text == NULL && browser->alttext && tok.preformatted != NULL) {
+ fprintf(out, " A %s", ANSI_COLOR_GRAY);
+ text = trim_ws(tok.preformatted);
+ alttext_printed = true;
}
break;
/* fallthrough */
case GEMINI_PREFORMATTED_END:
continue; // Not used
case GEMINI_PREFORMATTED_TEXT:
- if (text == NULL && (!browser->alttext || no_alttext)) {
+ if (alttext_printed) continue;
+ if (text == NULL) {
fprintf(out, " P %s", ANSI_COLOR_GRAY);
text = tok.preformatted;
}