From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/30871 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Albert Krewinkel Newsgroups: gmane.text.pandoc Subject: Re: Converting filter to custom writer Date: Wed, 29 Jun 2022 19:22:22 +0200 Message-ID: <87edz7bc3h.fsf@zeitkraut.de> 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="21766"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBCZJF7XJTILRBB466KKQMGQECTXT3BY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Wed Jun 29 19:42:34 2022 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-wm1-f58.google.com ([209.85.128.58]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1o6bhy-0005SQ-Be for gtp-pandoc-discuss@m.gmane-mx.org; Wed, 29 Jun 2022 19:42:34 +0200 Original-Received: by mail-wm1-f58.google.com with SMTP id p22-20020a05600c359600b0039c7b23a1c7sf51802wmq.2 for ; Wed, 29 Jun 2022 10:42:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1656524554; cv=pass; d=google.com; s=arc-20160816; b=l0sSsSr1EscqBCbIBurBrhryUMY+rN7/tlT+UKRNiTsjmDUMCPVKQ/zRNXO4GMzROH IhivveST/dc0zznHr0vUfaBF/CjKeTr0yPxSdgy6fogUaQ9bg5RXOzJLBW0VYzGbfYvp O8g3WNAeIr496x0EmlBkt1+RjJN/ETi9hhtLcASI5/oImAlFgRE46EahU3Wo4uXsmPSh mwu4T2CRob4DfDVN9bHebMAQ74qMgyTUQKAyjG9mRS+eU0jHFq79e+ppAeVrJeA1hUap xeVw93A50sMkDSFs5WFnILmURlpeIScx/s5W1eRBdoo4FW6iN+HtUQdEJqgd75utMqyi KcwQ== 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:content-transfer-encoding :mime-version:message-id:in-reply-to:date:subject:to:from:references :sender:dkim-signature; bh=X4NSMcVBDREysKJ2uul00OUOZfnvQCRA0F1OWmh6oO8=; b=czlPwiy+gAvg5wG9UjQZPqKJbal9kpRiAcZ2AWl7kT2lM5rBz5Vv5CJwLpLS5P+332 zWTgokC7gVWbs+4YdWiU8CW9sapb1NVrdj5IBoZD4VyV8ioJmEFklrZNXzmxVXVnRTjO mllqCLGv10jywQoheIJpsJkK9EzUgZ6zM8TVzrvdMBxaj8/2b0kvRU6/spVC+2JHTeSF reBDEr34eMh5j1XibgRJD3776lkS7Z7CoxhVwf5CJglkkeACuowzh75p5yU/k9ZdPoJG IGL/ARLpBkzVUoilURb5SppORVYBrzvv4My1+24s0ZNWfW4r7TmpWM6syY1sMSX0yB40 RU9w== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org designates 80.241.56.172 as permitted sender) smtp.mailfrom=albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:references:from:to:subject:date:in-reply-to:message-id :mime-version:content-transfer-encoding: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=X4NSMcVBDREysKJ2uul00OUOZfnvQCRA0F1OWmh6oO8=; b=oTPfZa1TSssepAcLqbmwAGy4TuzDsro9hgN2qggzv/SGm1vW4IM3HAZLPEOlJiiVmP 8Xqy30uOCex+NbUTKCekbUbrhWjooTeiZh6nKM6Sqg+c1p1W5gSF8IbQrH1Y8NjUjbnP 2qf/8ZgcTg9rOnuazeDi/bPWjs+WZemt0xd7G8E5+pZCvBqr5dFTIKzLbnmIHBY/LGbN i+IN7zkV7mikmlKUu0Zm0s3HBL734TGdS3HZsCaUNba1NFKdALwpUmMEZ58d0vFOvjfi QtxJNGvgK5K135Z8ZsIec0gMkdeZFDzbpiRiU7R+zcqI5KM/SpB5bP2KxPeOjeAS3H03 26yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:references:from:to:subject:date :in-reply-to:message-id:mime-version:content-transfer-encoding :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=X4NSMcVBDREysKJ2uul00OUOZfnvQCRA0F1OWmh6oO8=; b=kI5z4krF2juHQuQ9KGV4nlrYJL6OHn8OIBxZMqq1Bj/jyNyzvxf/eDdYr43byCLgWp 7iseN9Y2yXlRddgUfhjl5a9T+8WHgJiH1MRljuwyKfkGQGloLIunOLV4GCnvmUuAJS6q LtVezw5p94UH8LqWEVzPr7lx0Iuhhb1lJgMR6gor5nSu1v7l7/X/97fheTZwpSsSwrNf AgLTMtpDKDFr2yeabY4k3rAA00G8a7m0jSbCpk/0aN+tqa2hay1L5LDD1nVTBQABMJ71 YWNxWSCXJsxKwqslkA1hkBVO2aUVj94YVlSwgtGEaxdsL46UqklOHvwIwVNWsOLLICKP Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AJIora+2iJ/tJpyuPI0oQCJU/JfdDrZPR8RqGcfQEcUfsTBpLYUkomYc Aqhf2PkkL1ATR5p0ZZ+RScA= X-Google-Smtp-Source: AGRyM1v4pZsLrunB56HlupZJFUj28NTTlBfsU+/vCma+v5rzasuycCQsE+YMOygyMQIY3KUjSWNh2w== X-Received: by 2002:adf:ef8f:0:b0:21a:3757:1b0f with SMTP id d15-20020adfef8f000000b0021a37571b0fmr4512444wro.404.1656524553803; Wed, 29 Jun 2022 10:42:33 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:600c:1da7:b0:3a0:3b20:d119 with SMTP id p39-20020a05600c1da700b003a03b20d119ls282632wms.1.canary-gmail; Wed, 29 Jun 2022 10:42:30 -0700 (PDT) X-Received: by 2002:a7b:cf2c:0:b0:3a0:525e:1b25 with SMTP id m12-20020a7bcf2c000000b003a0525e1b25mr7305642wmg.82.1656524549933; Wed, 29 Jun 2022 10:42:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656524549; cv=none; d=google.com; s=arc-20160816; b=XHbGnTKux/eSWZRVkYC4436PCPQ/tsNNSl8KzeWty7oiBqK+Zrm7XVLCr3vK9MURTS jJ1o/K2SSNMzOUma+w+swJceJqYW/lSbCrGrn37bO61ibOkdAUnREN28lwB3cU4+an+V 9TpVkvusqhYZdTkJJklcHFOA0Og7saOoWztY1EhF1Dt2Cr3A4WQG+VBlGTcw1S0FvMz8 rY9W9+ThseTgMZo0LLclaVpFGIE+xUXINk24kzDUUwFAHUrVvmywe52zSWzMIzS4uR89 NIQRg2y7Znw9bulcXhE07g/fpXpv+XBpPCleKiFmAemuaCLIdWDMJ/TS3Cx1W+EQfMO0 SzAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:in-reply-to:date :subject:to:from:references; bh=dKbkNd0GGMncIkv4TIPF/9NlyNj090oB0GpT0WDBGs0=; b=Um2zAd40zZGTrot2UufZlsbaPeGowTW+i1mFqH6/fowdLXhFcf2mJJn6YQ9ANn0/y5 /pm77Ea57kxIrSO9Ts9YztQyaYdr8TD0wdE/O/snVClyfMEfw+j8tZJU9Z3nIVSWMzTa Uhpt7dKy9N4LYpjlHNWiqLBHEajcmZLvx6n9BF8EyUo1mE6dQZXgzn1TrJhLFou9paPq TNPpO+lNWKOYIBrzPZUMNJMbBwXOg6ZGXPOFL5eZMjKePYhkH12sLCL2bXs+5Bz6swTY 7ivPaZg6BAF2nNFPjnuujeYefFJxwSadb0I7RT9Za1mu/uZCrMXQ0cY4VH6fB0cxoHzo jm0g== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org designates 80.241.56.172 as permitted sender) smtp.mailfrom=albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org Original-Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org. [80.241.56.172]) by gmr-mx.google.com with ESMTPS id a1-20020a05600c348100b003a0312d8760si324116wmq.2.2022.06.29.10.42.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 10:42:29 -0700 (PDT) Received-SPF: pass (google.com: domain of albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org designates 80.241.56.172 as permitted sender) client-ip=80.241.56.172; Original-Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4LY81H61SRz9sS2 for ; Wed, 29 Jun 2022 19:42:27 +0200 (CEST) In-reply-to: X-Rspamd-Queue-Id: 4LY81H61SRz9sS2 X-Original-Sender: albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org designates 80.241.56.172 as permitted sender) smtp.mailfrom=albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org 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:30871 Archived-At: BPJ writes: > I saw no answer to this one. Thanks for the reminder :) > Den fre 24 juni 2022 16:09BPJ <> skrev: > > I have a not-so-old "pseudo-writer" implemented as a filter which > mostly injects tons of raw markup into the document tree so that the > output of the plain writer looks like my target format, returning a > table of filters at the end like this > > [...] > > Am I right that I in principle could convert this into a new style > custom writer by removing the Meta filter, replacing `return > {}` above with `local filters =3D {}` and adding the > following at the bottom of the script? > > ``````lua > function Writer (doc, opts) > get_config(doc.meta) > for _,filter in ipairs(filters) do > doc =3D doc:walk(filter) > end > doc.blocks =3D blocks > return pandoc.write(doc, 'plain', opts) > `````` Yes, I believe that would work. I'm actually starting to use custom writers in a similar way. The only downside is that you can't use the default extension mechanism (like `plain-multiline_tables`) on the command line to tune the writer, but we're working on that. > (This got me thinking: what if `walk` accepted one more argument which > will be passed as an extra argument to the functions in the filters, > which could be used to pass config and/or maintain state? It somehow > feels more intuitive than defining a table outside the metadata handler > which all handlers close around.) Good idea. Although I have to admit that I'm not really enthusiastic about it due to many small, slightly annoying changes that implementing this feature would require in the Haskell code. > (BTW the main reason that the `note_filter` is separate is that it > needs to be topdown because it counts and collects the notes, while > `main_filter` needs to be bottomup because it sometimes relies on the > content of elements already having been processed. I was very happy > when I realized that this would work!) =F0=9F=98=8A --=20 Albert Krewinkel GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124 --=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/87edz7bc3h.fsf%40zeitkraut.de.