From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/30977 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: John MacFarlane Newsgroups: gmane.text.pandoc Subject: Re: Adding own elements to pandoc AST Date: Fri, 15 Jul 2022 11:29:39 +0200 Message-ID: <6BC0E81E-3DB4-4DA1-AA2B-3FCE12F77E52@gmail.com> References: Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) 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="3095"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBDW7ZIEHTIIBBBXHYSLAMGQENNX47TQ-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Fri Jul 15 11:29:46 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 1oCHdp-0000dB-Q5 for gtp-pandoc-discuss@m.gmane-mx.org; Fri, 15 Jul 2022 11:29:45 +0200 Original-Received: by mail-wm1-f60.google.com with SMTP id ay27-20020a05600c1e1b00b003a2f3b04262sf781942wmb.1 for ; Fri, 15 Jul 2022 02:29:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1657877385; cv=pass; d=google.com; s=arc-20160816; b=tF1cE1DpZgPbhwlUW9tGnnPOo7JiGAcosfsUaZ+OD0FLOuiQftyzO8qufjxxfcMV1k jlpkIzESxbmldmC8v1il5qR3wbp5f7jNyzttgHec/O5rQo+soKD3kjBFdy5b+Bl3IPuC Ka9bb6jGYjYU3bOUGLNAF2kg+Y8egucEDcz2fL23PYX05ld0J2L9AWaqXHtwj5W6teMq JY8rTVyNcbovQ01Mo6sjC8X1AcwwDkA5jfZd9so+iPkMdCLVTNzJ6Xyy3FnR6usq21jA NkXu4C+B4XTz5dP9F5fwEyFBXAx0aBnNB4Mnm4Hj0E1EVl3t1oI0Hry7zUsOPqplBBJl W6Vg== 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:message-id:in-reply-to:to :references:date:subject:mime-version:content-transfer-encoding:from :sender:dkim-signature:dkim-signature; bh=o1hMK1oOtHU51kJQ+l1S5TL6CWZUk4KhHr+hW5pofo0=; b=CAE6dCXvPI2KE8XsGnQdaPsenTFDWgfja7al69xb2W/YU/G07HrizmecqnPTtwA/d3 VlD/T2+wS7yP0kfeJEwVemaabcR5HPQGoQuMsLrFBNbsDC6gHtKZHgQ2VRnbpi88u4sq gzy2tM92sLeDDew7Y0rLQFFT8V+JIqRJmLCXkMfq8HH8E6UugtQfd6D28Yt2+9I3Y0iM wlR5V8/7Jdo4GQf4ejnIdRa7OEymiHl3uMYJk+V3YSHQcSGirBiSxoNybBKBugVNgNaq voZnf1Pt1Xj6YImjxOIYxo1FmEjQ/h/uDqmxmQ2aCHiziemTPNjpGVE52+a93P1CxOf7 mpmA== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Y3aQ+NOt; spf=pass (google.com: domain of fiddlosopher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::333 as permitted sender) smtp.mailfrom=fiddlosopher-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:from:content-transfer-encoding:mime-version:subject:date :references:to:in-reply-to:message-id: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=o1hMK1oOtHU51kJQ+l1S5TL6CWZUk4KhHr+hW5pofo0=; b=KLHm3cHQeQVSI4Hir7pgXLC810gdhwrkPgqHqWe08kb+d+KBavGXrqIWUignFR0gmE wl327zyHS69faFv9KA14wyTvH9LLiZwNSqOLAiSgvhT/64rY93TmA5GQYTiAJGtX6jk6 7hzlflKUqVjFwp/sXHZygwKezIkQ8Zpk8tN0pBctvwLaTd5yCn7fvV6Ox43lB5sLvov9 7GvTUzRW3oOc5YiOOEBkfaQQ4cL7BVKhAhAK84oudWYKISYK++g/3ttFfYq6sbKYfp3x 7FSnpPvGLsafSaBaSf2D7AlamB+afljCNNvm6gI3xtZXOoGPo/hW1h8lolJ7eGotI4QD JVmQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:content-transfer-encoding:mime-version:subject:date:references :to:in-reply-to:message-id: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=o1hMK1oOtHU51kJQ+l1S5TL6CWZUk4KhHr+hW5pofo0=; b=Ip29pUiPRKc49ZEqhP5f1LzC09DvAZ+OolbMDvDIM/xVuffAD2b+VO6TteeFn43P/W QosH/ZIPpELpJNkZ2KjJEy21GGJml7Rw1UlNGUtgPRNTPmVUW2OgZ9Jl1kbC5SRXkoh0 RaB6ePiDp/c5NdJigkQealGvE8a2X7S8TadO2H2RB3MG/xgzOQfLmz1yjl2LDewtl0R8 UqRlpS/UpvA4oo/MyKpD1OtOb1ebG560QJzGXhdATgzD4/NGrSkUXc7MsbCApIoUT9/C AZ1ptOU5H4LVV1c2S1rC/166iSQjH31j7kldYWXQI6Dx2T+joftpDlPkb5OBxAFvALhf 7ubw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:from:content-transfer-encoding :mime-version:subject:date:references:to:in-reply-to:message-id :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=o1hMK1oOtHU51kJQ+l1S5TL6CWZUk4KhHr+hW5pofo0=; b=QxnUACa+fNMXbyb9Ov+ksMHJ3s8tkc5XUt48fiSPR/wX3WinRBv4KEjnva6KOLJafc n3wgqlvrtLXpNIaEHyXgy2sI1keJ7ZyHolXiYMP3fpzusHd5L2qDU5vlizbgF5sFcoAx /xHbYnxOtyKuG+6uLGrAcIr+77pjzlax6WHLgjZp/1fpkEDRkoUiyTvUI+sAla8UK29d 7jK1TCsnwFI9evrzuf5clUHWZ8UblB5lo4b/dpd97vUdnqM4I4uOkcpnWGmUPeF7vehz LorOuQ9s0cwQ7greO+Z6UDLveS2ytC3w4EOHgS6+wddexgxcwXZIXQyQa3OUDAUMp5/2 Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AJIora8iBdAxIygqGcnuPxGrtARwrmpKIRNDVUhKaanKlgllUXzvBlaN P6mDtSC9yuMKVvEj2lU5NVc= X-Google-Smtp-Source: AGRyM1skAC/l6Yp6fWQjrdPexuvwd/GujRQSEExzt+fmbHk/uwzv9J8NwkNze7mf1c5SdGFFqO+qIQ== X-Received: by 2002:a05:6000:d1:b0:21d:ad67:c320 with SMTP id q17-20020a05600000d100b0021dad67c320mr11641152wrx.27.1657877385378; Fri, 15 Jul 2022 02:29:45 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:600c:3485:b0:3a2:e5bf:aeec with SMTP id a5-20020a05600c348500b003a2e5bfaeecls7318028wmq.0.canary-gmail; Fri, 15 Jul 2022 02:29:41 -0700 (PDT) X-Received: by 2002:a05:600c:3b1d:b0:3a2:60a1:fe30 with SMTP id m29-20020a05600c3b1d00b003a260a1fe30mr13406342wms.193.1657877381643; Fri, 15 Jul 2022 02:29:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657877381; cv=none; d=google.com; s=arc-20160816; b=i4CcPtn35HascAgxfvGz92JWWeE7tokjXt9lcT2X28gvcgqAP0LqcEY7bKR5Am5Pg1 jwb4jfFVCaAiW1v+L0H2SykdoSGBYGcatLimc6Pr0ZR3R34D0xdeohTggZ5rGplFmwoj b6VHcuBDEIYvTO/GS0tQtxhqQ0m303eiP8KQ4BiHEj4LKY2PUztT22Luqbgm46pqeIJq aHcdXLXmFEGpaY7DSvJ7LnDjjjgZUKaJnpOtDa9oJES9NheD2i374akMxoyEfpjgvsRk eirY5r9YvYt8KRj1VyQiV9VAJRM8MPkzx2doQtf1tJNVO/DYdqT/CiDKgOdNDOK9nUy+ Gevw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:in-reply-to:to:references:date:subject:mime-version :content-transfer-encoding:from:dkim-signature; bh=HS13N+0/zAOQ0PJAoEvKQypsNKhhJuSkV8QiCMl+hGI=; b=ClFPv16lgGPbTswm/3lhjlhhQtfCQWfvZ54ndaj5bGhK4E5OPL35vXMC3qkCrqFYnN wA7ZOimEslc2xX/E5AvI+dPz2T9ExokksZFapiQnEPoyrgiqzMhcS2I/Hlh59LIVQFBg V0u9CRjhfnT3NCXeIFTp6z3/eVc7VwKrSgAAwZQa50AGDrSdNnDQcsmcKZqIxU/8AlCE HQVXZEiu7bICs7A/5X8ZYbF1yePQCNO4yQ8e2msk+7Y+yJ7IeWxnkMR+TdUXXxtLso/4 g7WVShQSPop73FOYZ9bWUXscG3wYVf0gJuArGDJZgo8eSK46L6y17CPFwrVqHNeKr3VL YiGw== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Y3aQ+NOt; spf=pass (google.com: domain of fiddlosopher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::333 as permitted sender) smtp.mailfrom=fiddlosopher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Original-Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com. [2a00:1450:4864:20::333]) by gmr-mx.google.com with ESMTPS id p184-20020a1c29c1000000b0039c4d96e9efsi377820wmp.1.2022.07.15.02.29.41 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 15 Jul 2022 02:29:41 -0700 (PDT) Received-SPF: pass (google.com: domain of fiddlosopher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::333 as permitted sender) client-ip=2a00:1450:4864:20::333; Original-Received: by mail-wm1-x333.google.com with SMTP id r127-20020a1c4485000000b003a2fb7c1274so377650wma.1 for ; Fri, 15 Jul 2022 02:29:41 -0700 (PDT) X-Received: by 2002:a05:600c:19c8:b0:3a1:7399:861d with SMTP id u8-20020a05600c19c800b003a17399861dmr13219947wmq.170.1657877380859; Fri, 15 Jul 2022 02:29:40 -0700 (PDT) Original-Received: from smtpclient.apple ([2a01:e0a:40e:ff40:31bc:54b2:cb5b:ea79]) by smtp.gmail.com with ESMTPSA id u8-20020a5d4348000000b0021da4b6c6f7sm3485740wrr.40.2022.07.15.02.29.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Jul 2022 02:29:40 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3654.120.0.1.13) X-Original-Sender: fiddlosopher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Y3aQ+NOt; spf=pass (google.com: domain of fiddlosopher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::333 as permitted sender) smtp.mailfrom=fiddlosopher-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:30977 Archived-At: You can't add new AST elements. But instead of just using a string, you co= uld use a Span with attributes. That would be more convenient to match on = in a filter. > On Jul 14, 2022, at 5:17 AM, A A wrote: >=20 > 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 altoge= ther. Having an AST element would reduce the complexity of my code on the f= ilter 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 >=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 = 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 it should = not be difficult to translate): >=20 > ``` > function Str(s) > if string.match(s.text, '^gls:') then > -- code to handle the string > end > return s > end > ``` >=20 > Le Wednesday 13 July 2022 =C3=A0 11:05:33PM, A A a =C3=A9crit : > > Dear all, > >=20 > > 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. > >=20 > > I envision the markdown to look something like this: > >=20 > > mentioning a gls:term from the glossary. > >=20 > > or something like this: > >=20 > > mentioning a gls(term) from the glossary > >=20 > > So the syntax would be very similar to LaTeX, but a bit more lightweigh= t. > >=20 > > 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? > >=20 > > Thanks for your consideration. > >=20 > > Regards, > >=20 > > Amine > >=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 = 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. > >=20 > > References: > >=20 > > [1] mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > > [2] https://groups.google.com/d/msgid/pandoc-discuss/CAMwawgNgACJDXLyFA= cx26iy4-71yOUD%2BHccx67%2BRgJB132D0_A%40mail.gmail.com?utm_medium=3Demail&u= tm_source=3Dfooter >=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-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit https://groups.google.com/d/msgi= d/pandoc-discuss/Ys9IXXrcD4Nwmu6q%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-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit https://groups.google.com/d/msgi= d/pandoc-discuss/CAMwawgNLuqw-NM_RYCHurBdg0EH20sjeAiYGOepmbgQLW9MD_A%40mail= .gmail.com. --=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/6BC0E81E-3DB4-4DA1-AA2B-3FCE12F77E52%40gmail.com.