1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

[gemini] One link per line. Fix for links without descriptions.

This commit is contained in:
Witold Filipczyk 2021-07-01 21:01:02 +02:00
parent 5ed65c8733
commit 40e2865705

View File

@ -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, "<a href=\"");
for (; i < line->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, "</a>");
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, "</a><br/>");
return;
}