From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/30656 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Bastien DUMONT Newsgroups: gmane.text.pandoc Subject: Re: How to make my latex environment accessible from markdown via short-code? Date: Thu, 2 Jun 2022 08:33:37 +0000 Message-ID: References: <4de0a599-a196-438a-928c-b0895b35afb6n@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36952"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBDCINCES2QJRBY7L4GKAMGQE34MUX5A-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Thu Jun 02 10:33:43 2022 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-ed1-f64.google.com ([209.85.208.64]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nwgH1-0009Qi-6S for gtp-pandoc-discuss@m.gmane-mx.org; Thu, 02 Jun 2022 10:33:43 +0200 Original-Received: by mail-ed1-f64.google.com with SMTP id i20-20020a50fd14000000b0042dd305d0f7sf2987440eds.18 for ; Thu, 02 Jun 2022 01:33:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654158823; cv=pass; d=google.com; s=arc-20160816; b=AvFLQoQ7rRxtId9bOFT1ozlT5raRQmSYYvE+/hMe2gCLoJUrlgZZSOVxLc1FF5u1x7 qw2n3yKPJxDkdxe3+JYGlxjURourNjgJ2Ln+YOwT8mPN0/zZCc5tya8G3BpAy+gIBquE XGXfthNMLoqpWwUaBvgKBn040INhrjoqYTUnjhtdrofR+g7ehp91DpKwoeJE41U4CNe6 NMBRfzs5WrOAb9Xa36zJNoOviITTMli/eiazgH8/Z7btOKR6MGng00A+UJ6xf0ZgGGPl YFBBKrJtnnsD+t0mmqtk1b/uX/qXfDvJbbKCAVp+OQT+v6zkIk0Cvtfm15pESfvrt3yc bKUA== 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:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:to:from:date:sender:dkim-signature; bh=qO/4alcxOtW5Jqbb2Krs6A+B6I09+Nfn5XAU7eSPKEI=; b=Z3UvPEEVcIJCgA916FDjuk3Dk4fp2C9Tvl727P1tQfiFH6DNgPnDdhaul+ijDe/Q+4 mhzFHzBzIXPnQcVZQyubouSYT0gsFP4akHXxaGoKnGcRKK3QVlpaIURE/MXaD0PYFHfv l3hiqipE+zk5D+oTqfy0WMEmiNOV64Vg0Yie3+pIM6EtyxidnrsZo2taHQ2IfVvlRr8t 3oUUHuyofIoqDw1EmX/EKgOlww+E/COuGNv9yQ77kLYBeopCjMlniTo5G+SPKiDPx1aB HNsOGT5zVkXp0EcaduabkZj2jbm5lguokHGuk0xPHHmYe03G2bVaCVj/E3oq7i/eIlAK ARjw== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b=IlA4O5cV; spf=pass (google.com: domain of bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org designates 185.67.36.65 as permitted sender) smtp.mailfrom=bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=posteo.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:date:from:to:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :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=qO/4alcxOtW5Jqbb2Krs6A+B6I09+Nfn5XAU7eSPKEI=; b=W7rSeycB2AmwJXGcX197fHBxFvzZ4hC6QWHGz+yuXTDC74L8IGwdsaPIsPch6gZUvm Eu4qN5hIBZE7ufS1M7VRq4yWNYtQgFNTCS2KhWuu0sJEzUiEWtzCgSGc5v0lc5mO2vNk +/M6Ex3noIEN7ut7XnXr+aonHY9qHQVDOy2sQsYDhyvJkHGkcoLc0496gZDW8i/h/7Be Pk3BDYlYYu8xVyOfp0fm1ni4gseSFUFLDMUQ74pVVcpVIQZKHeZuXBhWqkW+H+GTVOfj lq05buvMSmsIr5IemTRg5BtidCVtIqj6ISRiq2m1nG7X3aY2ynN86bC3q7UL4HFoU+58 L8KA== 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:subject:message-id :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to: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=qO/4alcxOtW5Jqbb2Krs6A+B6I09+Nfn5XAU7eSPKEI=; b=POUNy9FIf2JqBnk+mRhyXMv3Sj4qZeav2hlum9v6pDofeCf0RLsq7tERVOeDxTNiP/ ar38aZbPJGFfWyaHzEAk5la99tPzA5nP1vEYRWgFSMgO8RhltiQ2t2EeAvjXGfdUyTKc a+jlP5XikUGDYCN91vnUnFZoK2zi0juiam5XEa3dY0jYX0RBIsx/i1Yk2o07gwz2Iq2n u7OVO4o5KOvmQyXk6w8f7d3mmmIME9mOH3jaCWhSrrFUSRRMP5puYeYi74kuK1HkaKYR HdpQ0n8UJ9EMjxIV9+LtJW+WZJwaY5+1TXSGEG6hgUiy Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM533F7g7migdQZSa1ok4xJ9elj+Kz3feT9a2gF86n1Ksno6YycsLM d9buriuT65SRPqysq3N4DhM= X-Google-Smtp-Source: ABdhPJxSLYw/aEgRaTsAc7Sihu215Juy85mjoKmFNVho1dIwzZHJG9ASDLRpATIRdGJG29bJAm5M1A== X-Received: by 2002:a05:6402:3227:b0:42d:df54:ba24 with SMTP id g39-20020a056402322700b0042ddf54ba24mr4030238eda.49.1654158822681; Thu, 02 Jun 2022 01:33:42 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6402:5205:b0:42a:c2bb:3d7f with SMTP id s5-20020a056402520500b0042ac2bb3d7fls977929edd.1.gmail; Thu, 02 Jun 2022 01:33:38 -0700 (PDT) X-Received: by 2002:a05:6402:3491:b0:42b:635a:efaf with SMTP id v17-20020a056402349100b0042b635aefafmr4019847edc.135.1654158818903; Thu, 02 Jun 2022 01:33:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654158818; cv=none; d=google.com; s=arc-20160816; b=zaEhDSWWUYyKpBk1j+nu96xf5ycVyEcqjl9rfXtb3uRanzOyC1X9b7p9cODfaQFt3T G+wKeXjIfEoarRyW4HjmbdvtDjGfww89sUbnOiX5XRuR11ohPNPWmohqlq1YkTVbgFU5 y2uC/I/mtaoWTBlxAl5OHezLsQ8aKSMO58lSG8WwejFWci7ksfYpT23sGgZPK5jPP5t6 53819MoaAXPNjjZxPjSYZXqoE7zDKnEc5Kjn287+f452bLGDF2tCFno0CvTYQHJsg8Ev QqZuhr3Sx93Mhb4m8ePJrDOB2gSYWpjd5IToHRganNd5bSFGi758i/PNzA3jhmC544zi ABvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:to:from:date :dkim-signature; bh=zbiSaEcoC+m9qqRqhnKDEULsdyWVLf9u8Ny2vRM6L7A=; b=ORiuB7LbwiPjo9SWipF7fP6mnHIUSv5h4DJw1hKQOfmHY7/u1H8yPNJV7viUHKe6kY Ha5I1D9XbPMicD2E3Su6U5++FAKShHFtL40oHCL2IocvxbN6+FnCchUwXqKtz5I+AiQn iQZQnh6UQRtxL33jvDbOHYSsoEfsltfjqxPEy59t54nmmvrnD0er6kkzibozhngo1Zqs c8zewQoACVZknWGRv8lCzSpBBYiLrUwPJpKl9njeqRHJtCNsV2nwDU/lhIEvhZLMF+kQ +ifAgquBiTNgLFCJ5BpWF/YYgh6Ddm9DjA0yaayFpSEDIUviuaEWLuqMvz5TgGXQ+zLA wNhA== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b=IlA4O5cV; spf=pass (google.com: domain of bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org designates 185.67.36.65 as permitted sender) smtp.mailfrom=bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=posteo.net Original-Received: from mout01.posteo.de (mout01.posteo.de. [185.67.36.65]) by gmr-mx.google.com with ESMTPS id q24-20020aa7d458000000b0042d687c85d2si206355edr.0.2022.06.02.01.33.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jun 2022 01:33:38 -0700 (PDT) Received-SPF: pass (google.com: domain of bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org designates 185.67.36.65 as permitted sender) client-ip=185.67.36.65; Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 7D37D240029 for ; Thu, 2 Jun 2022 10:33:38 +0200 (CEST) Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4LDK6V0lLPz6tmF for ; Thu, 2 Jun 2022 10:33:38 +0200 (CEST) Content-Disposition: inline In-Reply-To: <4de0a599-a196-438a-928c-b0895b35afb6n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> X-Original-Sender: bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b=IlA4O5cV; spf=pass (google.com: domain of bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org designates 185.67.36.65 as permitted sender) smtp.mailfrom=bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=posteo.net 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:30656 Archived-At: To complement Denis' answer, your Markdown chunks in "hint.lua" are handled= like strings 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 applies fi= lters. Filters manipulate objects in the internal representation of the doc= ument and should return such objects. In exceptional cases where you 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 li= ke 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-c= ode. >=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 escape= d > 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 qu= isquam 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-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit [2]https://groups.google.com/d/m= sgid/ > pandoc-discuss/4de0a599-a196-438a-928c-b0895b35afb6n%40googlegroups.com. >=20 > References: >=20 > [1] mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > [2] https://groups.google.com/d/msgid/pandoc-discuss/4de0a599-a196-438a-9= 28c-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/Yph14Uv3BuicNJi9%40localhost.