author | Olivier Brunel
<jjk@jjacky.com> 2023-01-06 17:27:08 UTC |
committer | Olivier Brunel
<jjk@jjacky.com> 2023-01-06 17:27:08 UTC |
parent | 2b76e4d336671d48fcc5705b716507d3287a67ea |
main.c | +13 | -3 |
diff --git a/main.c b/main.c index eb3126b..3f35b2f 100644 --- a/main.c +++ b/main.c @@ -89,6 +89,7 @@ struct ctx { size_t ofooter; int flags; } doc; + const char *manurl; struct { stralloc sa; size_t salen; @@ -954,9 +955,13 @@ leave_span(MD_SPANTYPE type, void *details, void *ctx_) file = NULL; } - if (file) { + if (file || ctx->manurl) { if (!raw_str(ctx, "<a href=\"") - || !escape_text(ctx, file, strlen(file)) + || (!file && !raw_str(ctx, ctx->manurl)) + || !raw_text(ctx, s, l) + || !raw_text(ctx, ".", 1) + || !raw_text(ctx, buf + 1, 1) + || !raw_text(ctx, ".html", 5) || !raw_str(ctx, "\">") || !raw_text(ctx, s, l) || !raw_str(ctx, buf) @@ -1320,6 +1325,7 @@ help(void) " -I, --inline-css Use inline CSS instead of external files\n" " -i, --index Force index mode\n" " -l, --lang LNG Set LNG as language attribute\n" + " -M, --man-url URL Use URL as prefix for external man-page links\n" " -o, --overwrite Overwrite destination files if already exist\n" " -s, --subtitle TEXT Set TEXT as general subtitle\n" " -T, --no-toc Don't write a TOC on each page. Implies --no-index\n" @@ -1369,6 +1375,7 @@ main (int argc, char *argv[]) { "inline-css", no_argument, NULL, 'I' }, { "index", no_argument, NULL, 'i' }, { "lang", no_argument, NULL, 'l' }, + { "man-url", required_argument, NULL, 'M' }, { "overwrite", no_argument, NULL, 'o' }, { "subtitle", required_argument, NULL, 's' }, { "no-toc", no_argument, NULL, 'T' }, @@ -1376,7 +1383,7 @@ main (int argc, char *argv[]) { "no-index", no_argument, NULL, 'X' }, { NULL, 0, NULL, 0 }, }; - while ((c = getopt_long(argc, argv, "a:bCc:d:F:H:hIil:os:Tt:X", opts, NULL)) != -1) switch (c) { + while ((c = getopt_long(argc, argv, "a:bCc:d:F:H:hIil:M:os:Tt:X", opts, NULL)) != -1) switch (c) { case 'a': ctx.doc.author = optarg; break; @@ -1409,6 +1416,9 @@ main (int argc, char *argv[]) case 'l': ctx.doc.lang = optarg; break; + case 'M': + ctx.manurl = optarg; + break; case 'o': ctx.options |= OPT_OVERWRITE; break;