From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/16623 Path: news.gmane.org!.POSTED!not-for-mail From: Kolen Cheung Newsgroups: gmane.text.pandoc Subject: Re: Filter with arguments Date: Fri, 6 Jan 2017 15:10:02 -0800 (PST) Message-ID: <1239e0f1-2538-4781-8a75-90c59f86aabc@googlegroups.com> References: <20170106114647.GG791@Administrateurs-iMac-3.local> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_1380_100952215.1483744202223" X-Trace: blaine.gmane.org 1483744212 12679 195.159.176.226 (6 Jan 2017 23:10:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 6 Jan 2017 23:10:12 +0000 (UTC) To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCS252WXTEIBBSWHYDBQKGQEZCYVWCY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Sat Jan 07 00:10:06 2017 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane.org Original-Received: from mail-pg0-f63.google.com ([74.125.83.63]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cPde3-0001s9-81 for gtp-pandoc-discuss@m.gmane.org; Sat, 07 Jan 2017 00:09:59 +0100 Original-Received: by mail-pg0-f63.google.com with SMTP id l5sf165610457pgh.1 for ; Fri, 06 Jan 2017 15:10:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:date:from:to:message-id:in-reply-to:references:subject :mime-version:x-original-sender:reply-to:precedence:mailing-list :list-id:x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=Kae9BSDT9mnJ/08vBv/wol1fV7gcWUH3lntAJL3PvY8=; b=tGPYIoYQT/ecK0jgQyOEcNIy0ojVWEC8vJ3HBmrxO3h+ejwps2VdQRltdVVaL2PLxy tlSbSeU+B+1Jh3ZO+l0Kx/WNjJnHlZtwgVQyblOESGoOr26IU/i7SVbrfIn9OV+Iled2 eLLR/Tgo+HFo87iO7MRYWuKaw49P2WZR2nn19JlhbJR/BdEc7c703E5nBoqUbFf6lWt1 VVAQDpwKciRS85OdpCfkvzEz4cPmT7hXBwYdnZo6DQQFsosC3kaagJaSSszVxBitlchS HXSa3A9phUa6V22qFHl2yk265fUxdUmrQHFU3m188NPO1drRwfEMPla4UlN+V3ZOKiti Bxnw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:message-id:in-reply-to:references:subject:mime-version :x-original-sender:reply-to:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=Kae9BSDT9mnJ/08vBv/wol1fV7gcWUH3lntAJL3PvY8=; b=tF+LFn2Ze38UWyVkbCARqCO9IYC8LED5YYyK/r+w8BHLt8R5hG/bxe7360L48ldWmM SBNGQ6BQAUt1veqPosRVbmVdU1NS5HmiKHNRlGNG+h8qzgZedDuikhMUeI/pllB56bI7 BY0t5pZjIxWz7URUMaVTgno5PnQgRga2Ym4np/G3VYqY9Hmajmo+MAEE0GVk/Ub9nbra Bimu5Wq1Gqko0u+SG1agftHRJEQDFoLPNynDipUAsIpJNtFMxGpfYWKy1o2vbYueBecH wJ+JptN3NDTK6v3xpJWvkzbxP8VAKWVd07sAbaFjrY5DgV0O3pCiWGirER0B4uCmhTBW 0boQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:date:from:to:message-id:in-reply-to :references:subject:mime-version:x-original-sender:reply-to :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=Kae9BSDT9mnJ/08vBv/wol1fV7gcWUH3lntAJL3PvY8=; b=cfAH8eg/h4CQ8+8v+8zUUAbr5U9Cpj4DEzqYuZsQo65nhr8h4qgJjQkyTFw/pAxndO MFcFtn9CeACLp50j2Z9jPhAuY04+PAKFbA2zewT67Xw09U1fTVwIWJtf3NVbq7JpEZCq Za+FgFVzvnKvHdUa43lKu4ymQlq7lTxLUC6HAp9ua59T8KdDiCGmJsKW2hC10y4z1bCc PDDXyVvBXf0szuixrP3TfauyPCQvNfAO9/4ZpFYi+LqA8NKuv/ho3qpNbsxFv4aur3ID 8sLIXguG5Y1ZWd3421VvSH1C2D+aQpPs4ysKVp6DtR04p2vb6sYcbs/qhZ7SGJv9dnFi Arlg== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AIkVDXKhNT9kj0sVY78SfCUpVnO3x5T2HLBJ2keD77VzB+3DQOIsXARkA83YjY9vtYqkYA== X-Received: by 10.157.20.197 with SMTP id r5mr401926otr.9.1483744203126; Fri, 06 Jan 2017 15:10:03 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 10.157.29.137 with SMTP id y9ls2096893otd.39.gmail; Fri, 06 Jan 2017 15:10:02 -0800 (PST) X-Received: by 10.157.40.132 with SMTP id s4mr405644ota.7.1483744202694; Fri, 06 Jan 2017 15:10:02 -0800 (PST) In-Reply-To: <20170106114647.GG791-BKjuZOBx5Kn2N3qrpRCZGbhGAdq7xJNKhPhL2mjWHbk@public.gmane.org> X-Original-Sender: christian.kolen-Re5JQEeQqe8AvxtiuMwx3w@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.org gmane.text.pandoc:16623 Archived-At: ------=_Part_1380_100952215.1483744202223 Content-Type: multipart/alternative; boundary="----=_Part_1381_708360418.1483744202223" ------=_Part_1381_708360418.1483744202223 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Oops! Sorry again to have a duplicated post=E2=80=A6 a post on the same top= ic is in pandoc-discuss/support=20 arguments on filters=20 . To compensate, let me wrote a combined summary of both posts (please expand= =20 or correct if incomplete/incorrect): <#>Current method=20 =20 1. pipe it through - Cons:=20 - the filter would not know the output format without duplication - related question: how to pass output format when using pandoc= =20 -t json | filter1 ... | ...? e.g. I often see filters checking= =20 the output format from the json rather than the 1st arg.=20 - ugly, =E2=80=9Cunnecessary=E2=80=9D pipe=20 - Questions: how about Windows users? Does it work the same way?=20 2. Metadata, either through YAML or -M command line option - Cons: - treated as Markdown=20 - metadata key collision (e.g. hierarchy of metadata key is=20 needed, which make it uglier)=20 3. panzer=20 - Cons: - extra dependency=20 - written in Python (for filter not written in Python it is not=20 desirable)=20 - it has its own rules (which some *might* not like)=20 4. environmental variables - Cons: suffer the same deficiency of -M option in (2)=20 - Questions: how about Windows users? Does it work the same way?=20 (@bpj has mentioned it is a pain to do so.)=20 =20 Comments: As as filter writer, one would want their filter as easy to use as=20 possible, and as few extra dependencies as possible. These criteria=20 eliminates (1, 4) for easiness and (3) for dependencies. This leaves (2) as= =20 the only viable solution, which still has some cons needed to be dealt=20 with. I personally don=E2=80=99t worry too much about things treated as Mar= kdown,=20 but metadata key collision is unavoidable if one want short, easy to=20 remember keys (e.g. pantable -s -t csv, anyone used to pandoc will almost= =20 be able to remember this.). In addition, the above discussion hasn=E2=80=99t covered the case that one = might=20 want to write a program that can acts as both a filter and a standalone=20 cli. e.g. I am thinking about using -s to indicate it is a standalone cli= =20 (and without it, a pandoc filter). Using -M means the options is parsed=20 differently (and duplicated) in these 2 cases. <#>Suggested method=20 =20 1. -O key=3Dvalue/--filter-option=3DKEY:VAL/--filter-args/--filter-argum= ents - Cons - what if there=E2=80=99s multiple filters? special ordering is ne= eded.=20 2. -F "filter --split --on --hyphens"/-F filter --split --on --space - Cons: - pandoc is already passing the output format as the 1st arg=20 - potentially break existing ill-named filters=20 =20 Comments: Just for the sake of letting the -F option be backward compatible, (1)=20 might be better. But either way it will be fine with me. =E2=80=8B --=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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/= pandoc-discuss/1239e0f1-2538-4781-8a75-90c59f86aabc%40googlegroups.com. For more options, visit https://groups.google.com/d/optout. ------=_Part_1381_708360418.1483744202223 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

= Oops! Sorry again to have a duplicated post=E2=80=A6 a post on the same top= ic is in pandoc-discuss/support arguments on filters.

To compensate, let me wrote = a combined summary of both posts (please expand or correct if incomplete/in= correct):

C= urrent method

  1. pipe it through
    • Cons:
      • the filter would not know the output forma= t without duplication
        • related question: how to pass output forma= t when using pandoc -t json | filter1 ... | ...? e.g. I= often see filters checking the output format from the json rather than the= 1st arg.
      • ugly, =E2=80=9Cunnecessary=E2=80=9D pipe
    • Questions: how about Windows users? Does i= t work the same way?
  2. Metadata, either through YAML or
  3. Cons:
    • treated as Markdown
    • metadata key collision (e.g. hierarchy of = metadata key is needed, which make it uglier)
  4. panzer
    • Cons:
      • extra dependency
      • written in Python (for filter not written = in Python it is not desirable)
      • it has its own rules (which some might= not like)
  5. environmental variables
    • Cons: suffer the same deficiency of -M option in (2)
    • Questions: how about Windows users? Does i= t work the same way? (@bpj has mentioned it is a pain to do so.)

Comments:

As as filter writer, one wou= ld want their filter as easy to use as possible, and as few extra dependenc= ies as possible. These criteria eliminates (1, 4) for easiness and (3) for = dependencies. This leaves (2) as the only viable solution, which still has = some cons needed to be dealt with. I personally don=E2=80=99t worry too muc= h about things treated as Markdown, but metadata key collision is unavoidab= le if one want short, easy to remember keys (e.g. pantable -s -t= csv, anyone used to pandoc will almost be able to remember this.).<= /p>

In addition, the above discu= ssion hasn=E2=80=99t covered the case that one might want to write a progra= m that can acts as both a filter and a standalone cli. e.g. I am thinking a= bout using -s to indicate it is a standalone cli (and wi= thout it, a pandoc filter). Using -M means the options i= s parsed differently (and duplicated) in these 2 cases.

Suggested method

  1. -O key=3Dvalue/--filter-args/
  2. Cons
    • what if there=E2=80=99s multiple filters? = special ordering is needed.
  3. -F "filter --split --on --h= yphens"/-F filter --split --on --space
    • Cons:
      • pandoc is already passing the output forma= t as the 1st arg
      • potentially break existing ill-named filte= rs

Comments:

Just for the sake of letting= the -F option be backward compatible, (1) might be bett= er. But either way it will be fine with me.

=E2=80=8B
<= /div>

--
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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/= msgid/pandoc-discuss/1239e0f1-2538-4781-8a75-90c59f86aabc%40googlegroups.co= m.
For more options, visit http= s://groups.google.com/d/optout.
------=_Part_1381_708360418.1483744202223-- ------=_Part_1380_100952215.1483744202223--