diff --git a/src/gmnlm.c b/src/gmnlm.c

index c56f3a2d393b7d475f3b859a9a8ed4ca922186a3..f93ae642c8c641c9718f8ee849b0f666bdcd2869 100644

--- a/src/gmnlm.c

+++ b/src/gmnlm.c

@@ -639,7 +639,7 @@ result = PROMPT_ANSWERED;

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 @@

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 @@ col += fprintf(out, " ");

}

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;

}