mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-25 14:35:04 +00:00
Minor tweak to markdown-like links.
This commit is contained in:
parent
36969bcf6f
commit
36764b8ade
3 changed files with 12 additions and 7 deletions
11
format.c
11
format.c
|
@ -144,11 +144,16 @@ static xs_str *format_line(const char *line, xs_list **attach)
|
|||
if (*v == '[') {
|
||||
/* markdown-like links [label](url) */
|
||||
xs *w = xs_strip_chars_i(xs_dup(v), "[)");
|
||||
xs *l = xs_split(w, "](");
|
||||
xs *link = xs_fmt("<a href=\"%s\">%s</a>",
|
||||
xs *l = xs_split_n(w, "](", 1);
|
||||
|
||||
if (xs_list_len(l) == 2) {
|
||||
xs *link = xs_fmt("<a href=\"%s\">%s</a>",
|
||||
xs_list_get(l, 1), xs_list_get(l, 0));
|
||||
|
||||
s = xs_str_cat(s, link);
|
||||
s = xs_str_cat(s, link);
|
||||
}
|
||||
else
|
||||
s = xs_str_cat(s, v);
|
||||
}
|
||||
else
|
||||
s = xs_str_cat(s, v);
|
||||
|
|
6
xs.h
6
xs.h
|
@ -277,7 +277,7 @@ int _xs_get_size(const xs_val *ptr)
|
|||
/* must match _XS_TYPE_SIZE */
|
||||
{
|
||||
int i;
|
||||
memcpy(&i, ptr, sizeof(i));
|
||||
memcpy(&i, ptr + 1, sizeof(i));
|
||||
return i;
|
||||
}
|
||||
|
||||
|
@ -299,7 +299,7 @@ int xs_size(const xs_val *data)
|
|||
case XSTYPE_LIST:
|
||||
case XSTYPE_DICT:
|
||||
case XSTYPE_DATA:
|
||||
len = _xs_get_size(data + 1);
|
||||
len = _xs_get_size(data);
|
||||
|
||||
break;
|
||||
|
||||
|
@ -1286,7 +1286,7 @@ xs_data *xs_data_new(const void *data, int size)
|
|||
int xs_data_size(const xs_data *value)
|
||||
/* returns the size of the data stored inside value */
|
||||
{
|
||||
return _xs_get_size(value + 1) - (1 + _XS_TYPE_SIZE);
|
||||
return _xs_get_size(value) - (1 + _XS_TYPE_SIZE);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
/* 65769f25ed99b886a643522bef21628396cd118d 2024-05-25T08:18:51+02:00 */
|
||||
/* e148ab08d5a55ac7bd30ff900f5eb048a57e21af 2024-05-27T05:33:01+02:00 */
|
||||
|
|
Loading…
Reference in a new issue