From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/30660 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Schroeder Newsgroups: gmane.text.pandoc Subject: Re: AW: How to make my latex environment accessible from markdown via short-code? Date: Thu, 2 Jun 2022 01:47:02 -0700 (PDT) Message-ID: <00769f1a-ee10-4fc2-bb22-9cb1ac351450n@googlegroups.com> References: <4de0a599-a196-438a-928c-b0895b35afb6n@googlegroups.com> <2acb8d6c2b3f4042a0e940cbda7899e4@unibe.ch> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_280_522195922.1654159622704" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20613"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCMMVPMN5MPRBB7S4GKAMGQE75UY3NQ-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Thu Jun 02 10:47:06 2022 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-oa1-f63.google.com ([209.85.160.63]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nwgTx-000591-T4 for gtp-pandoc-discuss@m.gmane-mx.org; Thu, 02 Jun 2022 10:47:06 +0200 Original-Received: by mail-oa1-f63.google.com with SMTP id 586e51a60fabf-f32dadb746sf2690197fac.6 for ; Thu, 02 Jun 2022 01:47:05 -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=rssCPPZ6R2hXL7+0GLnygunRRbLs+aGXCan5l2cmT6s=; b=TTAExZIp5Q1w/amdzeTX2oscVT0ZY14fduJSMBhHxil8FuOIUHl8l1gjFGugqPOfoU VDutk2INleVri8p9KTqkfaP6XJWFX3ahpeQRO2pxj6j0ZDhitBp9zoumSGx3sUuZkPVf xw6LrXBUXv7yEVdmbjIsvwj2I9EbQohu8P6GeRO8Zl+JvTKJ+jbdr4qNGBZYhPJY4EKY 38IDZ+13FnWK2ZR9mFmcobdIcUzYvZOYfbP5KDKcx22A8ZbM6+BGsd4YouTc0Er8PgCk o4uVHOaFv+079leNHrIF0fPu2vx0CtRO7dacuIlP8UzLFKg++H8nn9zIv+foU111RQWS JT3Q== 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=rssCPPZ6R2hXL7+0GLnygunRRbLs+aGXCan5l2cmT6s=; b=DDLjQysMB0VgfB8tgL1K/K0QYcTyH2MOA/FHh8T5VzrFV3GVJ/11LxUwHWGjPdaLSo orJxGeqd0bu+i4EkKvtH+gFcEvFZKmCWQt29LeA5Lq1XKOWKMWwXiaAh4fovKl2E8Rc6 jQ5oTDJXZMuuTBISF1uIWZQxjPXNTSVa/Ym1/WouvaV6omcCecHjqYNpBIc1ymAN6mCe rKTpDR2+8SQ7Bq85AzcC9iTIHCIJPw7VH52Wy8fj/VU+rNA6PP2CT+JLeMholgoetso1 JwOFggHpx0k5Jx89Xhde6Q76t9XYqTapkOERLnm57W9v7q1kMSSwO8GnjITMju6qpI4O niUg== 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=rssCPPZ6R2hXL7+0GLnygunRRbLs+aGXCan5l2cmT6s=; b=F58IbELR5F0JLg4Qfbe8+cATOh+6ukbYI+p4un0fCrTM1P22m4wvhhLFQZur/FjXG3 Bcz4guRNrtYEMwmKkjCNt4GyzBGYFspaXiyA0tUq+pS7gmzEmfQSAmPyDB1At4g1ctob SXSgUpIpe4i8QGrO0B4f3uciMtzplUjTK8YtK8PC6Moav4/YJ2g9Fju8bPiVNgTVM/Ig kGTNl4xhqvvlP+q1d6K6Zn/xGg3P8DyS7UJcj4euUG9eBlattAxLfjlk3/zwD14xZFYI a3697ez+6L9Gv+FfL6yN50dLIH1r8BA5w3LMi3xkvEKVcWwavuEO9JP++JhW5qGO/+kd avTQ== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM532XqPXctgBNHThZmR1VnUqEX9+xiYBoHwDc/FE8ftpVbkxvb6XM sMyu4dfAmpg0X1Nr1RB2vm4= X-Google-Smtp-Source: ABdhPJzGrEefI+KXXVN3hA+8KM4gFO6j50jCzywQqYfYcUfM5cE9piPPCxXBJl8ieAwoX1vt0m/Cpw== X-Received: by 2002:a05:6870:15ce:b0:e9:894f:d9ce with SMTP id k14-20020a05687015ce00b000e9894fd9cemr2093312oad.121.1654159624897; Thu, 02 Jun 2022 01:47:04 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6808:15a4:b0:32b:1a5d:cb2d with SMTP id t36-20020a05680815a400b0032b1a5dcb2dls2335763oiw.7.gmail; Thu, 02 Jun 2022 01:47:03 -0700 (PDT) X-Received: by 2002:a05:6808:170b:b0:2fa:729a:a42e with SMTP id bc11-20020a056808170b00b002fa729aa42emr17719328oib.0.1654159623196; Thu, 02 Jun 2022 01:47:03 -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:30660 Archived-At: ------=_Part_280_522195922.1654159622704 Content-Type: multipart/alternative; boundary="----=_Part_281_1493464260.1654159622704" ------=_Part_281_1493464260.1654159622704 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thank you for your suggestion as well, Bastien. I'll keep a note of what=20 you said for reference. On Thursday, June 2, 2022 at 10:44:14 AM UTC+2 Bastien Dumont wrote: > Oh yes, you're right, sorry! > > Le Thursday 02 June 2022 =C3=A0 08:35:22AM, denis...-NSENcxR/0n0@public.gmane.org a =C3=A9cri= t : > > Or, maybe even a RawBlock? Like in that function: > > local function latex(s) > > return pandoc.RawBlock('latex', s) > > end > >=20 > >=20 > > > -----Urspr=C3=BCngliche Nachricht----- > > > Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > > dis...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im Auftrag von Bastien DUMONT > > > Gesendet: Donnerstag, 2. Juni 2022 10:34 > > > An: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > > > Betreff: Re: How to make my latex environment accessible from markdow= n > > > via short-code? > > >=20 > > > To complement Denis' answer, your Markdown chunks in "hint.lua" are > > > handled like strings because you created them as Str objects. What yo= u=20 > want > > > is to return a CodeBlock (https://pandoc.org/lua- > > > filters.html#pandoc.codeblock), e.g. `pandoc.CodeBlock("latex", > > > "\\begin{guidehint}")`. > > >=20 > > > More generally, Pandoc has already parsed the input file when it=20 > applies > > > filters. Filters manipulate objects in the internal representation of= =20 > the > > > document and should return such objects. In exceptional cases where y= ou > > > really need to parse a Markdown string inside a filter, use=20 > pandoc.read. > > >=20 > > > Le Thursday 02 June 2022 =C3=A0 01:17:44AM, Stefan Schroeder a =C3=A9= crit : > > > > I am converting markdown to pdf via latex using my own template. > > > > In the template I have defined a new environment called 'hint' that= =20 > is > > > > like a call-out. > > > > > > > > This works: > > > > --- > > > > ```{=3Dlatex} > > > > \begin{hint} > > > > ``` > > > > Lorem ipsum dolor sit amet, > > > > ```{=3Dlatex} > > > > \end{hint} > > > > ``` > > > > --- > > > > The Lorem text appears in the callout-environment. > > > > > > > > I want to make the environment accessible more conveniently via a= =20 > short- > > > code. > > > > > > > > I have created a new lua-filter, 'hint.lua' that I successfully=20 > 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, > > > > } > > > > } > > > > > > > > But when I use it, the macro-text will be included literally: > > > > > > > > {{hint_begin}} > > > > Neque porro quisquam est, > > > > {{hint_end}} > > > > > > > > The code is not interpreted to end up being proper Latex, but it's > > > > escaped somehow to become a string literal. > > > > Thus my output looks like this: > > > > > > > > =E2=80=9C=E2=80=98{=3Dlatex}\begin{hint}=E2=80=9C=E2=80=98 Neque po= rro 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 > > > > > > > > How do I make the short-code to get access to my own environments? > > > > > > > > PS. If there are different apporaches, that'll be nice as well. > > > > > > > > Thanks > > > > Stefan > > > > > > > > > > > > -- > > > > 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,= =20 > send > > > > 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. > > > > > > > > References: > > > > > > > > [1] mailto:pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > > > > [2] > > > > https://groups.google.com/d/msgid/pandoc-discuss/4de0a599-a196- > > > 438a-92 > > > > 8c- > > > b0895b35afb6n%40googlegroups.com?utm_medium=3Demail&utm_source=3Dfo > > > oter > > >=20 > > > -- > > > You received this message because you are subscribed to the Google=20 > Groups > > > "pandoc-discuss" group. > > > To unsubscribe from this group and stop receiving emails from it, sen= d=20 > 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/Yph14Uv3BuicNJi9%40localhost. > >=20 > > --=20 > > You received this message because you are subscribed to the Google=20 > Groups "pandoc-discuss" group. > > To unsubscribe from this group and stop receiving emails from it, send= =20 > an email to pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To view this discussion on the web visit=20 > https://groups.google.com/d/msgid/pandoc-discuss/2acb8d6c2b3f4042a0e940cb= da7899e4%40unibe.ch > . > --=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/00769f1a-ee10-4fc2-bb22-9cb1ac351450n%40googlegroups.com. ------=_Part_281_1493464260.1654159622704 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thank you for your suggestion as well, Bastien. I'll keep a note of what yo= u said for reference.

On Thursday, June 2, 2022 at 10:44:14 AM UTC+2 Bastien = Dumont wrote:
Oh yes, you're right, sorry!

Le Thursday 02 June 2022 =C3=A0 08:35:22AM, denis...-NSENcxR/0n0@public.gmane.org a =C3=A9crit :
> Or, maybe even a RawBlock? Like in that function:
> local function latex(s)
> return pandoc.RawBlock('latex', s)
> end
>=20
>=20
> > -----Urspr=C3=BCngliche Nachricht-----
> > Von: pandoc-...@go= oglegroups.com <pandoc-
> > dis...@googlegroup= s.com> Im Auftrag von Bastien DUMONT
> > Gesendet: Donnerstag, 2. Juni 2022 10:34
> > An: pandoc-...@goo= glegroups.com
> > Betreff: Re: How to make my latex environment accessible from= markdown
> > via short-code?
> >=20
> > To complement Denis' answer, your Markdown chunks in &quo= t;hint.lua" are
> > handled like strings because you created them as Str objects.= What you want
> > is to return a CodeBlock (https://pand= oc.org/lua-
> > filters.html#pandoc.codeblock), e.g.=C2=A0`pandoc.CodeBlock(&= quot;latex",
> > "\\begin{guidehint}")`.
> >=20
> > More generally, Pandoc has already parsed the input file when= it applies
> > filters. Filters manipulate objects in the internal represent= ation of the
> > document and should return such objects. In exceptional cases= where you
> > really need to parse a Markdown string inside a filter, use p= andoc.read.
> >=20
> > 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 t= emplate.
> > > In the template I have defined a new environment called = 'hint' that is
> > > like a call-out.
> > >
> > > This works:
> > > ---
> > > ```{=3Dlatex}
> > > \begin{hint}
> > > ```
> > > Lorem ipsum dolor sit amet,
> > > ```{=3Dlatex}
> > > \end{hint}
> > > ```
> > > ---
> > > The Lorem text appears in the callout-environment.
> > >
> > > I want to make the environment accessible more convenien= tly via a short-
> > code.
> > >
> > > 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{gui= dehint}\n```\n")
> > > elseif elem.text =3D=3D "{{hint_begin}}"= then
> > > return pandoc.Str "```{=3Dlatex}\\begin{gui= dehint}```"
> > > else
> > > return elem
> > > end
> > > end,
> > > }
> > > }
> > >
> > > But when I use it, the macro-text will be included liter= ally:
> > >
> > > {{hint_begin}}
> > > Neque porro quisquam est,
> > > {{hint_end}}
> > >
> > > The code is not interpreted to end up being proper Latex= , but it's
> > > escaped somehow to become a string literal.
> > > Thus my output looks like this:
> > >
> > > =E2=80=9C=E2=80=98{=3Dlatex}\begin{hint}=E2=80=9C=E2=80= =98 Neque porro 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
> > >
> > > How do I make the short-code to get access to my own env= ironments?
> > >
> > > PS. If there are different apporaches, that'll be ni= ce as well.
> > >
> > > Thanks
> > > Stefan
> > >
> > >
> > > --
> > > 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...-/JYPxA39Uh5TLH3MbocFFw@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.
> > >
> > > References:
> > >
> > > [1] mailto:
pa= ndoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> > > [2]
> > > https://groups.google.com/d/= msgid/pandoc-discuss/4de0a599-a196-
> > 438a-92
> > > 8c-
> > b0895b35afb6n%40googlegroups.com?= utm_medium=3Demail&utm_source=3Dfo
> > oter
> >=20
> > --
> > You received this message because you are subscribed to the G= oogle Groups
> > "pandoc-discuss" group.
> > To unsubscribe from this group and stop receiving emails from= it, send an
> > email to pandoc-di= scus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
> > To view this discussion on the web visit
> > https://groups.google.com/d/msgid/pandoc-
> > discuss/Yph14Uv3BuicNJi9%40localhost.
>=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 pandoc-discus..= .@googlegroups.com.
> To view this discussion on the web visit https://grou= ps.google.com/d/msgid/pandoc-discuss/2acb8d6c2b3f4042a0e940cbda7899e4%40uni= be.ch.

--
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/00769f1a-ee10-4fc2-bb22-9cb1ac351450n%40googlegroups.= com.
------=_Part_281_1493464260.1654159622704-- ------=_Part_280_522195922.1654159622704--