From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/30964 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: A A Newsgroups: gmane.text.pandoc Subject: Re: Adding own elements to pandoc AST Date: Thu, 14 Jul 2022 05:17:26 +0200 Message-ID: References: Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000000edd7805e3bb5835" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31462"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBDJ77HUDRUCBBVEVX2LAMGQESTGE5RY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Thu Jul 14 05:17:45 2022 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-pj1-f58.google.com ([209.85.216.58]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oBpMG-0007yV-Ky for gtp-pandoc-discuss@m.gmane-mx.org; Thu, 14 Jul 2022 05:17:44 +0200 Original-Received: by mail-pj1-f58.google.com with SMTP id q8-20020a17090a304800b001ef82a71a9esf587379pjl.3 for ; Wed, 13 Jul 2022 20:17:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1657768663; cv=pass; d=google.com; s=arc-20160816; b=hjqLEaBwvBXXao3hBOS1ASjkXWI36drmXccyH/JYJUkU5wispshF4z6jv1QlK+MmCW T8j0KFDFS3RkTKYhi5H2JEW89yanpFVM2TsfngyNAUtgXkmQOB+WCoUCC13JcOfDJCLA vE/sRNcgB5OQt61UvhBdH9g8KL6shvS06HzxAku2qp74JCYqi2p03WE+sdMXJKng0KNd rSa6Ah/PkwOu9lC623NNO0am287CdRLzkRKE7fE4DP7uaNkTmSBfAUClUIEnLzUSpuQ8 EO30myFdHTxKuM5/3yb3umJLbXgxnKK9qyPVlhk9dcFl7fHcS2BxgNelrOdzRuFeZ7I5 GB+g== 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:to:subject:message-id:date :from:in-reply-to:references:mime-version:sender:dkim-signature :dkim-signature; bh=PI1/hhPqwYE/quoVoQforGE55JAm9J7XnLht2jT2F2U=; b=zgLFwd/cIhP+wSDZI8r5nc0mWd+aght40Qfu3WA6hI3az5fVue44BkSPAO92IDpNqs EL13+Hm6AiGZvAcAuoyNjPvMOAWvZNdHRpcUafmRTNsjeI+rPR5YLlejU0rK9iiS1SWE ENZE+KC4eflAyDoVv6v2UJpNZjEimXVBB5CGhgRvX5NZ3AE+VyabHSmTxsL3EDF7QoqI /ErCwuvLtc9VlPF3pHd9coiain4ngF4jJpVTFIoXxQ5R7lZ3PjnTEntlQlOrA9H4Fy8s 6R7PbUmNIaDdhf5nbKHVR6oJVbamn+squl/fuKpWQHI2YOVloSmAYkMnPcgDnfCp9qPR uRuA== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=UzG+QHX1; spf=pass (google.com: domain of amine.aboufirass-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::102c as permitted sender) smtp.mailfrom=amine.aboufirass-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:mime-version:references:in-reply-to:from:date:message-id :subject: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=PI1/hhPqwYE/quoVoQforGE55JAm9J7XnLht2jT2F2U=; b=bpCz2pLDOvYaVy84w+iKHC2e5c30tW72e5rNHtbLiBvVr76tdPsOomsI3PEPI77SPj 3dA3zZdtdy1HugVg6XvZgyd4XRfe9iPDVRUxY3LpdyKAXNiAUySb/plmpriUyFd7wBHy j7o0+eiLdLWanryW2eLPFOjggu8l4h2NExXNhBjf4xWFudBLqKC/Qbx9TjOYqj7Dfi0l aMkiwrtXmBU6yv0iz16JZSA/cWiiJ3vGiN1ag03NdUjvOfRc4Dpwsx+2WpMsw++7bePn J4JnQ3Wsh75DgXqN/LZWl2drx806AcwU9ncH09mE/m5dfQXkdy+rJiH7cHZM1zu2vdOd u6aw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject: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=PI1/hhPqwYE/quoVoQforGE55JAm9J7XnLht2jT2F2U=; b=Z7prG7zCNosREPsTB6jg/dfUiwQeda3TK3i/VvzVvKA7Tyeslg4cjg5AlsieHzB5vq H3yxcV5/JD+togNNRctZA88dlOrFa7BVDpIxZrMZ0nH1+kx0nz0WdxcDljnN+0+g+tq5 tc+U6I0VE7cQMTqe1uF3R8pxBTb0WMDQFDX0GGK2qWdub5qPHNCNDAF2OLLttOG/BeDW pRIFvEhXN79rjcioA6mEd744IaVWHR/Eyx8N6z5MwskVQbN/gFsdT/sHOLgRoHeaSbjc sWzT+S64knBgCprFJUZtAusWua/5J4Ma9KMKcHDKOmna6ZXwQ3QBI/vZwfikscgeONH/ 4NSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:mime-version:references:in-reply-to:from :date:message-id:subject: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=PI1/hhPqwYE/quoVoQforGE55JAm9J7XnLht2jT2F2U=; b=HnPXEoh3nPSK3j81ELnG/Sf47yFK3b8YN7Y+K8smdXZ0ExXvGWZuFdTYJIrbTvy9IB uDffau3sW++hoNPT/IS23cY1tCY6MyA/1h5O6mcmp9wAzvGpW6LydfNCBeIH9VK0wbQc zK6A59YXLSky7yDD79JGLDtj94lGb7ElUqtlV3sUGnmVEpThQbTqYDDk64v4UsJVrMy/ Dx7jDFvEomnjmrIoR13ayHzcSghrZh+/uf4vWyeDufbUy5qM82hp4BjVGclKR24z1dqu ESl9AUv+MQE7NhHUzM+AFLarweiUU25t4FnY/eXoABnvJAe7ylt/2GNX0bDTHaXyYOje EmTw== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AJIora8EwkqtGY2uq7tYxgVUcQRYvYmSb3zUtGvpIyOiJIGsvYcSgzr6 ce/u9UtRN3fn4sdoVi1++pQ= X-Google-Smtp-Source: AGRyM1svR5iC6I12IGidZqPtkhtPykrg2wZt7Yiz+XjJEir9aDQd3hOkYXDY+HZmVHm+7bDDclDXxg== X-Received: by 2002:a63:8348:0:b0:415:d3a2:c943 with SMTP id h69-20020a638348000000b00415d3a2c943mr5734761pge.403.1657768663200; Wed, 13 Jul 2022 20:17:43 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a17:903:2351:b0:16c:1785:d810 with SMTP id c17-20020a170903235100b0016c1785d810ls4079518plh.3.gmail; Wed, 13 Jul 2022 20:17:39 -0700 (PDT) X-Received: by 2002:a17:902:d581:b0:16b:e6b8:4080 with SMTP id k1-20020a170902d58100b0016be6b84080mr6316173plh.146.1657768659688; Wed, 13 Jul 2022 20:17:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657768659; cv=none; d=google.com; s=arc-20160816; b=p2lT57pwmbutcg/rqLiVTkNb8rOlYGrUM4ZFD6HqvfzuoKUQdK0+VxwTxeTQtXRuvy DcNF0CCf37nXr4olD+Z5TyFxbUfHfFhTi3qbWnJyXpwuYoxNzMSt+w8JQJRYjfH5IhzY ZWrLM1P9X5kXGY1Yuu40JW6mwwRk2GkTOO2qjm3MXugQprgqJtmV0ru8IAVkdR4tSrCr nOnc8lEo3ltZI82gkN3HLxg7serpOga4pyUvdyH+1uvEfNkhYjbvqF1Kw6eBJVvEEmf2 rqEROxzJ7FdTPqR04lYRz8lM7MX4iX8BUOfVfTXIXaZPEyoJrqVYcncovlf5gfJLWwmA PQOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=ypQ2uF9Nvc9rVoiCXU/KmeJJhsmxq1DulCkDXcGbwuA=; b=llo32/8pypXFjMWf/5lY+05j+UVFQ7gNZh8D6bu1iKPRM5kK8l/1HZubzthJAWfkkw kd+VR0br9FjWZCrZ1uszVtl9dzYRCbz8bxvWVZeNuAaM3l+2XN6icGQFRJeW+MpqBOxB qAFM1gReU3wTyDuRvluXixFhu26oHqgIlUYdXMw0bjm0mFQmKRiCVXCc4FjBXanRpZRs 6YmVTAFAVta/CtDGaRUJbjleEQUfRoVkf9RHEB084n+9u0bnun1yVf4BVFUtgntr/CnO 67s0nR5Z4Mb9lVUG/fJxjc1Jrc+Dv72M9MIZtgT/QXpYGCQSC95xUzmhG4A+0qm5t49f juzw== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=UzG+QHX1; spf=pass (google.com: domain of amine.aboufirass-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::102c as permitted sender) smtp.mailfrom=amine.aboufirass-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Original-Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com. [2607:f8b0:4864:20::102c]) by gmr-mx.google.com with ESMTPS id mm15-20020a17090b358f00b001efc9eed180si155071pjb.0.2022.07.13.20.17.39 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 13 Jul 2022 20:17:39 -0700 (PDT) Received-SPF: pass (google.com: domain of amine.aboufirass-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::102c as permitted sender) client-ip=2607:f8b0:4864:20::102c; Original-Received: by mail-pj1-x102c.google.com with SMTP id o3-20020a17090a744300b001ef8f7f3dddso1225202pjk.3 for ; Wed, 13 Jul 2022 20:17:39 -0700 (PDT) X-Received: by 2002:a17:902:c947:b0:16b:f442:8568 with SMTP id i7-20020a170902c94700b0016bf4428568mr6229254pla.55.1657768659310; Wed, 13 Jul 2022 20:17:39 -0700 (PDT) In-Reply-To: X-Original-Sender: amine.aboufirass-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=UzG+QHX1; spf=pass (google.com: domain of amine.aboufirass-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::102c as permitted sender) smtp.mailfrom=amine.aboufirass-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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:30964 Archived-At: --0000000000000edd7805e3bb5835 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Dear Bastien, Yes, in python I could also do a regex match on string elements, but you can imagine this is a bit less ideal than creating a new AST element altogether. Having an AST element would reduce the complexity of my code on the filter side. I would only have to add an appropriately named function in Lua, rather than have multiple if string.match then statements inside the Str object for every new syntax I=E2=80=99d like to add. I=E2=80=99m tr= ying to see how difficult/feasible that would be=E2=80=A6 Some extensions already add syntax elements, consider fenced_divs, how do those extensions do that? Regards, Amine On Thu, 14 Jul 2022 at 00:34, Bastien DUMONT wrote: > Is the content of the \gls macro always a one-word string (without > spaces)? If so, using the markup in your sample, you will end up with Str > objects that you can handle like this (in Lua, I don't speak Python but i= t > should not be difficult to translate): > > ``` > function Str(s) > if string.match(s.text, '^gls:') then > -- code to handle the string > end > return s > end > ``` > > Le Wednesday 13 July 2022 =C3=A0 11:05:33PM, A A a =C3=A9crit : > > Dear all, > > > > I have a use case where I would like to be able to add my own element t= o > the > > pandoc AST such that I can use it in a panflute filter. This would be a= n > inline > > element emulating LaTeX=E2=80=99s \gls{term} command from the glossarie= s.sty > package. > > > > I envision the markdown to look something like this: > > > > mentioning a gls:term from the glossary. > > > > or something like this: > > > > mentioning a gls(term) from the glossary > > > > So the syntax would be very similar to LaTeX, but a bit more lightweigh= t. > > > > Is there a way to do this in pandoc? Inheriting from Block or Inline an= d > > setting up custom syntax such that it can be processed by a Lua or Pyth= on > > filter? > > > > Thanks for your consideration. > > > > Regards, > > > > Amine > > > > -- > > 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 > 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/msgid/ > > pandoc-discuss/ > > CAMwawgNgACJDXLyFAcx26iy4-71yOUD%2BHccx67%2BRgJB132D0_A%40mail.gmail.co= m > . > > > > References: > > > > [1] mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > > [2] > https://groups.google.com/d/msgid/pandoc-discuss/CAMwawgNgACJDXLyFAcx26iy= 4-71yOUD%2BHccx67%2BRgJB132D0_A%40mail.gmail.com?utm_medium=3Demail&utm_sou= rce=3Dfooter > > -- > 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/Ys9IXXrcD4Nwmu6q%40local= host > . > --=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/CAMwawgNLuqw-NM_RYCHurBdg0EH20sjeAiYGOepmbgQLW9MD_A%40mail.g= mail.com. --0000000000000edd7805e3bb5835 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Dear Bastien,

Yes, in python I could also do = a regex match on string elements, but you can imagine this is a bit less id= eal than creating a new AST element altogether. Having an AST element would= reduce the complexity of my code on the filter side. I would only have to = add an appropriately named function in Lua, rather than have multiple if string.match then statements inside the Str object for every new syntax I=E2=80=99d like to add. I=E2= =80=99m trying to see how difficult/feasible that would be=E2=80=A6

Some extensions already add syn= tax elements, consider fenced_divs, how do those extensions do that?

Regards,

Amine


On Thu, 14 Jul 2022 at 00:34, Bastien DUMONT <bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org> wr= ote:
Is the cont= ent of the \gls macro always a one-word string (without spaces)? If so, usi= ng the markup in your sample, you will end up with Str objects that you can= handle like this (in Lua, I don't speak Python but it should not be di= fficult to translate):

```
function Str(s)
=C2=A0 if string.match(s.text, '^gls:') then
=C2=A0 =C2=A0 -- code to handle the string
=C2=A0 end
=C2=A0 return s
end
```

Le Wednesday 13 July 2022 =C3=A0 11:05:33PM, A A a =C3=A9crit :
> Dear all,
>
> I have a use case where I would like to be able to add my own element = to the
> pandoc AST such that I can use it in a panflute filter. This would be = an inline
> element emulating LaTeX=E2=80=99s \gls{term} command from the glossari= es.sty package.
>
> I envision the markdown to look something like this:
>
> mentioning a gls:term from the glossary.
>
> or something like this:
>
> mentioning a gls(term) from the glossary
>
> So the syntax would be very similar to LaTeX, but a bit more lightweig= ht.
>
> Is there a way to do this in pandoc? Inheriting from Block or Inline a= nd
> setting up custom syntax such that it can be processed by a Lua or Pyt= hon
> filter?
>
> Thanks for your consideration.
>
> Regards,
>
> Amine
>
> --
> You received this message because you are subscribed to the Google Gro= ups
> "pandoc-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send= an email
> to [1]pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
> To view this discussion on the web visit [2]https://groups.go= ogle.com/d/msgid/
> pandoc-discuss/
> CAMwawgNgACJDXLyFAcx26iy4-71yOUD%2BHccx67%2BRgJB132D0_A%40mail.gmail.com= .
>
> References:
>
> [1] mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> [2] ht= tps://groups.google.com/d/msgid/pandoc-discuss/CAMwawgNgACJDXLyFAcx26iy4-71= yOUD%2BHccx67%2BRgJB132D0_A%40mail.gmail.com?utm_medium=3Demail&utm_sou= rce=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 pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/Ys9IXXrc= D4Nwmu6q%40localhost.

--
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/CAMwawgNLuqw-NM_RYCHurBdg0EH20sjeAiYGOepm= bgQLW9MD_A%40mail.gmail.com.
--0000000000000edd7805e3bb5835--