From 40e28657056a76a5a99a22abd1f35e9c24fa710a Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Thu, 1 Jul 2021 21:01:02 +0200 Subject: [PATCH] [gemini] One link per line. Fix for links without descriptions. --- src/document/gemini/renderer.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/document/gemini/renderer.c b/src/document/gemini/renderer.c index 37985b595..30c0a36db 100644 --- a/src/document/gemini/renderer.c +++ b/src/document/gemini/renderer.c @@ -73,14 +73,15 @@ convert_single_line(struct string *ret, struct string *line) if (line->length >= 2 && !strncmp(line->source, "=>", 2)) { int i = 2; - int begin; + int href; + int inner; add_to_string(ret, "length; ++i) { if (line->source[i] != ' ' && line->source[i] != '\t') { break; }; } - begin = i; + href = i; for (; i < line->length; ++i) { if (line->source[i] == ' ' || line->source[i] == '\t') { @@ -88,17 +89,23 @@ convert_single_line(struct string *ret, struct string *line) } } - add_bytes_to_string(ret, line->source + begin, i - begin); + add_bytes_to_string(ret, line->source + href, i - href); add_to_string(ret, "\">"); + inner = i; + for (; i < line->length; ++i) { if (line->source[i] != ' ' && line->source[i] != '\t') { break; }; } - add_bytes_to_string(ret, line->source + i, line->length - i); - add_to_string(ret, ""); + if (inner == i) { + add_bytes_to_string(ret, line->source + href, i - href); + } else { + add_bytes_to_string(ret, line->source + i, line->length - i); + } + add_to_string(ret, "
"); return; }