public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* How to check for used pdf-engine in lua filters?
@ 2020-04-13 18:00 Johannes Maibaum
       [not found] ` <9dd5275f-89e2-4cd3-a2a8-826def719d39-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Johannes Maibaum @ 2020-04-13 18:00 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 1519 bytes --]

Hello,

I have the following lua filter function that uses fontspec's 
\addfontfeature to activate certain OpenType font features, in this case 
diagonal fractions for all Spans with the custom 'frac' class:

if FORMAT:match 'latex' then
    function Span (elem)
        -- Surround with fontspec's \addfontfeature{Fractions=On}
        if elem.classes:includes('frac', 1) then
            return {
                pandoc.RawInline('latex', '{\\addfontfeature{Fractions=On}
'),
                elem,
                pandoc.RawInline('latex', '}'),
            }
        else
            return elem
        end
    end
end

However, this does only work when I set `pdf-engine` to `xelatex` or 
`lualatex`. When I forget this, pandoc defaults to pdflatex which doesn't 
support fontspec, and this breaks compilation as expected:

Error producing PDF.
> ! Undefined control sequence.
> l.59 {\addfontfeature
>

Is it possible to check the value of `pdf-engine` (or if a certain LaTeX 
package like `fontspec` has been loaded) from the filter API? I would like 
to add a check like this to my filter.


Johannes

-- 
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/9dd5275f-89e2-4cd3-a2a8-826def719d39%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 4937 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to check for used pdf-engine in lua filters?
       [not found] ` <9dd5275f-89e2-4cd3-a2a8-826def719d39-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-04-13 21:51   ` John MacFarlane
       [not found]     ` <m2v9m3gilw.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: John MacFarlane @ 2020-04-13 21:51 UTC (permalink / raw)
  To: Johannes Maibaum, pandoc-discuss


> However, this does only work when I set `pdf-engine` to `xelatex` or 
> `lualatex`. When I forget this, pandoc defaults to pdflatex which doesn't 
> support fontspec, and this breaks compilation as expected:
>
> Error producing PDF.
>> ! Undefined control sequence.
>> l.59 {\addfontfeature
>>

No, not possible.  Using a --defaults file that specifies both
the lua filter and the tex engine might help.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to check for used pdf-engine in lua filters?
       [not found]     ` <m2v9m3gilw.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
@ 2020-04-14 11:46       ` BPJ
       [not found]         ` <CADAJKhBn28sJ3rrLC7BDys9NRgqVjHf_n7eT1FXvqXgJnYcXyQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: BPJ @ 2020-04-14 11:46 UTC (permalink / raw)
  To: pandoc-discuss

[-- Attachment #1: Type: text/plain, Size: 1575 bytes --]

Or add a metadata variable which the filter can check. You need to type both

--pdf-engine=...

and

-M pdf-engine=...

but maybe you can put that ugliness in a defaults file.

Den mån 13 apr. 2020 23:52John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> skrev:

>
> > However, this does only work when I set `pdf-engine` to `xelatex` or
> > `lualatex`. When I forget this, pandoc defaults to pdflatex which
> doesn't
> > support fontspec, and this breaks compilation as expected:
> >
> > Error producing PDF.
> >> ! Undefined control sequence.
> >> l.59 {\addfontfeature
> >>
>
> No, not possible.  Using a --defaults file that specifies both
> the lua filter and the tex engine might help.
>
> --
> 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/m2v9m3gilw.fsf%40johnmacfarlane.net
> .
>

-- 
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/CADAJKhBn28sJ3rrLC7BDys9NRgqVjHf_n7eT1FXvqXgJnYcXyQ%40mail.gmail.com.

[-- Attachment #2: Type: text/html, Size: 2654 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to check for used pdf-engine in lua filters?
       [not found]         ` <CADAJKhBn28sJ3rrLC7BDys9NRgqVjHf_n7eT1FXvqXgJnYcXyQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2020-04-14 17:35           ` Johannes Maibaum
  0 siblings, 0 replies; 4+ messages in thread
From: Johannes Maibaum @ 2020-04-14 17:35 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

[-- Attachment #1: Type: text/plain, Size: 1137 bytes --]

>
> Den mån 13 apr. 2020 23:52John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> skrev:
>
>>
>> No, not possible.  Using a --defaults file that specifies both
>> the lua filter and the tex engine might help.
>>
>
BPJ <bpj-J3H7GcXPSITLoDKTGw+V6w@public.gmane.org> schrieb am Di., 14. Apr. 2020, 13:47:

Or add a metadata variable which the filter can check. You need to type both

--pdf-engine=...

and

-M pdf-engine=...

but maybe you can put that ugliness in a defaults file.


I knew about the default file workaround, but wanted to ask if I was
missing an API feature. This question has now been answered. Thanks to you
both for your explanations and suggestions!

>

-- 
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/CAM_yyFcXLsbo5bFKJR9kviR4Vj01XLVc-gDh-jo1z9uaKim_mA%40mail.gmail.com.

[-- Attachment #2: Type: text/html, Size: 3354 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-04-14 17:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-13 18:00 How to check for used pdf-engine in lua filters? Johannes Maibaum
     [not found] ` <9dd5275f-89e2-4cd3-a2a8-826def719d39-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-04-13 21:51   ` John MacFarlane
     [not found]     ` <m2v9m3gilw.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2020-04-14 11:46       ` BPJ
     [not found]         ` <CADAJKhBn28sJ3rrLC7BDys9NRgqVjHf_n7eT1FXvqXgJnYcXyQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-04-14 17:35           ` Johannes Maibaum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).