From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/26320 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: John MacFarlane Newsgroups: gmane.text.pandoc Subject: Re: Custom lua writers and standalone documents Date: Sun, 04 Oct 2020 11:41:12 -0700 Message-ID: References: <66e3e0f4-a77c-4ff6-b71e-68182d95ac2an@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7026"; mail-complaints-to="usenet@ciao.gmane.io" Cc: pandoc-discuss To: William Lupton Original-X-From: pandoc-discuss+bncBCJZJHG45QDBBVNO5D5QKGQEAHAUEPI-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Sun Oct 04 20:41:29 2020 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-pf1-f186.google.com ([209.85.210.186]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kP8wr-0001j0-Ip for gtp-pandoc-discuss@m.gmane-mx.org; Sun, 04 Oct 2020 20:41:29 +0200 Original-Received: by mail-pf1-f186.google.com with SMTP id 8sf4730595pfx.6 for ; Sun, 04 Oct 2020 11:41:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1601836888; cv=pass; d=google.com; s=arc-20160816; b=YZrXKqRXZxB71fR/LQooVjxvJiCkwf4ZrPcMkJn/bUJgU0JoSZNQOHilUszUdnIbIt 4zvr2L8Q57bIV2oj1AYakdm1ZlK35+nadrgrC+/ZEmmsDm/mK/T21vrfYzfYN+mRqEY6 93GEZGrsEd+5wSJBmN2oDAKdg6oCfq9YsTaezU7CtPL5ztybLYWscSpa7+ptMBVLjEj8 baL/9o+6odetLvfSEWPKjQypa1tOC0MBsOgllbhhRqZeYMTJ3j563QOLnLlOm+EUtEZM 5I08ebMQTqAA0xvq3YZyuBP7BzyapbizUkPecwWYvi5WR9G0sv73crHqIti2iqEg9LOx s23A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:mime-version:message-id :date:references:in-reply-to:subject:cc:to:from:sender :dkim-signature; bh=9H+Nsk2Y5OGWxdMHOgnBb6kCvo199OHOJWXlPu7a8dQ=; b=DOY7aJJmLdeLpjPEybtvj9VdR8HHO9bmHLt7GfVJx7T4cQlx2BZ5+VFEhkbiFgLbTo 13vnZHBHvopkuv+1vhxT54pflASGbvCioDaFIUgf6H/JO34WODIop/bS1MjPPcWOmEaW s6+OZ24Mra9zNKZhtI0v+z4s1h/PoZ6b5mynRR0L1/JbCo14sMhkLfbvCJo3YQePKk8M SjxHSSpXSJf0vxSzEFReAnaQulUqKMXMEj7ttGrzKeEPLRuPyf6Xynd6Er78E4vvMOvj Xca8c54RXHHC2gTpxkK3SQTXNn/O+BWRrLOdfsvHBr+iGJoTewYjj9YfR9k9PN4wjyHA Utng== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@berkeley-edu.20150623.gappssmtp.com header.s=20150623 header.b=hdnT2+lu; spf=pass (google.com: domain of jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org designates 2607:f8b0:4864:20::1030 as permitted sender) smtp.mailfrom=jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:in-reply-to:references:date:message-id :mime-version:x-original-sender:x-original-authentication-results :reply-to:precedence:mailing-list:list-id:list-post:list-help :list-archive:list-subscribe:list-unsubscribe; bh=9H+Nsk2Y5OGWxdMHOgnBb6kCvo199OHOJWXlPu7a8dQ=; b=oP9IG8jlyIY/kRDzzvnYQtOeyaIyrTfL10zA370yPS8JazKmYceRZrraKNmNFKEqWp TCeK6AN2/gqW+lXF9wwQwZBOqv4YrZp1nyuQGct4TqlVtvsFbn6Jg6wxetiQYPhzjovu NwI8l+rSgBTemlZuYwlAns56rmoDzL23of3EGD6ebS2UBe7z+Re2fhf/43yYKK/ittKo MzfF0bgG6LAuonEIOsUFJIgX8iB9DmNMV69Oxmhapc7IAnAxz6zE+4+arWsA2GAW7Ptx GuZv3uCtms1YK/nV3UpfZBAcwPJjc7K0m8Q1XVhPC3NYI2BpXiKY0fZsOvQe1deoH3qd dHlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:in-reply-to:references :date:message-id:mime-version:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=9H+Nsk2Y5OGWxdMHOgnBb6kCvo199OHOJWXlPu7a8dQ=; b=jGYp6juI4SZdUQ47pHNS/vE+47Sug53P7jeO9oTW5ZhplgB4XajpodTN7bW6CZrtGt X0LdXtXHVyYQX2McMD8pDv+Zr/yHUz+lwVsZbaYfcpEPwHDdz3EQOGS1hQFMEZG+EU+k WmQzyk7songYOxzaGEI3nZri9FzV0BJpjt7zEiEq5j+up5n41HRY1k2S6FravZhkSzyq R5XCxIYSkx5QEX+CZYv1wQif8XMAlL5Dzb+YnB1cc1oIx65ODLJXpp6T14mZJ5kfdzxM XV+PHW5Q71DwI8i+sYbVqUIUx3S7zh8PuSCbggRThS5CLtuWpL0NGvHPn8bIyo1txPQw OTYw== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM5312PiuO4Shi+TPQdC9hzjXWAeZ7GnNqHLLln6qokz/A2/+Dx6e7 POLfT4FBr4tvDY500iCfRq0= X-Google-Smtp-Source: ABdhPJyQ1UkzqwFJhw0GLFktkFG6RUpDsCv48Dy3ju+SfQSHQol9I1aqRpciEfm1l1rWU1tC5weTQw== X-Received: by 2002:a17:90a:650a:: with SMTP id i10mr6538337pjj.43.1601836888331; Sun, 04 Oct 2020 11:41:28 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6a00:150b:: with SMTP id q11ls1316766pfu.4.gmail; Sun, 04 Oct 2020 11:41:25 -0700 (PDT) X-Received: by 2002:a63:5761:: with SMTP id h33mr11267604pgm.167.1601836884980; Sun, 04 Oct 2020 11:41:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601836884; cv=none; d=google.com; s=arc-20160816; b=mkI/+6jNdtGBchquLU327+ubkFDlz7isWZSTQW3Vvjz4uLVZji86/MdCHDvZCiagSI R2qmKcAJQZ+c4lrWwOsQmQLpF5B7GD8AL84Msm/zUn9oB/n2lHeI9csQ+tGGCLDSgfxI Az+NLfX7cu6sc9r7w4+oct07DHpg5LM+TZG3qkr78rRWlLiLWQaw7n8aXo8GRFSqjI8M V7qR21vRJNRQmraM1KUT9hJJrJg9jubpdofq5RIdTmy99ef/7td6BqBUiwjRKD5gKLGN Flp9Kk79a8I8SlI7ZRWApdIIrnbXZgUAyvIAYNbfwBmnOqcNDUw+UlKRrZpmpHM7pZ3/ YUOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:dkim-signature; bh=CyNSb+OBRZGJvxf3FTOI7FVVPITjHwktup/KdlwG9A4=; b=IhNwyqhCb0VBISgh/8Tk68kaVQhVFZ9jp0/BT+mBQiZ2x3iiZ4kCsvgxUmjuv8f9ot AWiF+WKDe4T4BHJ2hBC6fK/ftOjz5Ulm53Br0XAo6p2+ZeH0jmvVQt40yQjeLMROyT9q LFJbDxEois2tpceanY+bBs8eIHEWUvL/s1tSDus3xgwdzbKCy0T01WwtP4ZTwTFrKFZs ejYZx3lDLqc7joKXPDf2gpo9+qTkPndzRMEU51Bx/36GcTr8Ee996WMfOppbQYOdRbrG fG1xWlxfSe3bCxrHN8LI5h7kZAOUEnvt0dvYQmymsNq09S1D6qCHpIlo6ZfxWfao/Z+m pnvA== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@berkeley-edu.20150623.gappssmtp.com header.s=20150623 header.b=hdnT2+lu; spf=pass (google.com: domain of jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org designates 2607:f8b0:4864:20::1030 as permitted sender) smtp.mailfrom=jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org Original-Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com. [2607:f8b0:4864:20::1030]) by gmr-mx.google.com with ESMTPS id i4si537013pjj.2.2020.10.04.11.41.24 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 04 Oct 2020 11:41:24 -0700 (PDT) Received-SPF: pass (google.com: domain of jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org designates 2607:f8b0:4864:20::1030 as permitted sender) client-ip=2607:f8b0:4864:20::1030; Original-Received: by mail-pj1-x1030.google.com with SMTP id ds1so932827pjb.5 for ; Sun, 04 Oct 2020 11:41:24 -0700 (PDT) X-Received: by 2002:a17:90a:77c1:: with SMTP id e1mr12415081pjs.39.1601836884481; Sun, 04 Oct 2020 11:41:24 -0700 (PDT) Original-Received: from johnmacfarlane.net (li55-134.members.linode.com. [74.82.3.134]) by smtp.gmail.com with ESMTPSA id g9sm8153138pgm.79.2020.10.04.11.41.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Oct 2020 11:41:23 -0700 (PDT) Original-Received: by johnmacfarlane.net (Postfix, from userid 1000) id B1F8CA23F; Sun, 4 Oct 2020 14:41:12 -0400 (EDT) In-Reply-To: X-Original-Sender: jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@berkeley-edu.20150623.gappssmtp.com header.s=20150623 header.b=hdnT2+lu; spf=pass (google.com: domain of jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org designates 2607:f8b0:4864:20::1030 as permitted sender) smtp.mailfrom=jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org Precedence: list Mailing-list: list pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org; contact pandoc-discuss+owners-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org List-ID: X-Google-Group-Id: 1007024079513 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Xref: news.gmane.io gmane.text.pandoc:26320 Archived-At: You can specify a template. However, I don't think there's a way to _set_ template variables from within a custom writer, though your writer can see the variables that were set on the command line via the 'variables' parameter. If you want to propose modifying the custom writing code so writers can set variables, that would be a reasonable request to make at the pandoc bug tracker. The only thing from the command line the custom writer will see is the variables, so the writer can't tell if --table-of-contents was specified. Making writer options available to the custom writers would be another reasonable enhanchement. William Lupton writes: > Also, I specified --table-of-contents on the command line, but didn't see > it set in the writer's Doc() function. Should I have expected to see it? > > On Sun, 4 Oct 2020, 16:54 William Lupton, > wrote: > >> Great. Thanks. I can do this. >> >> But can I then use a template? I didn't mention this earlier, but I tried >> setting some variables in the Doc() function (e.g. 'toc') and they didn't >> seem to be seen by the template. >> >> On Sun, 4 Oct 2020, 16:12 John MacFarlane, wrote: >> >>> >>> The table of contents is generated by the HTML writer. >>> So, if you create a custom writer, you'll have to reproduce >>> this functionality in your writer. >>> >>> William Lupton writes: >>> >>> > Hello, >>> > >>> > % pandoc --version >>> > pandoc 2.9.2.1 >>> > >>> > I want to generate modified HTML for headers (to be specific, I want to >>> add >>> > a link to each header, like Sphinx does), so I decided to create a >>> custom >>> > lua writer. >>> > >>> > I started with the supplied sample.lua and modified the Header() >>> function, >>> > but I find (when I run with --standalone --table-of-contents) that I >>> don't >>> > get a ToC. And when I look at the variables in the Doc() function I >>> don't >>> > see 'toc' or 'table-of-contents'. >>> > >>> > Should I be able do this, or do I have to use my custom writer to >>> generate >>> > a fragment and then run pandoc again to process the fragment and >>> generate >>> > the ToC (I've tried this and it works)? >>> > >>> > Note: I tried to parse this comment in sample.lua Doc(), but am not >>> clear >>> > whether it's saying that I can use --template in the _same_ pandoc >>> > invocation or whether I need to use a separate invocation: >>> > * You could use the metadata table to fill variables in a custom lua >>> > template. Or, pass `--template=...` to pandoc, and pandoc will do the >>> > template processing as usual. >>> > >>> > I can supply more detailed info on request. >>> > >>> > Thanks, >>> > William Lupton >>> > >>> > -- >>> > You received this message because you are subscribed to the Google >>> Groups "pandoc-discuss" group. >>> > To unsubscribe from this group and stop receiving emails from it, send >>> an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> > To view this discussion on the web visit >>> https://groups.google.com/d/msgid/pandoc-discuss/66e3e0f4-a77c-4ff6-b71e-68182d95ac2an%40googlegroups.com >>> . >>> >>