From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/30965 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Bastien DUMONT Newsgroups: gmane.text.pandoc Subject: Re: Adding own elements to pandoc AST Date: Thu, 14 Jul 2022 07:46:06 +0000 Message-ID: References: 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="36950"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBDCINCES2QJRBQETX6LAMGQEMO2PQSI-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Thu Jul 14 09:46:13 2022 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-wm1-f60.google.com ([209.85.128.60]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oBtY4-0009QP-QH for gtp-pandoc-discuss@m.gmane-mx.org; Thu, 14 Jul 2022 09:46:12 +0200 Original-Received: by mail-wm1-f60.google.com with SMTP id c187-20020a1c35c4000000b003a19b3b9e6csf2256468wma.5 for ; Thu, 14 Jul 2022 00:46:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1657784772; cv=pass; d=google.com; s=arc-20160816; b=OOeKNELfp1MhJpzY1MHJmwagi19h1ygP7Mx1a7Oi4As+UBZm9TqTVOTD9NC5ikFV+m bCfdnvueBbBQutAe1HTinQkPUyNcjeBOyUDOmisR06EvJhmyPBi+xzbXbr3l3h6gF7Cv JXC+rCldzO+Ct91LwnYiQpRzkpbgOYgLTJZzwDx/sGIsLtPoEbqg1KlF8PgsJMOjwbqj 6c6XRyx/B4aAoyIqP8k+Tkae8XkXFPRAHckdpclDsq825JPkpbHxD4egbgSbDNUeMgjr /T3qJ2TF+4JSDGMghqrqkkBp8/23LKzyGN48Vo77ouDBKMROmrS8GTPlXT4JRCV5jzl4 570Q== 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=i2CE55FKdNEaH3a6b2HvrsiGy67DJdTAhIuvSh7rBE8=; b=JwZhPpgyTPWNRftdBSoB9qODdIuQHzGAyEa6AU/CIWvT1vAVE78Eu0FMtMn2Nfnu1s 3R3QkgZDyQt7ivLQZSGkGUlONb+zKZ3yTCXHFY6cSvzljh71EZUiF8PualrDQX9b3QTR Tu6Pc4sm5rfoi20jckbARmb2y0jH6HOoPk9Bx2dt8P7424/Jmv6/IClwe+xfZus6MrJ3 Ev33f7D/3dCwEwXjqJdm2yZrRO97L4rpGqr9L7OI2nGYtzqUxk8A1J+QW+D1gKKf5/va QqSFm1j8y/oMGfTk4RIgNLBo9mpRHkwTVCW7906L7retjOokgY8f/7g0z4Rxq/65yq3W HQpw== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b=jFniOXFh; 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=i2CE55FKdNEaH3a6b2HvrsiGy67DJdTAhIuvSh7rBE8=; b=fm/f2kZqNAw7SzlhDvDxLeqf+AKu9QpWAq7VeztXVtjtdllq9Wvc+REyRm2Da3BcfW BFnhJw99YjMSwoVuknz0Uyw8bDO/DHBmDMorpayAPPWlKvVRx823m3uqeR7ALlqfhmVU N/W0hG2dacWPEqTSSB+vBNoukCctzxNRYCRK16oPzSuwjf/5P9/eNN5zwTaCPVR1Pf9U yu4sM3g4avoqsRhiPaR9p+BeM8NlDXIsBQ21czhfp9gxEOaH28oAPTaXvULGM/xJSEHE KMcAtX2XY8TGaGjKbynY1cqLn9jcSFsMmTiCJJDrCX3LSq1kdzs0hqTkAYqqqnqUp4iu PSTA== 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=i2CE55FKdNEaH3a6b2HvrsiGy67DJdTAhIuvSh7rBE8=; b=SfvlWAKPJgZvK0935/tY76WvZmyOc7+7E/y1coEqY8i0uk0VGOgxLj955n46GTh8su NeTDAaXHQtFF5b2fA0ZWf8cD31482Dr8dJlsEpavp2qT60RHcNxSyyhnm3vrpWccSaFs p8Bhn4DL7wVScxYv6iucfEE6xKzl/Xb2s+D+oMzlNE2kPiACwOOVdRW3LV2jHcUPMM4C TqvNzCIXH8OoGKdLTCva4LylycBTdIvMuWx5XRBg10Nnb5FMW5Ybi6vAzLb095+Mz4Xl 73Oz5mEoC1kwz8t/M4ogCepsW0m3TSDqgfcfv232pdF5 Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AJIora81dhk1LG6IwLgJzfrKuY1mywg9Emzhbt1D2gK5L1pK2Cf0Ln95 qFAC87qm2EC/ZbCopQ1mvQo= X-Google-Smtp-Source: AGRyM1vM8droyqd/MWujELsZxAS163pxdJh3KIugt9V/0/xBzKNSXr493Rq4ONDZDal/JByPoDWgQw== X-Received: by 2002:a05:600c:25ce:b0:3a2:dd48:9b33 with SMTP id 14-20020a05600c25ce00b003a2dd489b33mr7823712wml.134.1657784772350; Thu, 14 Jul 2022 00:46:12 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6000:1ac7:b0:21d:ab25:25ba with SMTP id i7-20020a0560001ac700b0021dab2525bals242880wry.2.gmail; Thu, 14 Jul 2022 00:46:07 -0700 (PDT) X-Received: by 2002:a5d:4710:0:b0:21d:6905:f6ea with SMTP id y16-20020a5d4710000000b0021d6905f6eamr7039147wrq.395.1657784767930; Thu, 14 Jul 2022 00:46:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657784767; cv=none; d=google.com; s=arc-20160816; b=ydqFAn8BGk/eCu13g/tjCm1TQr8GdyYKMsjni/SanLRqBoZ/L600xjxJOA7ChlBNfI jEIT2wXR3azMwOgAjllNQHGU8Imx+02E7QJk23UbejlDTf1OfGE3NHGv8NQs7yfz/vSn 51c92dNj8jbE63kczS8VypS18p5/G5APvxINGShAxs8w1cBjhQ/NP2I4vYWguSQYrdmZ nmeWWtsWzFHTKnCAARgh43BEWVE+Jo9NtS2dsEVcNiEBMH0LXWknAvrU8F3ysm9vve7/ 4ld2r0aUf0onjgvboqZ+s3NO+Y54uGhwPBke4lDGOmfKLWG2hRVEr3YuvKqmroHZE0CE 1I3w== 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=T+koafxrqbWSwKCt9/XtwyG8X6rtyO/cuGfMGzXwV3w=; b=whsmY1KB+sd5q73YxGq7L8mjxRNjHfserUm3GAIC0H+olu5Z4d44cvg3tpIoz9bqAm yXCdmjO6oAOtYBJIDhhN6AIY4jsncOgzJo9MbCI1wd3S1Z4IXBkxpNQKWYl96B68Pd5a YTumx2LQVBb/eKijQZCtu1o1z0Pm/0hYsMkQIjPEULrAfTcfcebn98oPnGfBLIgfUYKf K07jWsfsnVxsc+0rcQmVWf5HR/jQQTXbaypqRHustczn/Tql8rQCEOUrqFkfTImjK8oY NBZmdYOO9A1aQUV5ozncweqdqPsO8qA0qosXAH0F3W/vrYEfu7eOP6LIlx9/jdQd16gi /ffw== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b=jFniOXFh; 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 co10-20020a0560000a0a00b0021d9b97121bsi25314wrb.4.2022.07.14.00.46.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Jul 2022 00:46:07 -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 81EFF240029 for ; Thu, 14 Jul 2022 09:46:07 +0200 (CEST) Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Lk64H13Wvz9rxS for ; Thu, 14 Jul 2022 09:46:07 +0200 (CEST) Content-Disposition: inline In-Reply-To: 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=jFniOXFh; 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:30965 Archived-At: Your intent is twofold: you want to add a new type to the data structure of= Pandoc and to implement a new syntax corresponding to this type. You cannot do the former unless you modify the sources of Pandoc and build = it yourself, so you will have to emulate your "gls" type from another type.= From the samples you provide, Str would be the most straightforward, but y= ou can consider Span too, especially if the content can be composed of more= than one word (e.g.=C2=A0[the term]{.gls}). If you want to stick to panflute, I can't think of another way to implement= the new syntactic rule than what I proposed. However, you can also use a p= reprocessor such as pp, which would enable you to use the !gls(term) syntax= and transform it to [term]{.gls} before passing it to Pandoc. You can writ= e your own script for preprocessing too. But in the end, you will always en= d up with a regular Pandoc object that you will need to post-process using = pattern matching in your filter. Le Thursday 14 July 2022 =C3=A0 05:17:26AM, A A a =C3=A9crit : > Dear Bastien, >=20 > 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 altogeth= er. > Having an AST element would reduce the complexity of my code on the filte= r > side. I would only have to add an appropriately named function in Lua, ra= ther > 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 d= ifficult/feasible that > would be=E2=80=A6 >=20 > Some extensions already add syntax elements, consider fenced_divs, how do= those > extensions do that? >=20 > Regards, >=20 > Amine >=20 >=20 > On Thu, 14 Jul 2022 at 00:34, Bastien DUMONT <[1]bastien.dumont-VwIFZPTo/vqzQB+pC5nmwQ@public.gmane.org= t> > wrote: >=20 > Is the content of the \gls macro always a one-word string (without sp= aces)? > If so, using the markup in your sample, you will end up with Str obje= cts > that you can handle like this (in Lua, I don't speak Python but it sh= ould > not be difficult to translate): >=20 > ``` > 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 > ``` >=20 > 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 eleme= nt 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 gloss= aries.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 lightw= eight. > > > > Is there a way to do this in pandoc? Inheriting from Block or Inlin= e and > > setting up custom syntax such that it can be processed by a Lua or = Python > > filter? > > > > Thanks for your consideration. > > > > Regards, > > > > Amine > > > > -- > > 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, s= end an > email > > to [1][2]pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To view this discussion on the web visit [2][3]https://groups.googl= e.com/ > d/msgid/ > > pandoc-discuss/ > > CAMwawgNgACJDXLyFAcx26iy4-71yOUD%2BHccx67%2BRgJB132D0_A%[4] > 40mail.gmail.com. > > > > References: > > > > [1] mailto:[5]pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > > [2] [6]https://groups.google.com/d/msgid/pandoc-discuss/ > CAMwawgNgACJDXLyFAcx26iy4-71yOUD%2BHccx67%2BRgJB132D0_A%40mail.gmail.= com? > utm_medium=3Demail&utm_source=3Dfooter >=20 > -- > You received this message because you are subscribed to the Google Gr= oups > "pandoc-discuss" group. > To unsubscribe from this group and stop receiving emails from it, sen= d an > email to [7]pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit [8]https://groups.google.com= /d/ > msgid/pandoc-discuss/Ys9IXXrcD4Nwmu6q%40localhost. >=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 [9]pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit [10]https://groups.google.com/d/= msgid/ > pandoc-discuss/ > CAMwawgNLuqw-NM_RYCHurBdg0EH20sjeAiYGOepmbgQLW9MD_A%40mail.gmail.com. >=20 > References: >=20 > [1] mailto:bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org > [2] mailto:pandoc-discuss%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > [3] https://groups.google.com/d/msgid/ > [4] http://40mail.gmail.com/ > [5] mailto:pandoc-discuss%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > [6] https://groups.google.com/d/msgid/pandoc-discuss/CAMwawgNgACJDXLyFAcx= 26iy4-71yOUD%2BHccx67%2BRgJB132D0_A%40mail.gmail.com?utm_medium=3Demail&utm= _source=3Dfooter > [7] mailto:pandoc-discuss%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > [8] https://groups.google.com/d/msgid/pandoc-discuss/Ys9IXXrcD4Nwmu6q%40l= ocalhost > [9] mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > [10] https://groups.google.com/d/msgid/pandoc-discuss/CAMwawgNLuqw-NM_RYC= HurBdg0EH20sjeAiYGOepmbgQLW9MD_A%40mail.gmail.com?utm_medium=3Demail&utm_so= urce=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/Ys/Jvo/Zf1AW12Vk%40localhost.