From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/29680 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Greg S Newsgroups: gmane.text.pandoc Subject: Re: Skipping commands in LaTeX document Date: Sat, 4 Dec 2021 18:50:06 -0800 (PST) Message-ID: References: <0462fc42-ae24-4c52-b267-1126ed5834edn@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_6584_1411073317.1638672606613" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6320"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCFLTL462MKBBX6RWCGQMGQEHHBXAWI-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Sun Dec 05 03:50:10 2021 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-oo1-f55.google.com ([209.85.161.55]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mthbO-0001Ty-8K for gtp-pandoc-discuss@m.gmane-mx.org; Sun, 05 Dec 2021 03:50:10 +0100 Original-Received: by mail-oo1-f55.google.com with SMTP id i27-20020a4a929b000000b002c672a291dfsf5323744ooh.23 for ; Sat, 04 Dec 2021 18:50:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:date:from:to:message-id:in-reply-to:references:subject :mime-version:x-original-sender:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:list-subscribe :list-unsubscribe; bh=e7yxaPsQH5juYZ4dsXB0vuYKlO8elsqlbsklgrXBP+M=; b=h8xJb6SJ+Zhb954HnPSC3QM/x8uFzIxVk2kAHol1x2Tl7iZgEF3S4yFFGAvIfSpf0d iIBfSHxFB3WJfCUeNXOsnTC/XeIoR1c++AnkEFrZuQbcvCF3Jq6Z4kOXOzHhCzanEr7H k5H5BduEkOw8tlYislcCtIGdmQ2fHBz6Qz1WVmRijtfDVAIeGuX2nbnatkAWy2djbjbA RyVg+pXt+ZgaOxn9Nv3Pt4y8uEy01ESOvseW5DnGiLbwo5gQ0RGwQtBr9iOBmxyJRTHy Up5ZisnJErm52U319AOvWEGFycUBquRH0EiruN35wVODwYY6tj1VS+ZmMcLcvoYBveO8 I0oA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:message-id:in-reply-to:references:subject:mime-version :x-original-sender:reply-to:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=e7yxaPsQH5juYZ4dsXB0vuYKlO8elsqlbsklgrXBP+M=; b=B6dFOl/jl8JWSgS2djpdNwXRrD4zE4esm5ehiPbVr5J3AHE7dIMCfDK8DZvJzMo+n/ JfJrCsINEOSaA13BQST6KD86FP5XcwC6pPeedzYF0FZ0+7Q76Lx0N9bcTjhLoM9Ccmc4 7LKyyRfrFN9gETsy7rVCGIMat+8Irzw6x1GtMfQcfkuDN8TGQrrRlNNQ1ynhzXfjvDIP W5u3YK6y72U8h0n/BOTF3ze5amaRGf38KUjATsr260Y9M0z7eL4tYH/RkHx+ig3m+FyB AZocpXr+7C0tPGBN8+2c8W2O1i3qzpwoh6T1hIg36t4KOAaHZgCGI0+ZM0Dn4TlTHruC sE7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:date:from:to:message-id:in-reply-to :references:subject:mime-version:x-original-sender:reply-to :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=e7yxaPsQH5juYZ4dsXB0vuYKlO8elsqlbsklgrXBP+M=; b=zTYgawDSmvu75bLTc0PhjY8O+0AiZzp4PwXkt/k7p2xP/BvsvD0xgCTO8OMwit7f3r i6Tm834jJiIy7MFPigKka3qoKtw1mh8huSvOY2l0KQDOeLKbfLPa7QoKzs5/YoB03Odd //Ma4dnE8qC4rMXUj4QcbWdozEbVpfQgcrlZ6lSd22LidKxFlKvpKPHpg7whocB+YKVF EUSLq6ttvVVG1qhC2ugyeROzcJsFo3JaI0MAMbvngVtwBqBeirVx/ItqH7UsSDSJH6nH sUgjXFV5sXlE13KVtIfFtFAssnz71pqspYjeBoLp6UjaQhGfUNlXz/jOx0zq07S4xq2n 8dbA== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM5338PX2zmIFCnAhgxysAxkgqu3fOqsK9rU7YaJ/cFQ7qoiYhOhv4 Lsk6P6ZNA6+LGa1Io7U3pIQ= X-Google-Smtp-Source: ABdhPJxgXea1xN0Xk5iwCZQxUujYmK7w3POQmFNon9l4cGc+SsZbePeJScFZhHp2PXfk3Gez/FUy7w== X-Received: by 2002:a54:4584:: with SMTP id z4mr17300833oib.158.1638672608925; Sat, 04 Dec 2021 18:50:08 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a4a:4f01:: with SMTP id c1ls934208oob.11.gmail; Sat, 04 Dec 2021 18:50:07 -0800 (PST) X-Received: by 2002:a4a:d8c7:: with SMTP id c7mr18135394oov.58.1638672607291; Sat, 04 Dec 2021 18:50:07 -0800 (PST) In-Reply-To: X-Original-Sender: elorian.mestec-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:29680 Archived-At: ------=_Part_6584_1411073317.1638672606613 Content-Type: multipart/alternative; boundary="----=_Part_6585_2119026040.1638672606613" ------=_Part_6585_2119026040.1638672606613 Content-Type: text/plain; charset="UTF-8" Is there a way I can tell pandoc to insert a new Latex macro before processing that doesn't exist in the document? Using \renewcommand{\IPA}[1]{#1} makes the text appear in the output of the latex -> html conversion, but it breaks the formatting I care about in the pdf version so I don't want to have that line permanently in the latex source file. I think I'd ultimately like to use a filter to intercept the raw latex from \IPA{...} and do something specific with it in HTML (probably put it within a tag). I also have some other latex macros from specific packages that pandoc doesn't seem to understand, that I'd like to handle in a custom way. I tried creating a simple logging Python filter just to understand how they work. ``` #!/usr/bin/python import logging from pandocfilters import toJSONFilter, Emph, Para def handle(key, value, format, meta): logging.warn(f"KEY {key} VALUE {value} format {format} META {meta}") if __name__ == "__main__": toJSONFilter(handle) ``` And then running `pandoc --pdf-engine=xelatex --verbose test.tex -o test.html --filter filter.py`. But it seems like latex macros that pandoc doesn't understand are getting skipped before the filter is applied, so the `handle` function never gets called with the text contents of my \IPA macro. On Saturday, December 4, 2021 at 9:37:16 AM UTC-8 John MacFarlane wrote: > > Pandoc doesn't understand everything, especially outside of > core LaTeX. In particular, it doesn't understand > > \DeclareTextFontCommand > > from fontspec, so the \IPA macro isn't understood. > > You can work around this by adding your own macro > definition before you convert with pandoc: > > \renewcommand{\IPA}[1]{#1} > > and then the contents of \IPA will just be passed > through. > > I suppose you could alternatively redefine > > \renewcommand{\DeclareTextFontCommand}[2]{\newcommand{#1}[1]{##1}} > > before your fontspec stuff (untested and may not work). > > Another option is to use a filter and intercept the raw > LaTeX inline produced from \IPA{some text}, changing it > into textual content, but I think the first approach above > is the simplest. > > > > Greg S writes: > > > I have a minimal test latex file `test.tex`: > > > > > > \documentclass{article} > > > > \usepackage{fontspec} > > > > \newfontfamily\IPAFont{Doulos SIL} > > \DeclareTextFontCommand{\IPA}{\IPAFont} > > > > \begin{document} > > > > \section{Test} > > Hello \IPA{some IPA} > > > > \end{document} > > > > > > This builds fine with xelatex and produces a pdf I expect. When i try to > > convert this to an html document with `pandoc --pdf-engine=xelatex > > --verbose test.tex -o test.html`, I see the warnings: > > > > [INFO] Could not load include file fontspec.sty at test.tex line 3 > column 22 > > [INFO] Skipped '\newfontfamily' at test.tex line 5 column 15 > > [INFO] Skipped '\IPAFont{Doulos SIL}' at test.tex line 5 column 35 > > [INFO] Skipped '\DeclareTextFontCommand{\IPA}{\IPAFont}' at test.tex > line 6 > > column 40 > > [INFO] Skipped '\IPA{some IPA}' at test.tex line 11 column 21 > > > > And the text within the custom \IPA command is skipped. How can I make > > pandoc not skip these? > > > > > > -- > > 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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To view this discussion on the web visit > https://groups.google.com/d/msgid/pandoc-discuss/0462fc42-ae24-4c52-b267-1126ed5834edn%40googlegroups.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/bac7947b-259e-4774-b993-33f69fffc05fn%40googlegroups.com. ------=_Part_6585_2119026040.1638672606613 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Is there a way I can tell  pandoc to insert a new Latex macro before = processing that doesn't exist in the document? Using \renewcommand{\IPA}[1]= {#1} makes the text appear in the output of the latex -> html conversion= , but it breaks the formatting I care about in the pdf version so I don't w= ant to have that line permanently in the latex source file.

I think = I'd ultimately like to use a filter to intercept the raw latex from \IPA{..= .} and do something specific with it in HTML (probably put it within a <= span class=3D"IPA"> tag). I also have some other latex macros from speci= fic packages that pandoc doesn't seem to understand, that I'd like to handl= e in a custom way. I tried creating a simple logging Python filter just to = understand how they work.

```
#!/usr/bin/python
import logging
from pandocfilters import toJSONFilter, Emph, Para
def handle(key, value, format, meta):
    logging.warn(f"KEY {key} VALUE {value} format {f= ormat} META {meta}")

if __name__ =3D=3D "__main__":
   toJSONFilter(handle)
```
And then running `pandoc --pdf-engine=3Dxelatex --verbose test.t= ex -o test.html --filter filter.py`.

But it seems like latex macros = that pandoc doesn't understand are getting skipped before the filter is app= lied, so the `handle` function never gets called with the text contents of = my \IPA macro.

On Saturday, December 4, 2021 at 9:37:16 AM UTC-8 John MacFarl= ane wrote:

Pandoc doesn't understand everything, especially outside of
core LaTeX. In particular, it doesn't understand

\DeclareTextFontCommand

from fontspec, so the \IPA macro isn't understood.

You can work around this by adding your own macro
definition before you convert with pandoc:

\renewcommand{\IPA}[1]{#1}

and then the contents of \IPA will just be passed
through.

I suppose you could alternatively redefine

\renewcommand{\DeclareTextFontCommand}[2]{\newcommand{#1}[1]{##1}}

before your fontspec stuff (untested and may not work).

Another option is to use a filter and intercept the raw
LaTeX inline produced from \IPA{some text}, changing it
into textual content, but I think the first approach above
is the simplest.



Greg S <elorian...@gmail.= com> writes:

> I have a minimal test latex file `test.tex`:
>
>
> \documentclass{article}
>
> \usepackage{fontspec}
>
> \newfontfamily\IPAFont{Doulos SIL}
> \DeclareTextFontCommand{\IPA}{\IPAFont}
>
> \begin{document}
>
> \section{Test}
> Hello \IPA{some IPA}
>
> \end{document}
>
>
> This builds fine with xelatex and produces a pdf I expect. When i = try to=20
> convert this to an html document with `pandoc --pdf-engine=3Dxelat= ex=20
> --verbose test.tex -o test.html`, I see the warnings:
>
> [INFO] Could not load include file fontspec.sty at test.tex line 3= column 22
> [INFO] Skipped '\newfontfamily' at test.tex line 5 column = 15
> [INFO] Skipped '\IPAFont{Doulos SIL}' at test.tex line 5 c= olumn 35
> [INFO] Skipped '\DeclareTextFontCommand{\IPA}{\IPAFont}' a= t test.tex line 6=20
> column 40
> [INFO] Skipped '\IPA{some IPA}' at test.tex line 11 column= 21
>
> And the text within the custom \IPA command is skipped. How can I = make=20
> pandoc not skip these?
>
>
> --=20
> 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-discus..= .@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/0462= fc42-ae24-4c52-b267-1126ed5834edn%40googlegroups.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://groups.google.com/d= /msgid/pandoc-discuss/bac7947b-259e-4774-b993-33f69fffc05fn%40googlegroups.= com.
------=_Part_6585_2119026040.1638672606613-- ------=_Part_6584_1411073317.1638672606613--