From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/32415 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: BPJ Newsgroups: gmane.text.pandoc Subject: Re: How best to determine (in a lua filter) that PDF is being generated? Date: Wed, 29 Mar 2023 10:49:41 +0200 Message-ID: References: Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000024c53805f8060fdc" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22796"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCWMVYEK54FRBMHXR6QQMGQELF4R7UI-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Wed Mar 29 10:49:56 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-yw1-f192.google.com ([209.85.128.192]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1phRVE-0005mi-Ct for gtp-pandoc-discuss@m.gmane-mx.org; Wed, 29 Mar 2023 10:49:56 +0200 Original-Received: by mail-yw1-f192.google.com with SMTP id 00721157ae682-5458dde029bsf149764577b3.13 for ; Wed, 29 Mar 2023 01:49:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1680079795; cv=pass; d=google.com; s=arc-20160816; b=O9DF7BBBWFN4i8Klx6NHP2Y5AQEWNSm6tBRErNWjfxF+6nHjV3skC+Y0H2waHjlPer zU49zKANdhFbl7i+lqohcN8LWxj2mdapwwvkpDMhSlhK8Xm+X/B0xpvJRZmINCg+FLVG mnmBeGj8iLuE5g98Ley4ebatseXVSHnovHu3Y0HENX/lsRnD94MKqncI8k7Q+yySH8XU DhtYmtgLyFEgEr97HBCtFmltrJYVpPfhb4PIXT58T/T6XppOKspSJQphr1PJjhhItzrt lmdgFjx67bu5WE42d5wvNm80mMO1p6Ng5KOSnJs03GRgJDkL183mIj/FTAASiQnGSnzX EzHw== 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:to:subject:message-id:date:from :reply-to:in-reply-to:references:mime-version:sender:dkim-signature; bh=pJ4rkmzMXNAiTd6wJxlbD8pIDgQo3BW3wPFJ4gR0dkE=; b=LOwgo1L6Vk5onR5PbHtEsxyO2T9vNKlyLhBjpXWG1Qe5uJn//b+iQCy+ObuDc51LP/ 2ILVEOaYgP6r5kGrRCSQvwopnYvXVK4/XmyyZ7gkDYV/yyGG3ffC56/tILqmmr5/blAe +S1B6EsjCRDyMYlD4AhekC3O+mCW+APwNw78wO21g+Uc2AW2juLQ4ujfRTbBVGN4LtHn rT30iuTSOqix4qFuR7qwSeQ7+eP9CQ9AxJyRUn2sjl4VvZewspPdkX/QWzwJVerxlXv4 c+rRe9OTIJyKKvg2UZ2h71/aj1lVWJL7MSz7pS3HQdAhJvUE6nmwjqjqVtSPBMsO4YTR q0NQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 209.85.128.169 as permitted sender) smtp.mailfrom=melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; t=1680079795; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:to:subject:message-id:date:from:reply-to :in-reply-to:references:mime-version:sender:from:to:cc:subject:date :message-id:reply-to; bh=pJ4rkmzMXNAiTd6wJxlbD8pIDgQo3BW3wPFJ4gR0dkE=; b=TxfPeuzMpGwUrziiXdkPQ0N/yebJ7m5XBXY+QlmIEHzNu2vsHHCCQtTNv+B04QwDQJ i+LMN7BxSexNDmrm06rGb3y3EbWgpmlVRx9oYq2Zxj/3jZFSp8oxMAVDMorqMbuIPGFC hPlLiB6Z2Yjo0/lZWrA5lgqRuyEp39xfOtE+75X2lpXTXnfmzpfDGfi3vTGEeTXYbX3/ eAk9aOSSOhV9opmE6116V/88AfdywlpgA8fGkrBFDDFnem/J2HPSg2TvHWLoKDGhUUvD 1FncpD30DflFE41Oe+M5g70lUqAMj2+DtwQ5kRdVHzL4RxSbN2JqeENbKxyooWhqUeQa oANg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680079795; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:to:subject :message-id:date:from:reply-to:in-reply-to:references:mime-version :x-gm-message-state:sender:from:to:cc:subject:date:message-id :reply-to; bh=pJ4rkmzMXNAiTd6wJxlbD8pIDgQo3BW3wPFJ4gR0dkE=; b=nimKgMBuD/9sVeXC1w7ut1lDstxFqP8s7hA49R8/MzvIGl+FE/9BhVGqcUDkD7sRNl /i7l3txFt1jmHiMumL/FTQiJW6HkzM0rnU+/Z/Nvgcv9Wnw41x5rtHLbQouw6FrLEXZ5 LSYEWH6khZXOWV1pbuQNsiUcjqmGXGAU9gnKHboYz/F5ZC3VDsRZu3Bn9K75RokdyfsG c9j7it0VSSbU89H7Ut7PA/eSVA9AON7jjdBqgduZoZygggWnAMiynBqIaysaLDS0Po8F YGgtXijcXlMfqU8zi/DaDtKtU88+PCj5 Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AAQBX9eGizyR/6CKoi81rYAJ7h6MDbPEWXG9Aei/rkrpIRB7pToE5HfK CF2YQq5xmxw0PrDVrJMgFrDgUg== X-Google-Smtp-Source: AKy350YiomFfswf+JDO5ssNXoFePGbQfihNb1B3mLT65CTCfphKhA1zdjf53fBBnl1xK1O/e38z1cw== X-Received: by 2002:a05:690c:dd0:b0:533:a15a:d33e with SMTP id db16-20020a05690c0dd000b00533a15ad33emr1016639ywb.5.1680079795403; Wed, 29 Mar 2023 01:49:55 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6902:1890:b0:b6a:10ba:6aeb with SMTP id cj16-20020a056902189000b00b6a10ba6aebls9469819ybb.10.-pod-prod-gmail; Wed, 29 Mar 2023 01:49:51 -0700 (PDT) X-Received: by 2002:a25:3c4:0:b0:b5f:f7e4:1ffd with SMTP id 187-20020a2503c4000000b00b5ff7e41ffdmr20185881ybd.13.1680079791640; Wed, 29 Mar 2023 01:49:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680079791; cv=none; d=google.com; s=arc-20160816; b=GisxQ/+auTVeXTCkYIefAtviQYQidgzia50XhiaHH6DnsXmMNgfyfTozzhg3nX4+oO opKD0kKcbw9owteTuWB4/UhLdhiVKGpLkpbSdImFO+QZa95J8pwT5GB/4rTr3q+9ZB3C m4EY4NLRyLt1KsJnGZc6OS4xkPPPyI9/D8FmmcMiXyjwO+ZtEeydW6kXhabQGkGayfZG UxygzJdcbzTyYfWsArPTI+6Qhd5MVQtP19rnIXDV6bLyFGQabVQbd7QNIEemUTKbAvtQ ICSkFs3lesOhyRHJuHKBRmFR8/9q10OpF+2Y2w4+SnvJD459iYfeeJSz8kgdpTMerT8K Tuww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:reply-to:in-reply-to:references :mime-version; bh=j9q8gQhw34IFQA5P+JJ/354AruhrmhQirvrSm+ZscnU=; b=hgfAGmexZZQfqzsADqXuGwNj2sEtfZ87K03idGyRHqXnUzeuZCoFdm+j54K+sKtoYk Qt5o4zTQT+zulsthUWbSjZkd55I9JQqIoivmOAvSONbi9CdYpDNiPy3hn23VYwqpjmAE tPqOdsMvAFKU3+RqnUCTxELOcHCQtvABqOEkdlqWXDzXduQJnkJrHHHzX1/DV6NP24CL Mx13XR0z8FBCOhTI3w5TOb+tqROJf2y96Bg6hkJmrnl0xsFO0o4cRFgoTk3X7Ml92V3/ yOgtVDIo5CRDQrol9HB1SabjO6kYY1s7ackagnhx8GOzPEhNdiW1ZRwSo3DhN7hfwk03 wnKA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 209.85.128.169 as permitted sender) smtp.mailfrom=melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org Original-Received: from mail-yw1-f169.google.com (mail-yw1-f169.google.com. [209.85.128.169]) by gmr-mx.google.com with ESMTPS id ck19-20020a05690218d300b00ac63c777174si2049927ybb.2.2023.03.29.01.49.51 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Mar 2023 01:49:51 -0700 (PDT) Received-SPF: pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 209.85.128.169 as permitted sender) client-ip=209.85.128.169; Original-Received: by mail-yw1-f169.google.com with SMTP id 00721157ae682-5416698e889so280957257b3.2 for ; Wed, 29 Mar 2023 01:49:51 -0700 (PDT) X-Received: by 2002:a81:ef0f:0:b0:545:1d7f:acbf with SMTP id o15-20020a81ef0f000000b005451d7facbfmr8725350ywm.10.1680079791111; Wed, 29 Mar 2023 01:49:51 -0700 (PDT) In-Reply-To: X-Original-Sender: melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 209.85.128.169 as permitted sender) smtp.mailfrom=melroch-Re5JQEeQqe8AvxtiuMwx3w@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:32415 Archived-At: --00000000000024c53805f8060fdc Content-Type: text/plain; charset="UTF-8" Den tis 28 mars 2023 19:38'William Lupton' via pandoc-discuss < pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> skrev: > Hello, > > I'm generating PDF using wkhtmltopdf, so "to" is "html" and I don't see > the PDF engine in any of the globals. Should I just look at the output file > name? > As a last resort I set a 'flag' in metadata and inspect that: ``````lua local make_pdf local Meta = function(meta) -- For use outside this function make_pdf = meta['my-filter-pdf'] if not (make_pdf) then local includes = meta['header-includes'] -- Make sure we have a list if 'List' ~= pandoc.utils.type(includes) then if nil == includes then includes = pandoc.List({ }) else -- Assume the current value makes sense as a meta list item includes = pandoc.List({ includes }) end end includes:insert(pandoc.RawBlock('html', [=[...]=])) meta['header-includes'] = includes return meta end return nil end return { { Meta = Meta }, main_filter } `````` `````` % pandoc -L my-filter.lua -M my-filter-pdf ... `````` At least guaranteed surprise free... > Thanks, > William > > PS, My filter adds some JavaScript to header-includes. I'm doing this as a > RawBlock(html) but I think I need to omit it when the HTML will be > converted to PDF (wkhtmltopdf complains). > > -- > 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/CAEe_xxhU3eFmbb-XT640STjhrhbeWd75SkRf_ggYYZ3Gx1E79Q%40mail.gmail.com > > . > -- 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/CADAJKhDfsFvqD--hJWQ%2BUGoVibGzHKeZ3qaqKUU1yYk5uxxRHQ%40mail.gmail.com. --00000000000024c53805f8060fdc Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


Den tis 28 mars 2023 19:38'William Lupton' via= pandoc-discuss <pand= oc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> skrev:
Hello,

I'm generating P= DF using=C2=A0wkhtmltopdf, so "to" is "html" and I don&= #39;t see the PDF engine in any of the=C2=A0globals. Should I just look at = the output file name?

As a last resort I set a 'flag' in met= adata and inspect that:

``````lua
local make_pdf
=
local Meta =3D function(meta)
=C2= =A0 -- For use outside this function
=C2=A0 make_pdf= =3D meta['my-filter-pdf']
=C2=A0 if not (ma= ke_pdf) then
=C2=A0 =C2=A0 local includes =3D meta[&= #39;header-includes']
=C2=A0 =C2=A0 -- Make sure= we have a list
=C2=A0 =C2=A0 if 'List' ~=3D= pandoc.utils.type(includes) then
=C2=A0 =C2=A0 =C2= =A0 if nil =3D=3D includes then
=C2=A0 =C2=A0 =C2=A0= =C2=A0 includes =3D pandoc.List({ })
=C2=A0 =C2=A0 = =C2=A0 else
=C2=A0 =C2=A0 =C2=A0 =C2=A0 -- Assume th= e current value makes sense as a meta list item
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 includes =3D pandoc.List({ includes })
=C2=A0 =C2=A0 =C2=A0 end
=C2=A0 =C2=A0 e= nd
=C2=A0 =C2=A0 includes:insert(pandoc.RawBlock(= 9;html', [=3D[...]=3D]))
=C2=A0 =C2=A0 meta['= ;header-includes'] =3D includes
=C2=A0 =C2=A0 re= turn meta
=C2=A0 end
=C2=A0 r= eturn nil
end
return {
<= div dir=3D"auto">=C2=A0 { Meta =3D Meta },
=C2=A0 ma= in_filter
}
``````

``````
% pandoc -L my-filter.lua -M my-filter-pdf ...
```= ```

At least guaranteed = surprise free...

Thanks,
William

PS, My filt= er adds some JavaScript to header-includes. I'm doing this as a RawBloc= k(html) but I think I need to omit it when the HTML will be converted to PD= F (wkhtmltopdf complains).

--
You received this message because you are subscribed to the Google Groups &= quot;pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to pandoc-discuss+unsubscribe-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.org= m.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/= CAEe_xxhU3eFmbb-XT640STjhrhbeWd75SkRf_ggYYZ3Gx1E79Q%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups &= quot;pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to pand= oc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://group= s.google.com/d/msgid/pandoc-discuss/CADAJKhDfsFvqD--hJWQ%2BUGoVibGzHKeZ3qaq= KUU1yYk5uxxRHQ%40mail.gmail.com.
--00000000000024c53805f8060fdc--