From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/32416 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "'William Lupton' via pandoc-discuss" 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:04:26 +0100 Message-ID: References: Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000f290c005f80643f8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31965"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBCS4HJ6WSAHBBJX6R6QQMGQEWUNIQ6A-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Wed Mar 29 11:04:45 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-lj1-f188.google.com ([209.85.208.188]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1phRjW-00080M-Tb for gtp-pandoc-discuss@m.gmane-mx.org; Wed, 29 Mar 2023 11:04:42 +0200 Original-Received: by mail-lj1-f188.google.com with SMTP id b5-20020a2ebc05000000b00295bab7c7d0sf3218916ljf.15 for ; Wed, 29 Mar 2023 02:04:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1680080682; cv=pass; d=google.com; s=arc-20160816; b=RSJKPvpD2MV+9GK9vXD+1jvxjKoPG75t7qTl3IlEqZlPuQWvhToFY4aXjTc3BJ/0gA l8j7K/cOOoGfXpzxYlK875o8eaiaveklJSJPLzlmjfeKoidXFLmeTDNXOyqAI3SBaVbK f/0MIQqK7kbreCLP2843H9ReYEpWECQ9OFIRmdfgYP2S9F8VVDEdz3nriFF+f2BmMq3G J95ToIxkNdk6I+O5ux2Wxx9tDAloxfUEnujeyH4/nLasC2iplLRwv+Cus+uZnMUcn9YU qLf31hf27nMmBW1TqunEZLg8kxobkDhUDS4SFocgU0jl/B9q00Txce6F8mpJF/tsnukO ikgw== 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:to:subject:message-id:date :from:in-reply-to:references:mime-version:dkim-signature; bh=cxmO11ZD8n3H8R/jB6Gfa9Xu3B+fRrMv78ZFGwiFl78=; b=dx6pyb9tOlx4xOfM1v++c5z2SiTowXrIhSBMxv4CFVO8aZuDdsz0r6jeOZclqxflQG RDBteFeGZCVDxVujBuGBjOTEPLp7nNzeck6ZIeuq91yX2WUK2pZqiZZg2d6NtwKQcw4B KTrEjFQkqW1VQ/9Wef7f7ZldzvF+jwjNVz7sz8Ar5scDEtXSvjQMy5jt0plf/jGp3+99 Wqia5VS2nyz4JyE+bZ4CthapY237KHW6h0Fzw4iUmE36Yz8yKAsBnY+yt84iWX6M/cR1 kLH2UqspGuUMiMNmiHTDwBVqLdcb80cM53jMQ5qUiQ0eCCzyBMfF1ape9qnt3QpB5KiK JaMQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@broadband-forum.org header.s=google header.b=CFZmdYZA; spf=pass (google.com: domain of wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org designates 2a00:1450:4864:20::52e as permitted sender) smtp.mailfrom=wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadband-forum.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; t=1680080682; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:to:subject :message-id:date:from:in-reply-to:references:mime-version:from:to:cc :subject:date:message-id:reply-to; bh=cxmO11ZD8n3H8R/jB6Gfa9Xu3B+fRrMv78ZFGwiFl78=; b=OVpJ5E4lTuwN365lSF6Z6u4KoPZO8Jcd7ePc6u/qjlhmmj3Q2psKo9BWTvynMRRRO3 2ckJe74SK4/gxlwuWmlVFJRHrvDpS7SAKV4eO3VkFhhUHO6mDviLajWq6VJay6WXNHyj ROM1jV7bHBpBHhj/ZcQpiLt4FzIB5bwSQ5fhCiDzJir8DH7PFIM7K4a1VzOokjeT8+lP uxe0piKH7swxMSxD80RUlglls9EwBPTHOjYjkxlplVgNu9+9lfx+5VaXdRdqVrFUZR7p DyW3LYw5EEqnhdAghYyM0RR+410BYE1UcypADROEtD2RIjk221n7cD2fZ+Z7XtAUXJ2x PC8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680080682; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:to:subject :message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cxmO11ZD8n3H8R/jB6Gfa9Xu3B+fRrMv78ZFGwiFl78=; b=ler+BYpHlugM4tyi60R476sxDiI6bLK+3ei1m8muFscWk/h17ctmNkB/b25mP+Wcy6 uxqx4jRcUB+CRuijsuI0i/W8OgDqvu7qtUsyw+UZytwhviX3azFTwkZtnn58dKf0qaQe J4Sil+Xma/yk1guoO4twd9I11u4SPWChiwb3GYwNz3WgdSLv52F+aS96vPf/8reMH99e qudIfsDAz5cQHctCCpMmrDsmteX1AYofJkkLH8liPhI+5yhIxPUuMidwIGakiUM+QrfU EGsz6mx3HKCYg6wDdoMiKOR50HSGLpy3rRD8dffTG2jEIF+GZ X-Gm-Message-State: AAQBX9fkOAiuliERptXr5zqv7SCPXnkDqMQSXNc8XSsHLvS+LpghFn35 6lkcIfduYBEh4PFHYuvzpIo= X-Google-Smtp-Source: AKy350afeiX0mNLaIpAFtxXfRyTqd37v7tY9oQMDQqMOAwixl1pRPt01Y9/9+HXjbEtchliFPGXZgg== X-Received: by 2002:a05:6512:15b:b0:4ea:fa77:e436 with SMTP id m27-20020a056512015b00b004eafa77e436mr5467707lfo.6.1680080682397; Wed, 29 Mar 2023 02:04:42 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6512:1585:b0:4e9:c006:ce26 with SMTP id bp5-20020a056512158500b004e9c006ce26ls150114lfb.3.-pod-prod-gmail; Wed, 29 Mar 2023 02:04:37 -0700 (PDT) X-Received: by 2002:ac2:46d8:0:b0:4e1:7d1c:85ce with SMTP id p24-20020ac246d8000000b004e17d1c85cemr5164194lfo.27.1680080677734; Wed, 29 Mar 2023 02:04:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680080677; cv=none; d=google.com; s=arc-20160816; b=is89WWt3XYiDA2zGofNPXLFnmZ+7EX4vEuQ0bEHtP5hq23kEvx9I0YgoHx2wG3l0uU TgvPGfpeWAOVWSirGsOYkgxbLposQl6qU/5jLLSW0BE17AkCOIc5q1RV+DnMZIi0M3gC gpzHZkWHWfOP4LvX5m553N53C5qTuqkYqhO8RV9G/2/wm9/gOCgbKMeCzSqw7BSQjiLU WPSpwKjfGJdlwUWHGcSif28TdiQDTGVH08sHP18yFqSYukmsUe9HPOdlZer1ngNPXsuy pkw4zxIPJ333XsFKk5b8MO9Gk1u6X14qlKnyKVBhC2VfB9lr4GdmkpNAJtUHeNXWSw6+ iQEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=jWcyp+JpVrRM/rujXDuzlUJEcda8hQPbJOp9jlLkBL8=; b=Jf+5nrDOGDpJIS1e0qHo3pPk2ZM/zsdMJEjR1vgkVxgpShiMSqjxK0Xn9kC6Lh7hDN zFzWW6gtDRbiKV/wCJs5N8QAyL2OsDNryeWjHatayuSwO9ovz+hLmtftM4vKOSQ9mc7U RxVzZn5JB1oxxEbf9yB0jcsb7PfGKfS6zVVPn35z2QfE6QK/T8X5g3BGJDd7d6IJ6UEg 85R0PPsWHNagrar52KtXSUgWzxrI3xKG87m2jYgqXQYxOJvqhnRKw1RAD7/yj9AQiwEm 4JX214L+0qLD8MQoF4++4VX8cRiErGEHUMhT0QyvqntzpOYg64gQs1udPhCgrUWLzYRU gbNg== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@broadband-forum.org header.s=google header.b=CFZmdYZA; spf=pass (google.com: domain of wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org designates 2a00:1450:4864:20::52e as permitted sender) smtp.mailfrom=wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadband-forum.org Original-Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com. [2a00:1450:4864:20::52e]) by gmr-mx.google.com with ESMTPS id be9-20020a056512250900b004e83bb20554si1874893lfb.3.2023.03.29.02.04.37 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Mar 2023 02:04:37 -0700 (PDT) Received-SPF: pass (google.com: domain of wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org designates 2a00:1450:4864:20::52e as permitted sender) client-ip=2a00:1450:4864:20::52e; Original-Received: by mail-ed1-x52e.google.com with SMTP id t10so60228047edd.12 for ; Wed, 29 Mar 2023 02:04:37 -0700 (PDT) X-Received: by 2002:a17:906:524b:b0:877:747d:4a90 with SMTP id y11-20020a170906524b00b00877747d4a90mr9785345ejm.14.1680080677010; Wed, 29 Mar 2023 02:04:37 -0700 (PDT) In-Reply-To: X-Original-Sender: wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@broadband-forum.org header.s=google header.b=CFZmdYZA; spf=pass (google.com: domain of wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org designates 2a00:1450:4864:20::52e as permitted sender) smtp.mailfrom=wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadband-forum.org X-Original-From: William Lupton 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:32416 Archived-At: --000000000000f290c005f80643f8 Content-Type: text/plain; charset="UTF-8" I'll do that (maybe with a fallback on an output file name check). Thanks! On Wed, 29 Mar 2023 at 09:49, BPJ wrote: > > > 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 > > . > -- 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_xxgAhVVOFSR_hayo3dP-uvg8yno4P%2B3kef0eGeb82peC3Q%40mail.gmail.com. --000000000000f290c005f80643f8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I'll do that (maybe with a fallback on an output file = name check). Thanks!

On Wed, 29 Mar 2023 at 09:49, BPJ <bpj-J3H7GcXPSITLoDKTGw+V6w@public.gmane.org> wrote:


Den tis 28 mars 2023= 19:38'William Lupton' via pandoc-discuss <pandoc-discuss@googlegroups= .com> skrev:
Hello,

I'm generating PDF u= sing=C2=A0wkhtmltopdf, so "to" is "html" and I don'= 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 metadat= a 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 (make_pd= f) then
=C2=A0 =C2=A0 local includes =3D meta['h= eader-includes']
=C2=A0 =C2=A0 -- Make sure we h= ave a list
=C2=A0 =C2=A0 if 'List' ~=3D pand= oc.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 the c= urrent 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 end=
=C2=A0 =C2=A0 includes:insert(pandoc.RawBlock('= html', [=3D[...]=3D]))
=C2=A0 =C2=A0 meta['h= eader-includes'] =3D includes
=C2=A0 =C2=A0 retu= rn meta
=C2=A0 end
=C2=A0 ret= urn nil
end
return {
=C2=A0 { Meta =3D Meta },
=C2=A0 main= _filter
}
``````
<= div dir=3D"auto">
``````
= % pandoc -L my-filter.lua -M my-filter-pdf ...
`````= `

At least guaranteed su= rprise 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 b= e converted to PDF (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@googlegroups.c= om.
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 pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CADAJKhDfsFvqD--h= JWQ%2BUGoVibGzHKeZ3qaqKUU1yYk5uxxRHQ%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/CAEe_xxgAhVVOFSR_hayo3dP-uvg8yno4P%2B3k= ef0eGeb82peC3Q%40mail.gmail.com.
--000000000000f290c005f80643f8--