From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/29683 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: John MacFarlane Newsgroups: gmane.text.pandoc Subject: Re: Skipping commands in LaTeX document Date: Sun, 05 Dec 2021 10:56:37 -0800 Message-ID: References: <0462fc42-ae24-4c52-b267-1126ed5834edn@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="19938"; mail-complaints-to="usenet@ciao.gmane.io" To: Greg S , pandoc-discuss Original-X-From: pandoc-discuss+bncBCJZJHG45QDBB4UWWSGQMGQEQDT72CY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Sun Dec 05 19:56:52 2021 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-io1-f58.google.com ([209.85.166.58]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mtwgu-0004yV-As for gtp-pandoc-discuss@m.gmane-mx.org; Sun, 05 Dec 2021 19:56:52 +0100 Original-Received: by mail-io1-f58.google.com with SMTP id 7-20020a6b0107000000b005ed196a2546sf6509379iob.11 for ; Sun, 05 Dec 2021 10:56:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1638730611; cv=pass; d=google.com; s=arc-20160816; b=eLS1Z+ucRE6Iqq8Pn1hUqbbfDsL2eJdSfKqmawjIqMdNsFbz+up5sZ6tWaaQNsqG61 OYY/cV5fP1rjzrWUXMzcaDUtMPHMtGP57Vgo993ODDNoWz0l/jqmWFQFTkxBlK+kS8gU mMMyeJaLx4o3yzwbQCtHJiLDjcm3p/OzefWxkc/uZsH0VZff+YXZiU1l4I9fu60BCJWl V18i8RT6b77bMqSPX5CuV2XVbEdboOJ3FawAo6oq6Wa1CE5eQsQvFJohQGxkCuxLYyBO t6bS9sIjzegoa9WBuRMksb00Uhae9pqtM+4iOBG4WdtSM3/k5s4kB0M8IiFG9lr6L4bJ uPXw== 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:to:from:sender:dkim-signature; bh=wJrDE0SkAU/vFXfw6VYX2q1v4g72d4DXkTCYrIpTs7o=; b=1JmgzqEU6wwi18u6xklbJXU4coNgXPoW7gaxARYGXM/Upl0FlSxVU9uCafBcgpIYIB 3gKBo6jQg5ERucfTyQevcmQCVx/shVmy2Ul7IQgt3ArLFYhU2F8VEexZG+nKB7YJ8k9o HGU74j51UFFlGekcMik0OBwyJ5AmPM3aoku6GH7VMi/Et8+zOG4ZOpP6DbZe/bwh6Iis u5hGh9c1bNi/F7zWGsuslHjic3e1kIMSv94WdTHUDahLX27YCk2yo6COBpJ5GXK8Vspg VMgWGECIyvQ2wb3eBLAVR/bKQy0DEpm+uj1FDv4YfRWW04XSzKGM9qdDj2JW/yJcKoms ytPw== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@berkeley-edu.20210112.gappssmtp.com header.s=20210112 header.b=AEsQBWpk; spf=pass (google.com: domain of jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org designates 2607:f8b0:4864:20::535 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=20210112; h=sender:from:to: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=wJrDE0SkAU/vFXfw6VYX2q1v4g72d4DXkTCYrIpTs7o=; b=EDliBcQJpSFvDRFbi0xlwnwF17ZwKMNntokOn0RUyW/42YPBtBeHnIMb5N/uGI6WT4 SWksuxu0uukQ6oFbFFLugukbwTuvr+O45qh9N8jwvvYWH+uzp91SLhUOhyxOJLH5t+N5 1FWxB3oTVmJZWYNfLSC72Qlh45mKcpPluYmfU3TykSdb3/k2uZHdL+npXOF3ibugOke4 tZ/qK94Ls8zWQcsHzGpNYxbk7BP/llRIv7rV0GhkUUBryor7LTb9NYY+Uz+ooy1eW1TR YDQSmCImWwOsuNtNLQ4H8pLFcVxtBystVsOM/HLbKnglWfG3k7qDUlJoX+GBpGa4S3IF XEJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:from:to: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=wJrDE0SkAU/vFXfw6VYX2q1v4g72d4DXkTCYrIpTs7o=; b=FBReyUAioEtDxB0GJThbUyGNjX5D5+jSQY38lElY6ODMYMlspYiv/ZGkhqJJyZ713h PYKDG+bCdGcNCcNLLs6EY7eqmzyyUN7EBCHzYW47sCFeU2qZb5T7DOP+WHReIijEmdf8 pWDGSebIK4948GKMOOAzQ8kvIo9Xs8vwmu63V8xBs2YjOjoWD2UFtW/4xuVf155k/gla zq50Im2aWFbRfU7oC1v9M0Nr9vCzfFivfrE2hrZQL+LFWQ13HTnJqUXhAb8HU3EAtUXx OBNling/0MeneLFuvxdHTyIE3J9DAZR3k7A/jYwmr3hDMPfRQV5SzfZQTGNNJIkAsjL7 Ephw== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM532cKNsC+Jx6x9aHVOstqKfmKVMV/tPMO+lwJ1HQGzjtv30MKOWw fUwNlEQuu7Oell+xUH0qitQ= X-Google-Smtp-Source: ABdhPJw/jicBrKIreog8KliVR0zYA0GUSuj4o9ZkV34R5XoQEYqJOxA4qVx3zAUO1sdgvubeCV52Rg== X-Received: by 2002:a05:6602:2a44:: with SMTP id k4mr11093158iov.43.1638730611225; Sun, 05 Dec 2021 10:56:51 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a02:c554:: with SMTP id g20ls1658122jaj.4.gmail; Sun, 05 Dec 2021 10:56:49 -0800 (PST) X-Received: by 2002:a05:6638:24c6:: with SMTP id y6mr38778081jat.98.1638730609864; Sun, 05 Dec 2021 10:56:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1638730609; cv=none; d=google.com; s=arc-20160816; b=ECO8tCcd3Fe5bQRkkFezMxGQW0N62D3p5TxBPd6ocdY9URQNZnmpjiczy7apAaiNKM rtDNqx4mTziceEeQZvoDgpB2h3RBPFpgie6iDmvo04bm4Ht2AwGoEm2KDo4Vtms5XEBd zQhDjPVBqKaTqXNHqRQNp4ilOBqsBt381RI+pryOVIviuigNbUkI60hKZc0SAp/liRFf Ue9ouk+nQMa7k61iMJiAjeJvB8ejV+PsEvEucL/LkJxj+5LuAA8HRw3pTrl4IbVQIFMS KA98VZB3yB84JXkXPrP98u15oJpna5UVOKZwp10pHOM03s0ctdoo/3WRXaPwOIrGp4hn vtzQ== 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:to:from :dkim-signature; bh=ndXkyFilXxiHTrQxhR1icmCs2tqwIx6w77gnRzdIzQ8=; b=oSREHTAK9y1JUYhFyP/x2UIqxrUxY/05OzQakDrHTrjEHsdmMPFH44oWRgG8WSdjUV b3HCGJrgLcIPWgdTCWeIN0ELnryyUr4PjXbTSwtJSPcSTL5NRW+e2OZ3GF4/pdRBv0uR B6VmY1/7UEl5/bNCBYIKJPJgSmNdiMKG5aqjjjbkO1A/t3BVZ9fND48Y4IzW9Ta36KkV cRmFap/fF66AL6eJoQIy+0ksvu2BwQi2rOjJ4fMCond1AK+cT9DY4xB4WcCDRd6OFA8X lsE1X/cp31ATuaxlxs2HyNCJs3DvuqnOp6eew9Yqkwl+kttRJl+2ggyhNBvdSJd7FQ1m 88Sg== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@berkeley-edu.20210112.gappssmtp.com header.s=20210112 header.b=AEsQBWpk; spf=pass (google.com: domain of jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org designates 2607:f8b0:4864:20::535 as permitted sender) smtp.mailfrom=jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org Original-Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com. [2607:f8b0:4864:20::535]) by gmr-mx.google.com with ESMTPS id i17si1568523ila.3.2021.12.05.10.56.49 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 05 Dec 2021 10:56:49 -0800 (PST) Received-SPF: pass (google.com: domain of jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org designates 2607:f8b0:4864:20::535 as permitted sender) client-ip=2607:f8b0:4864:20::535; Original-Received: by mail-pg1-x535.google.com with SMTP id 137so8406277pgg.3 for ; Sun, 05 Dec 2021 10:56:49 -0800 (PST) X-Received: by 2002:a63:5b24:: with SMTP id p36mr2694797pgb.258.1638730609113; Sun, 05 Dec 2021 10:56:49 -0800 (PST) Original-Received: from johnmacfarlane.net (li55-134.members.linode.com. [74.82.3.134]) by smtp.gmail.com with ESMTPSA id a12sm7443340pgg.28.2021.12.05.10.56.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Dec 2021 10:56:48 -0800 (PST) Original-Received: by johnmacfarlane.net (Postfix, from userid 1000) id 5CA06A1D6; Sun, 5 Dec 2021 13:56:37 -0500 (EST) 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.20210112.gappssmtp.com header.s=20210112 header.b=AEsQBWpk; spf=pass (google.com: domain of jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org designates 2607:f8b0:4864:20::535 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:29683 Archived-At: You can't insert the macro with a filter, because the filter is applied after parsing, and the macro would be resolved in the parsing phase. However, you could have a filter that matches RawInline elements that are "\IPA" commands, extracts their textual content, and returns a Str element. Greg S writes: > 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.