From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/30659 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Schroeder Newsgroups: gmane.text.pandoc Subject: Re: How to make my latex environment accessible from markdown via short-code? Date: Thu, 2 Jun 2022 01:46:06 -0700 (PDT) Message-ID: <2b75bae1-51bc-49fb-84d0-d52139d9a1e3n@googlegroups.com> References: <4de0a599-a196-438a-928c-b0895b35afb6n@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_462_1196753326.1654159566866" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16052"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCMMVPMN5MPRBT7R4GKAMGQE5HT3CPI-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Thu Jun 02 10:46:10 2022 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-oi1-f188.google.com ([209.85.167.188]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nwgT4-00040p-Jk for gtp-pandoc-discuss@m.gmane-mx.org; Thu, 02 Jun 2022 10:46:10 +0200 Original-Received: by mail-oi1-f188.google.com with SMTP id ay32-20020a056808302000b002f96abff093sf1874756oib.23 for ; Thu, 02 Jun 2022 01:46:10 -0700 (PDT) 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=OmCQuWAQKocFacOuCDedJ/Bm9ESY0BW67B31Kh0PpTM=; b=h5vADzfljGjevHuhWzj5Md8nErVM582oA6qMpcI4NFJBUJT8IURmbtd95OK3nyFRMQ jvx+Q9iwjCvenIOCgEj5ifRTih7W3814azzJ9ce/CdtVJtUjn3vFGOSDwi9nfbqRUvjH hDUn1ZGThleoKbXakqRdW99kNGvvqi7Xh7X6PLQFdS3v2wBWq0Xlnzik8/v+vVlT3ws1 DxpERUEMZbauh9MpEsPe4M7SdOK3nj0tQSyiIDA4ez61anrFgQGtz7lCWCmxMz3ECx/W V89yJjp+XJB3bFV65ru3+xPV0q1iwtPkW889TUUuou6PQZSjICioGV0ciGns+7D6hxjR QPZA== 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=OmCQuWAQKocFacOuCDedJ/Bm9ESY0BW67B31Kh0PpTM=; b=e6gwEftEhFN9Lq4vSf0p6cCru1/J19Jq+rcfKualCpY3/sPvws0xlUHepBhZeb72Nu 510fBEmV1gkNTgOzRR/KbCD2/EH7R/DHN1S6ll80DihfgLl65m1fWTXWpcIPKWVNxaXi +QNi1DTH9MJNsOXHYmQQoVS4S+G6CwAdQrrPkCXYNcECGDwHsDRiPAVcUn8wgqxfKuTK pPTRAYhFT3p3sIqEDSTvYLJ0soDxjpG3FPRliRq7LIR1Xy2QY7MlyFfIRngg6iwb8pT7 77imPztlIHNAwtOPjjE0BgwEzGKsDN8M7Ws5wwy5KmqdJNaFJ4fbF37OotRTY/5XnZUi HXAw== 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=OmCQuWAQKocFacOuCDedJ/Bm9ESY0BW67B31Kh0PpTM=; b=Ms0/j4qVxJXE6HHoiwnr1xxnIhaoEFy9LVoZ1TpGiywvEmQa4dj6OtLOc/x+rOq9GD /ojW6LcIh/U9vKXU4QSKZxZBODDsc1ma7+TNirvALZ9Fndt8trUuhndpqRpYFUJq39fj q2RK/lZ/L9go+FUy48cr70OgMNdcGw04q1YFg3/aW/7Zwf2iiKQ2/MgpWkuDuhiOH/qr 4T678M7NVAZS3sKt6m7EIxxJS6J91FI4N1u9AbipSi4Jm3JP1LpYH8JJrrDFCJRUuZWS rTstjXovrYlWTnM8uq1ysDajRthJlTI9ncw9EYRcZp4q4Dw+e1uqthi1rRS17N1ZqDiS 5niQ== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM531Y0q7r/4IfzGR5ZJtGcGIqr/k0x/66elZRHoDAHX2yHg5lXy7D sEhyfHd+b0vT8a20Cp8KpPo= X-Google-Smtp-Source: ABdhPJzJOPHd3qWXJvyL5MXGFhsDPFiwKMuMY8qrv8gRhOj72OaFh4npOW1MKwmKc+DphQ9R1rCQZg== X-Received: by 2002:a05:6808:3097:b0:32b:1198:25ea with SMTP id bl23-20020a056808309700b0032b119825eamr1870886oib.196.1654159569607; Thu, 02 Jun 2022 01:46:09 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a9d:4604:0:b0:60b:8d36:6a1d with SMTP id y4-20020a9d4604000000b0060b8d366a1dls1232516ote.8.gmail; Thu, 02 Jun 2022 01:46:07 -0700 (PDT) X-Received: by 2002:a05:6830:2002:b0:60a:df8c:18f8 with SMTP id e2-20020a056830200200b0060adf8c18f8mr1537883otp.184.1654159567317; Thu, 02 Jun 2022 01:46:07 -0700 (PDT) In-Reply-To: X-Original-Sender: ondekoza-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:30659 Archived-At: ------=_Part_462_1196753326.1654159566866 Content-Type: multipart/alternative; boundary="----=_Part_463_67817356.1654159566866" ------=_Part_463_67817356.1654159566866 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Denis' suggestion works as advertised. Thanks. You made my day. =E2=98=98 On Thursday, June 2, 2022 at 10:33:42 AM UTC+2 Bastien Dumont wrote: > To complement Denis' answer, your Markdown chunks in "hint.lua" are=20 > handled like strings because you created them as Str objects. What you wa= nt=20 > is to return a CodeBlock ( > https://pandoc.org/lua-filters.html#pandoc.codeblock),=20 > e.g. `pandoc.CodeBlock("latex", "\\begin{guidehint}")`. > > More generally, Pandoc has already parsed the input file when it applies= =20 > filters. Filters manipulate objects in the internal representation of the= =20 > document and should return such objects. In exceptional cases where you= =20 > really need to parse a Markdown string inside a filter, use pandoc.read. > > Le Thursday 02 June 2022 =C3=A0 01:17:44AM, Stefan Schroeder a =C3=A9crit= : > > I am converting markdown to pdf via latex using my own template. > > In the template I have defined a new environment called 'hint' that is= =20 > like a > > call-out. > >=20 > > This works: > > --- > > ```{=3Dlatex} > > \begin{hint} > > ``` > > Lorem ipsum dolor sit amet, > > ```{=3Dlatex} > > \end{hint} > > ``` > > --- > > The Lorem text appears in the callout-environment. > >=20 > > I want to make the environment accessible more conveniently via a=20 > short-code. > >=20 > > I have created a new lua-filter, 'hint.lua' that I successfully include= : > > return { > > { > > Str =3D function (elem) > > if elem.text =3D=3D "{{hint_end}}" then > > return pandoc.Str("```{=3Dlatex}\n\\end{guidehint}\n```\n") > > elseif elem.text =3D=3D "{{hint_begin}}" then > > return pandoc.Str "```{=3Dlatex}\\begin{guidehint}```" > > else > > return elem > > end > > end, > > } > > } > >=20 > > But when I use it, the macro-text will be included literally: > >=20 > > {{hint_begin}} > > Neque porro quisquam est, > > {{hint_end}} > >=20 > > The code is not interpreted to end up being proper Latex, but it's=20 > escaped > > somehow to become a string literal. > > Thus my output looks like this: > >=20 > > =E2=80=9C=E2=80=98{=3Dlatex}\begin{hint}=E2=80=9C=E2=80=98 Neque porro = quisquam est, qui dolorem ipsum,=20 > quia > > dolor sit, amet, consectetur, > > adipisci velit =E2=80=9C=E2=80=98{=3Dlatex} \end{hint} =E2=80=9C=E2=80= =98 > >=20 > > How do I make the short-code to get access to my own environments? > >=20 > > PS. If there are different apporaches, that'll be nice as well. > >=20 > > Thanks > > Stefan > >=20 > >=20 > > -- > > You received this message because you are subscribed to the Google Grou= ps > > "pandoc-discuss" group. > > To unsubscribe from this group and stop receiving emails from it, send= =20 > an email > > to [1]pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To view this discussion on the web visit [2] > https://groups.google.com/d/msgid/ > > pandoc-discuss/4de0a599-a196-438a-928c-b0895b35afb6n%40googlegroups.com= . > >=20 > > References: > >=20 > > [1] mailto:pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > > [2]=20 > https://groups.google.com/d/msgid/pandoc-discuss/4de0a599-a196-438a-928c-= b0895b35afb6n%40googlegroups.com?utm_medium=3Demail&utm_source=3Dfooter > > --=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 e= mail 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/2b75bae1-51bc-49fb-84d0-d52139d9a1e3n%40googlegroups.com. ------=_Part_463_67817356.1654159566866 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Denis' suggestion works as advertised. Thanks. You made my day. =E2=98=98
On = Thursday, June 2, 2022 at 10:33:42 AM UTC+2 Bastien Dumont wrote:
To complement Denis= 9; answer, your Markdown chunks in "hint.lua" are handled like st= rings because you created them as Str objects. What you want is to return a= CodeBlock (https://pandoc.org/lua-filters.html#pandoc.codeblock), e.g.=C2=A0`pandoc.CodeBlock("latex", "\\begin{guidehint}= ")`.

More generally, Pandoc has already parsed the input file when it applie= s filters. Filters manipulate objects in the internal representation of the= document and should return such objects. In exceptional cases where you re= ally need to parse a Markdown string inside a filter, use pandoc.read.

Le Thursday 02 June 2022 =C3=A0 01:17:44AM, Stefan Schroeder a =C3=A9cr= it :
> I am converting markdown to pdf via latex using my own template.
> In the template I have defined a new environment called 'hint&= #39; that is like a
> call-out.
>=20
> This works:
> ---
> ```{=3Dlatex}
> \begin{hint}
> ```
> Lorem ipsum dolor sit amet,
> ```{=3Dlatex}
> \end{hint}
> ```
> ---
> The Lorem text appears in the callout-environment.
>=20
> I want to make the environment accessible more conveniently via a = short-code.
>=20
> I have created a new lua-filter, 'hint.lua' that I success= fully include:
> return {
> {
> Str =3D function (elem)
> if elem.text =3D=3D "{{hint_end}}" then
> return pandoc.Str("```{=3Dlatex}\n\\end{guidehint}\n`= ``\n")
> elseif elem.text =3D=3D "{{hint_begin}}" then
> return pandoc.Str "```{=3Dlatex}\\begin{guidehint}```= "
> else
> return elem
> end
> end,
> }
> }
>=20
> But when I use it, the macro-text will be included literally:
>=20
> {{hint_begin}}
> Neque porro quisquam est,
> {{hint_end}}
>=20
> The code is not interpreted to end up being proper Latex, but it&#= 39;s escaped
> somehow to become a string literal.
> Thus my output looks like this:
>=20
> =E2=80=9C=E2=80=98{=3Dlatex}\begin{hint}=E2=80=9C=E2=80=98 Neque p= orro quisquam est, qui dolorem ipsum, quia
> dolor sit, amet, consectetur,
> adipisci velit =E2=80=9C=E2=80=98{=3Dlatex} \end{hint} =E2=80=9C= =E2=80=98
>=20
> How do I make the short-code to get access to my own environments?
>=20
> PS. If there are different apporaches, that'll be nice as well= .
>=20
> Thanks
> Stefan
>=20
>=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 [1]
pandoc-discus...@= googlegroups.com.
> To view this discussion on the web visit [2]https://groups.google.com/d/msgid/
> pandoc-discuss/4de0a599-a196-438a-928c-b0895b35afb6n%40googlegroups.com.
>=20
> References:
>=20
> [1] mailto:pandoc-discu= s...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> [2] https://groups= .google.com/d/msgid/pandoc-discuss/4de0a599-a196-438a-928c-b0895b35afb6n%40= googlegroups.com?utm_medium=3Demail&utm_source=3Dfooter

--
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/2b75bae1-51bc-49fb-84d0-d52139d9a1e3n%40googlegroups.= com.
------=_Part_463_67817356.1654159566866-- ------=_Part_462_1196753326.1654159566866--