From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/30797 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Newsgroups: gmane.text.pandoc Subject: AW: Confused about filters, new style and classic style writers Date: Wed, 22 Jun 2022 15:40:07 +0000 Message-ID: <869e16a421e04fc18e8d5dcc5d0ff811@unibe.ch> References: Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="_000_869e16a421e04fc18e8d5dcc5d0ff811unibech_" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9542"; mail-complaints-to="usenet@ciao.gmane.io" To: Original-X-From: pandoc-discuss+bncBCZ27W53TUFBBWXPZSKQMGQESZOYPYY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Wed Jun 22 17:40:14 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 1o42Sj-0002NY-Fx for gtp-pandoc-discuss@m.gmane-mx.org; Wed, 22 Jun 2022 17:40:13 +0200 Original-Received: by mail-wm1-f60.google.com with SMTP id i5-20020a1c3b05000000b003a02b027e53sf5094wma.7 for ; Wed, 22 Jun 2022 08:40:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1655912413; cv=pass; d=google.com; s=arc-20160816; b=CHLlhGDRFcWRxp2goefFp1IchYYhihJRaiw5kMyU6MG07VVmrZ73VtJqIBDke0ZFBC Eh0SyNX8NER2Nwq+hc3uswDNUeJQlAuUptq4M8TYEBQQzBRJlwpS2UY8ha7kQyYYVWXu 1sLgRsSLXAyVWTYPRispSjHmtNxbChWYUKfbiC55XPbhm5+HPo2GccgypAFHTRYNL1z5 Uh7kfwvKHpJlgTaDlFiSxbIhaYZwZwRM91WyIBnHiQbnpHcFks51a9LHFGqTJOYbVQCC BGbWhgqavPv1YWdGesBi77e8bAwe/TyZjdVWM7WzyVlyCdhxo1zYfJSMktBE/hKfPDtd WOVw== 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:mime-version :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:to:from:sender :dkim-signature; bh=E+MG/wLN2uqBm1/r6aRSRm7Zg4Mm51yc9deDouNEkoY=; b=W939lDCHywUPJRHdZ1djwhZZJ5YUPaSSRG7F/DNb2roOm1S7rwi4Hvg3I3Ix9mMJcC AKwTO795SOzyUpwW77rFdcv5oK8jHBkzEpQ9pqulu78d2QNyJC7hzV+28Ml5D6jpQtyA VPZvs7GRh17aIkigJP5BVi3vQ7xSBxNazGvsT/48IZTuMC2B/n8Iu7l1tg1TcGF7x2o7 bx/g7eUCH5wF+c1Hg384ZFemkEV34Iq8K65fa06zR/zQay2AackTU3FVZctQXhELLSuF ZiDy3/ro7/7KrnZAHd3CTZgAK7W6HhFVvi2pWXOGt2c2WPsqmMPF4ip9WoZ2t4c9Sbgt SQCw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of denis.maier-NSENcxR/0n0@public.gmane.org designates 130.92.0.83 as permitted sender) smtp.mailfrom=denis.maier-NSENcxR/0n0@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=unibe.ch DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:from:to:subject:thread-topic:thread-index:date:message-id :references:in-reply-to:accept-language:content-language :mime-version: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=E+MG/wLN2uqBm1/r6aRSRm7Zg4Mm51yc9deDouNEkoY=; b=bf2LsKeuUnYfq/I1/mCoqOK+xPsGV3UKvlI18nSB4BoWgdfOJ87SO1XIrmMI0NVoad aPnuIggsIKixFByrvvQtRBV8mlVCx3i2kWDvRzOFAzUdixXHNQtKFDTbMScz1MshNnmL cXc+25o5mEZ+zIFn+VhHQ11E0heEUwBwpRBU4ztq+ZYizaE2uq8/EcL9rFsMInfNca43 t4NHXkFN7/VzLdAUKCoDyQ3tGHY2c0yFsONUs8gaALu2ortbROQtkOhgn4k1jPTNrK7e lXQRoO8sXylvgpIat0KssojG0u60N67n4ynbBQjSTqtFLJDwEypEG3FNA6gso+oQMNOc SHEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:from:to:subject:thread-topic:thread-index :date:message-id:references:in-reply-to:accept-language :content-language:mime-version: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=E+MG/wLN2uqBm1/r6aRSRm7Zg4Mm51yc9deDouNEkoY=; b=186i/kz8R3AZB1Hig0RP9jBc7pNJ5Zn9WfBExZtH4nnZKGB+Ek16jQefFnE6CTPcUu edOT3qM2NHW0NQxDWoKNXpmJWhvz1xhqFvgzwHaBG7B5l6PMa0noZumPMcPvTSC+zKTE gDeVkN+VGmg50sJiDLSWMyzGQWHphMBR7cfU9IuUecQ1bUFtH4QflsCHH+jgb8EmH2Ac bZ1uIZI3GYFxxcuVgjpL1m/ptXzvAsOyeqZDjb4eglZa2z0n+jTTPWsWO0xV0nXNQf2o kKhLNV2xLnK5tsxnm/t95cjNzKX+De7 Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AJIora9IHKhjVdsbtcpV3glrB93eYVJeOGms+gs9/lvCP9UC4+xQa4m/ Lz2Zus7Xsil6aUiLIALYyPE= X-Google-Smtp-Source: AGRyM1s6ym6Ytr2RT+yETjFTVsJZDvm8AzePN7VZoSgM+Dv7ktkal/4xKP/XaSGmfGk0DQQCU+BmPw== X-Received: by 2002:a05:6000:102:b0:21b:9219:b28e with SMTP id o2-20020a056000010200b0021b9219b28emr3965623wrx.236.1655912413027; Wed, 22 Jun 2022 08:40:13 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6000:1887:b0:218:5c3b:1a23 with SMTP id a7-20020a056000188700b002185c3b1a23ls643786wri.0.gmail; Wed, 22 Jun 2022 08:40:09 -0700 (PDT) X-Received: by 2002:a05:6000:1acf:b0:218:5a30:9067 with SMTP id i15-20020a0560001acf00b002185a309067mr3974574wry.48.1655912409328; Wed, 22 Jun 2022 08:40:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655912409; cv=none; d=google.com; s=arc-20160816; b=h+9gmyHgYRuIJkHb+m5WCgatWExdtksVTZRFritWmwrFXkt09hj0+GS0cPQqWzA+14 Id9fzKIoE8tpbfGDtqgDvKQ0MsnpOl9gGBrE5WxMy1xLFff2ow3WU6HuLPvgzijd02Bg jBVtVjZmav+Sd06B2EvuYapXOtvveF+G7qVQ+OXkUiE5Tf/vEqhY3Q8xANjiMjcq3oeo wgfi5yZEWioltuymo1Ix/2Tb7HI3UwpqS9pS4XQYanR7/MSlgjHq2KFJo9fGR7tzEqaf nBQ5B1fbx4HT1CipPp1xxxqmkMkgyrhuw8zNVBUIDapXpivVR7Eldo3puyQgJcIe3z63 6wtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:content-language:accept-language:in-reply-to :references:message-id:date:thread-index:thread-topic:subject:to :from; bh=ITwA4Pb6ur4LLf1LcPUFiA9pBEt1Xv4TS+jVULUY1og=; b=omw5euQTlEE3tXopt/PS0s9D+e/M5Y7Oj8K7Gsjs7JHN9HIlht+JS6lpQZQKLqJPOD te+TJ7sW6FSj3aiQ8loqnSaqfB2mtYTvPUEtlvr8GuBIZBlA6MIorYvclk7Gl3Sn9ERB Tps6Lhv87CVORGq1juJy0SzqKkUdnN9QHS0SqEIEZlIJYcqfp3tNQ0v/yxMNFflQ3UHG qs8Awp+6V+HQf8UyR+L1ECpY4Qtbad+9o/N0p6Ir7PkgFAHzJlkiDNXjDUIOtGdS1VzN tzXgEs8oIMISdvZJG0T/j+U7fiobVVcQ96/lrz4PkT5BGB/tMYh/uTc2vkbjlUS16gUH rb1w== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of denis.maier-NSENcxR/0n0@public.gmane.org designates 130.92.0.83 as permitted sender) smtp.mailfrom=denis.maier-NSENcxR/0n0@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=unibe.ch Original-Received: from mailhub-lb2.unibe.ch (mailhub-lb2.unibe.ch. [130.92.0.83]) by gmr-mx.google.com with ESMTPS id v13-20020a5d6b0d000000b0021a3b824fabsi612092wrw.1.2022.06.22.08.40.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jun 2022 08:40:09 -0700 (PDT) Received-SPF: pass (google.com: domain of denis.maier-NSENcxR/0n0@public.gmane.org designates 130.92.0.83 as permitted sender) client-ip=130.92.0.83; X-Virus-Scanned: By University of Bern - MGW Original-Received: from mail.campus.unibe.ch (aai-edge-02.campus.unibe.ch [130.92.13.148]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mailhub-lb2.unibe.ch (Postfix) with ESMTPS id EE083500088 for ; Wed, 22 Jun 2022 17:40:07 +0200 (CEST) Original-Received: from aai-mail-03.campus.unibe.ch (130.92.13.41) by AAI-EDGE-02.campus.unibe.ch (130.92.13.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P256) id 15.1.2507.9; Wed, 22 Jun 2022 17:39:59 +0200 Original-Received: from aai-mail-03.campus.unibe.ch (130.92.13.41) by aai-mail-03.campus.unibe.ch (130.92.13.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P256) id 15.1.2507.9; Wed, 22 Jun 2022 17:40:07 +0200 Original-Received: from aai-mail-03.campus.unibe.ch ([172.18.73.17]) by aai-mail-03.campus.unibe.ch ([172.18.73.17]) with mapi id 15.01.2507.009; Wed, 22 Jun 2022 17:40:07 +0200 Thread-Topic: Confused about filters, new style and classic style writers Thread-Index: AQHYgjzDtq0GF/soW0qCTlPG0qNCv61bmBjQ In-Reply-To: Accept-Language: de-CH, en-US Content-Language: de-DE x-originating-ip: [130.92.13.161] X-Original-Sender: denis.maier-NSENcxR/0n0@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of denis.maier-NSENcxR/0n0@public.gmane.org designates 130.92.0.83 as permitted sender) smtp.mailfrom=denis.maier-NSENcxR/0n0@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=unibe.ch 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:30797 Archived-At: --_000_869e16a421e04fc18e8d5dcc5d0ff811unibech_ Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Have a look at this example : https://gist.github.com/tarleb/5a9c3fbfa47b0e= 6d3643efd8af2994b9 Maybe that helps? Von: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Im A= uftrag von A A Gesendet: Freitag, 17. Juni 2022 13:24 An: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Betreff: Confused about filters, new style and classic style writers 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, a= nd adding the code inside these functions. The only notable difference I ca= n think of is that classic style writers return raw output (i.e. strings) f= rom these functions, whereas filters typically return some other pandoc obj= ect, 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.P= andoc 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 gen= erate 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 pr= ovided 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 sty= le? Why are we defining filters inside these new style writers? Couldn=E2= =80=99t we just make a simple filter instead? 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, 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/CAMwawgMV52MstXs800EgkT_K99tzRn0GaOsjauT2HkZrEckN5A%40mail.g= mail.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/869e16a421e04fc18e8d5dcc5d0ff811%40unibe.ch. --_000_869e16a421e04fc18e8d5dcc5d0ff811unibech_ Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Have a look at this example : https://gist.github.com/tarleb/5a9c3fbfa47b0e6d3643efd8af2994b9

 

Maybe tha= t helps?

&nbs= p;

Von: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im Auftrag von A A
Gesendet: Freitag, 17. Juni 2022 13:24
An: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Betreff: Confused about filters, new style and classic style writers=

 

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 filters and c= lassic style writers are pretty much identical, basically defining Lua func= tions corresponding to node names, and adding the code inside these functio= ns. 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 examp= le I have been able to find of these writers is the one in the main documen= tation, and it is super confusing:

function Writer (doc, opts)<=
/code>=
  local filter =3D {
    CodeBlock =3D fu=
nction (cb)<=
/o:p>
      -- o=
nly modify if code block has no attributes
      if c=
b.attr =3D=3D pandoc.Attr() then
      =
;  local delimited =3D '```\n' .. cb.text .. '\n```'
      =
;  return pandoc.RawBlock('markdown', delimited)
      end<=
/span>=
    end
  }
  return pandoc.write(doc:walk=
(filter), 'gfm', opts)
end

Here we have a global function called <= code>Writer w= hich takes in doc, a pandoc.Pandoc<= /code> and then proceeds to defining a filter which it then applies to this document using the walk me= thod. It then uses the gfm wri= ter to actually generate the raw output. So basically, a writer within a wr= iter.

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 m= ore useful to rewrite the example provided for classic style writers in the= new style , in my opinion.

Are there any more down-to-earth exampl= es 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 inst= ead?

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 pandoc-d= iscuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAMwawgMV52MstXs800EgkT_K9= 9tzRn0GaOsjauT2HkZrEckN5A%40mail.gmail.com.

--
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/869e16a421e04fc18e8d5dcc5d0ff811%40unibe.ch.
--_000_869e16a421e04fc18e8d5dcc5d0ff811unibech_--