From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/30752 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: A A Newsgroups: gmane.text.pandoc Subject: Confused about filters, new style and classic style writers Date: Fri, 17 Jun 2022 13:23:52 +0200 Message-ID: Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000e7da8e05e1a2fd8b" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1313"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBDJ77HUDRUCBBVGIWGKQMGQEDPMVAEQ-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Fri Jun 17 13:24:09 2022 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-il1-f185.google.com ([209.85.166.185]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1o2A5A-000069-7d for gtp-pandoc-discuss@m.gmane-mx.org; Fri, 17 Jun 2022 13:24:08 +0200 Original-Received: by mail-il1-f185.google.com with SMTP id a3-20020a924443000000b002d1bc79da14sf2484810ilm.15 for ; Fri, 17 Jun 2022 04:24:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1655465047; cv=pass; d=google.com; s=arc-20160816; b=vjmDsK+OQ/j8rEdzIbPY12HDHncXMCVFOUhx1cItTFtRA6GMnPHQENOvuyAKp8Fwiu ZidYQYrZkqNtdcIilM1r+EQcl/QlywLWxjsbxGlJKM7kuF04Rzgq/MMG8G9eCHlFsuzQ LosZD0Sn4V4chg6iEwBMNeLFThOU2Xz+y/ukGVkfQyBvkUipSO6FgmVx7NPciyjEqJe1 OFO9vcV6TNagkyo848nGzDkbVHX/kOKOYn1D49u1Fxdgk5B3tDZP8wOV1x1gVgxaVX5E 1pvAOedJ3ltr+zsiUBUXHnxxu8ZzNSM9ihvZjPk6nS+s30Rv6g1sf0pWItsdWJ0rqQr2 NFEw== 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:mime-version:sender:dkim-signature:dkim-signature; bh=zykXrMDJR4mf8LO5ulg+qpYD2wvNvakHArJJJKtLV0M=; b=VwPtS7+GDdvfmJloh0Uag4TGhxrQ4+REdW75m+G/ZwrkxX5AXtN+2uez3IK6vVCjt2 4tGXhsUBHMwJqgsvIkGk8ZpcGtFxvC6SaXw6zgs3dM0CLJKuuIPU2NmNgwe+HQYemrbf uyNHUH8UoRGXr1rd3vni9O2qXn/Mr8ICRfYDPgnMx3ekZuloZjx8hVrdJjIqRkV5Rz4J hz2sAwtjnV0hbmuOAXK6B4Kc+gV+BjJqQJK8ngKsnPo54SA76Mooohgpwk3b0JxXGqlp 5fpvYvxTAm+WO6fsAjvaAG2ObC/kAIdnFQ41PE3J6+Zbm8v3M5od8bqFtdV2x1b8Cj1p Bq6g== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=XG8inFTV; spf=pass (google.com: domain of amine.aboufirass-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::136 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: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=zykXrMDJR4mf8LO5ulg+qpYD2wvNvakHArJJJKtLV0M=; b=lZnyvwdQzUE8lvejlVomQC74vClXMFpyP5+azaqwpFvBcI5XD0zlSBrHV7/7S9Ugj6 YTQH2/zRUgbxsxcMlTXL1jUebKUJkWHPnhcBzLNcq2VGBTr66zR3NZKom/RwfX2C3cly dL+E0dBAMgVYBXmCjqSUR3/Q6fxXdy9Dq5sxhi+4+EJW2/h1V3seUkyajnXF8CRrbAFs LsRnPz2+OwCxCFtBZLyOnnS3/7Jwn6yGa3I1JdgNe59cpeGLEA7zSeNAEt+nIzE82L9s 0T1VE2dq1vIa22cgesRwgFbUO9UXveKCP8Dl8pfOXlXzf8qMi1ZDmC77uERo2Exe06sp nTpA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version: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=zykXrMDJR4mf8LO5ulg+qpYD2wvNvakHArJJJKtLV0M=; b=J5QWLA2GZvA85W6rDaT2+rsUs4V/Tv12AmWB9oLh2XpXKN5J8aFEfDdYIs8U/cYwUg +1MvdF9dlVKJRtPyrgqc20KZekjHf5qEvXsA/GxMipDpQ922fmFWfAeeMayUtRuTsK5S cWmvspdrzlWbZ3Mn2GywXD4FJcJX8wC2J7GQb0dou3DLOLm27WTjHMt0+095icFNO+uJ 8VBu/pFiUaQXyaclr4obIKOyzX4vAOzt8DpWBlkC6s3hT+X+oUHhAuDwBt66DTJc6w9i +qvcbgKIqI9VhAPqR54CaK33zH3gzeOa3wqzzTPoIYx0+nBNeGrxP6vrEya6vD61H1An 5Bwg== 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: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=zykXrMDJR4mf8LO5ulg+qpYD2wvNvakHArJJJKtLV0M=; b=3wa8cYWOJJbJ3I6g8icmnR6x28vofn8nQtrS7W+zAsM2dtEoIc2JDa002Rp/0JYABH jevQQw766/Gz4E/Vp9QN553wicym8mJaNRYb3ioDv5dOdoMGtX5Jd8+apLqWHpbtR9QC jZoyvcidr4DAXnQHfmyE6rfLLJYITnIh/r//crzbY5X25GIzdqiJymPE10Z2cW0vKnDR TAlJj7AD2aPk8qvSlibpoRQ4+xiCxm0pSzwSMPOjEqQMIyMbMzOcUAod/dH1cDJfl0QY zf0AFC4x2uAhe5xx3ASTMo+uePeQEhdVDF9wWrsuLL+JEoGnorl9f9FsrV65pQrK8CEx fv2w== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AJIora/wXi7bpkdnGhwPaK3aG4QeKoenRmDIU8zKa0aPL53P7PM1UucL idBZNaVA4kqR04GUabvgw+o= X-Google-Smtp-Source: AGRyM1vAFmPNtyAh2/JmsMPfTcSlYHJHIuSip3Kmp3ltHn90i3tSz3Xyy6cf980wVBPjFHHYViJeAw== X-Received: by 2002:a05:6e02:15c5:b0:2d7:a1cf:6f87 with SMTP id q5-20020a056e0215c500b002d7a1cf6f87mr5272865ilu.30.1655465047132; Fri, 17 Jun 2022 04:24:07 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6e02:8f0:b0:2d4:f46:5e89 with SMTP id n16-20020a056e0208f000b002d40f465e89ls770422ilt.0.gmail; Fri, 17 Jun 2022 04:24:04 -0700 (PDT) X-Received: by 2002:a05:6e02:180f:b0:2d1:3d44:8fcd with SMTP id a15-20020a056e02180f00b002d13d448fcdmr5583946ilv.0.1655465044587; Fri, 17 Jun 2022 04:24:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655465044; cv=none; d=google.com; s=arc-20160816; b=nr0klOet75jAOk2wCnlTXDRtXG1nbgFgpFYK2YrK9VioixgaUo74sSEUO1oTVNQPOT wdK9WBfdPYoX+10MFUlayicWRV6o95/fK8ieTUROH1PVNTm0rSPoTPNu7/l+VxkjELjE suqfUdqhsq8/qXqDmoKagEwKBzL0Yj9MIxZeNmG4YWKK1xXs/3xLuvxcGER+nhmER2tD aUlq27d61Z/1JDCugCOf7Yzfc+7vYjiJdvalpxrQSe2gvl4QuZ3xVXUqggQRUtoqtvjl yeS9lwnThczHXjWaEJhZZGv5uJHII57KeUm9DAQgmosQGIeOTCrRWy38QlFWjEz6M9Nl A6ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:mime-version:dkim-signature; bh=vuOMM4LVrP3D0l30ASUUL61ffcTg7Bd7GbmsOdLCE4I=; b=FLoGjruCt1rjTcyukR0SC78K6J9DUThuPlHGWcCOOfioxl3bKAu0zCylOyCScoOPPs 22x2XZkLeIwEg0cTyg3McZ2u+m+QHENQppnzZxm7n32QoBLoha/nRSMpGI6i9xwz31Fj yIKJKNPvkbm85ISdJq3jMty1chAVKVyBX5kDHVIQvPlySzBgW61CDMhUAjVf40wnPBxJ SXe7M/eVfAippmO0ix7iR5dOe7e+ej3w6rtLvRvHxd5lAeHjbvFl/uSrIuGNrzdxiJGt 9FBytW70I0+Db2RwLiwbsLRDT/9l24jAPBBZrgkbw7VhXqg/jmaiUXwFxwPSt25QI/mg hBLQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=XG8inFTV; spf=pass (google.com: domain of amine.aboufirass-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::136 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-il1-x136.google.com (mail-il1-x136.google.com. [2607:f8b0:4864:20::136]) by gmr-mx.google.com with ESMTPS id r21-20020a056638131500b00332299ce855si338969jad.5.2022.06.17.04.24.04 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 17 Jun 2022 04:24:04 -0700 (PDT) Received-SPF: pass (google.com: domain of amine.aboufirass-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::136 as permitted sender) client-ip=2607:f8b0:4864:20::136; Original-Received: by mail-il1-x136.google.com with SMTP id h5so644918ili.3 for ; Fri, 17 Jun 2022 04:24:04 -0700 (PDT) X-Received: by 2002:a05:6e02:792:b0:2d7:ae5d:e2fd with SMTP id q18-20020a056e02079200b002d7ae5de2fdmr5373665ils.315.1655465044333; Fri, 17 Jun 2022 04:24:04 -0700 (PDT) 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=XG8inFTV; spf=pass (google.com: domain of amine.aboufirass-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::136 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:30752 Archived-At: --000000000000e7da8e05e1a2fd8b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi all, There=E2=80=99s something which I don=E2=80=99t quite understand in with re= spect to the following: - lua writers - classic style - new style - lua filters As far as I can tell, lua filters and classic style writers are pretty much identical, basically defining Lua functions corresponding to node names, and adding the code inside these functions. The only notable difference I can think of is that classic style writers return raw output (i.e. strings) from these functions, whereas filters typically return some other pandoc object, or node in the AST, effectively modifying it during runtime. Enter new style writers. The *only* example I have been able to find of these writers is the one in the main documentation, and it is super confusing: function Writer (doc, opts) local filter =3D { CodeBlock =3D function (cb) -- only modify if code block has no attributes if cb.attr =3D=3D pandoc.Attr() then local delimited =3D '```\n' .. cb.text .. '\n```' return pandoc.RawBlock('markdown', delimited) end end } return pandoc.write(doc:walk(filter), 'gfm', opts) end Here we have a global function called Writer which takes in doc, a pandoc.Pandoc and then proceeds to defining a *filter* which it then applies to this document using the walk method. It then uses the gfm writer to actually generate the raw output. So basically, a writer within a writer= . I=E2=80=99m not sure if this is just a bad example, or whether I=E2=80=99m = missing something. It would have been more useful to rewrite the example provided for classic style writers in the new style , in my opinion. Are there any more down-to-earth examples for making writers in the new style? Why are we defining filters inside these new style writers? Couldn= =E2=80=99t we just make a simple filter instead? Regards, Amine --=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/CAMwawgMV52MstXs800EgkT_K99tzRn0GaOsjauT2HkZrEckN5A%40mail.g= mail.com. --000000000000e7da8e05e1a2fd8b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Hi all,

There=E2=80=99s something which= I don=E2=80=99t quite understand in with respect to the following:

  • lua writers
    • classic style
    • new style
  • lua filters

As far as I can tell, lua filte= rs and classic style writers are pretty much identical, basically defining = Lua functions corresponding to node names, and adding the code inside these= functions. The only notable difference I can think of is that classic styl= e writers return raw output (i.e. strings) from these functions, whereas fi= lters typically return some other pandoc object, or node in the AST, effect= ively modifying it during runtime.

Enter new style writers. The only example I have been able to find of these writers is the one in= the main documentation, and it is super confusing:

function Writer (doc, opt=
s)
  local filter =3D {
    CodeBlock =3D function (cb)
      -- only modify if code block has no attributes
      if cb.attr =3D=3D pandoc.Attr() then
        local delimited =3D '```\n' .. cb.text .. '\n```'
        return pandoc.RawBlock('markdown', delimited)
      end
    end
  }
  return pandoc.write(doc:walk(filter), 'gfm', opts)
end

Here we have a glo= bal function called Writer which takes in doc, a pandoc.Pandoc and then procee= ds to defining a filter which it then applies to this document usi= ng the walk method. It then uses the gfm writer to actually generate the raw output. So basically, a = writer within a writer.

I=E2=80=99m not sure if this is= just a bad example, or whether I=E2=80=99m missing something. It would hav= e been more useful to rewrite the example provided for classic style writer= s in the new style , in my opinion.

Are there any more down-to-eart= h examples for making writers in the new style? Why are we defining filters= inside these new style writers? Couldn=E2=80=99t we just make a simple fil= ter instead?

Regards,

Amine

--
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/CAMwawgMV52MstXs800EgkT_K99tzRn0GaOsjauT2= HkZrEckN5A%40mail.gmail.com.
--000000000000e7da8e05e1a2fd8b--