Welcome to little lamb

Code » qmdoc » commit cf8ed43

Fix current page title

author Olivier Brunel
2022-12-26 19:40:38 UTC
committer Olivier Brunel
2022-12-26 19:40:38 UTC
parent f74f0f52a3a3605e3612f1ce60fd1e7e7e32b9a4

Fix current page title

main.c +4 -2

diff --git a/main.c b/main.c
index 6e74073..6f898c3 100644
--- a/main.c
+++ b/main.c
@@ -64,6 +64,7 @@ struct ctx {
     struct css *css;
     struct page *pages;
     int nb_pages;
+    int cur_page;
     struct {
         int flags;
         int from;
@@ -195,8 +196,8 @@ enter_block(MD_BLOCKTYPE type, void *details, void *ctx_)
                 if (r < 0) return r;
                 r = raw_str(f, "<title>");
                 if (r < 0) return r;
-                r = escape_text(f, ctx->sa_names.s + ctx->pages[0].titleoff,
-                                strlen(ctx->sa_names.s + ctx->pages[0].titleoff));
+                r = escape_text(f, ctx->sa_names.s + ctx->pages[ctx->cur_page].titleoff,
+                                strlen(ctx->sa_names.s + ctx->pages[ctx->cur_page].titleoff));
                 if (r < 0) return r;
                 r = raw_str(f, "</title>");
                 if (r < 0) return r;
@@ -843,6 +844,7 @@ main (int argc, char *argv[])
         ctx.out = fdopen(fd, "we");
         if (!ctx.out) strerr_diefu5sys(-ERR_IO, "open '", destdir, "/", dst, "'");
 
+        ctx.cur_page = i - optind;
         int r = convert_file(sce, &ctx);
         if (r < 0) return -r;