diff options
-rw-r--r-- | main.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/main.c b/main.c index 5aa7a9e..7743de8 100644 --- a/main.c +++ b/main.c @@ -356,9 +356,22 @@ void markup_inline(InlineState *ms, Str *out, Str src, Arena *scratch, Arena *pe str_catc_html(out, src.s[i], perm); } } else { + Str skp = str_skip(src, i); if (c == '`') im_op(ms, out, IM_CODE, scratch, perm); else if (c == '*') im_tog(ms, out, IM_ITAL, scratch, perm); - else if (str_starts(str_skip(src, i), S("---"))) { + else if (str_starts(skp, S("[["))) { + skp = str_skip(skp, 2); + Str f = str_find(skp, S("]]")); + Str lnks = { skp.s, f.n ? f.s - skp.s : skp.n }; + Cut lnk = str_cut(lnks, '|'); + str_cat(out, S("<a href="), perm); + str_cat_uri(out, lnk.tail.n > 0 ? lnk.tail : lnk.head, perm); + str_catc(out, '>', perm); + markup_inline(ms, out, lnk.head, scratch, perm); + str_cat(out, S("</a>"), perm); + if (!f.n) break; + i = f.s - src.s + 2; + } else if (str_starts(skp, S("---"))) { str_cat(out, S("—"), perm); i += 2; } else { @@ -510,7 +523,7 @@ void usage(const char *cmd) { " -c --css embed the given file within a <style> element\n" " -l --link when combined with --css, link to an external stylehseet\n" " instead of reading from a file locally\n" - " -i --inline enable inline formatting (*italics*, `code`, ---dashes)\n" + " -i --inline enable inline formatting (*italics*, `code`, ---dashes, [[links]])\n" " -q --smartq enable smart quotes\n" " -t --title set the document title (does nothing without --standalone)\n" " -L --lang set the document's language\n", |