From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/16627 Path: news.gmane.org!.POSTED!not-for-mail From: BP Jonsson Newsgroups: gmane.text.pandoc Subject: Re: Filter with arguments Date: Sat, 7 Jan 2017 20:05:36 +0100 Message-ID: References: <20170106114647.GG791@Administrateurs-iMac-3.local> <1239e0f1-2538-4781-8a75-90c59f86aabc@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1483815951 16809 195.159.176.226 (7 Jan 2017 19:05:51 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 7 Jan 2017 19:05:51 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBDIY76M674FRBCHYYTBQKGQEUMVCZAY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Sat Jan 07 20:05:46 2017 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane.org Original-Received: from mail-vk0-f63.google.com ([209.85.213.63]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cPwJB-00037M-J1 for gtp-pandoc-discuss@m.gmane.org; Sat, 07 Jan 2017 20:05:41 +0100 Original-Received: by mail-vk0-f63.google.com with SMTP id p9sf119948519vkd.1 for ; Sat, 07 Jan 2017 11:05:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to: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=uJ0n9p4YHiu7fKDx1eek8FmbRhCpf7QYKA041+Os+nc=; b=bz26Fd0KPBGBhD3uXBjmSczLMcdxIhp/cBEOaeC0+4xbXQAJJmCmdK+4jySkOi7kOV DL6UoZ3Lv7Ew5DzvotZE9phlYeb6xZfmBHqvku1y/k4RKmogaHUGucUDLIYGziVo4vVS yNI3C/nzIJfvIsatP+Tg6R/izjqA/9yxGnm0Bs7KaofSSc5++Tq+zZkdxQN4Whc7o/Dm o5riG7ZG8za+cc61ycfC5XHGonsMu9eWPX/5nEQ0MUU9AProlIBqx/2fM1nreI5gmzsT Zj4U8dpbMJQwyksdtgk42eLECz1us2+0neCzSwn5OEk1lk69DQQGjB60MohDXXROGyRu e2bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:subject:to:references:from:message-id :date:user-agent:mime-version:in-reply-to: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=uJ0n9p4YHiu7fKDx1eek8FmbRhCpf7QYKA041+Os+nc=; b=kstV5gLtXtm1Rb2nXoD3zHVj7TCFvjkD1n2GAqKWd24BenWVcS1DTmYtgEye6vbKGk wuJ3XSGD0tJi0sEeULaPrXWRYLDbXPRrm8nMmjqrScbFvXoxO8SyKPwjQ8bTITprvTop +sQrxtohuED3jxGU9Vjko3c8PPRYI5ScNhQmYOamfoZQKsRneI2l6rMdmmGxjJHIBj58 0fpTNBVWjSvIb+VEZ4QDQQHtVS8cCgbQzK16YYWnG/ojXBjjcVl2pbPWm1Tvy02frojZ nomR1H4uvPNFJpL6hCmECLn/FThIydZKFcc3k5bYCQvQoz3zzgcDWu88h/AObta Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AIkVDXIMGbG496BdDuRyQRLMi2zAN+hxEv7cq9esVpApCm3e6VRIbeOwa+wCymaOc0YP+g== X-Received: by 10.36.87.138 with SMTP id u132mr239543ita.1.1483815945521; Sat, 07 Jan 2017 11:05:45 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 10.36.116.130 with SMTP id o124ls1438039itc.21.canary-gmail; Sat, 07 Jan 2017 11:05:43 -0800 (PST) X-Received: by 10.99.115.14 with SMTP id o14mr44082351pgc.103.1483815943946; Sat, 07 Jan 2017 11:05:43 -0800 (PST) Original-Received: from manu6.manufrog.com (manu6.manufrog.com. [138.128.164.242]) by gmr-mx.google.com with ESMTPS id l129si5336484vkg.1.2017.01.07.11.05.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 Jan 2017 11:05:43 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning bpjonsson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org does not designate 138.128.164.242 as permitted sender) client-ip=138.128.164.242; Original-Received: from [178.249.150.162] (port=42713 helo=[192.168.1.250]) by manu6.manufrog.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.87) (envelope-from ) id 1cPwJ9-003Fli-LV for pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org; Sat, 07 Jan 2017 20:05:39 +0100 In-Reply-To: <1239e0f1-2538-4781-8a75-90c59f86aabc-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - manu6.manufrog.com X-AntiAbuse: Original Domain - googlegroups.com X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - gmail.com X-Get-Message-Sender-Via: manu6.manufrog.com: authenticated_id: bpj-J3H7GcXPSITLoDKTGw+V6w@public.gmane.org X-Authenticated-Sender: manu6.manufrog.com: bpj-J3H7GcXPSITLoDKTGw+V6w@public.gmane.org X-Source: X-Source-Args: X-Source-Dir: X-Original-Sender: bpjonsson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; spf=softfail (google.com: domain of transitioning bpjonsson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org does not designate 138.128.164.242 as permitted sender) smtp.mailfrom=bpjonsson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=fail (p=NONE 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.org gmane.text.pandoc:16627 Archived-At: Den 2017-01-07 kl. 00:10, skrev Kolen Cheung: > In addition, the above discussion hasn=E2=80=99t covered the case that on= e might > want to write a program that can acts as both a filter and a standalone > cli. Is that a realistic scenario? Either the program would have to=20 expect pandoc-style JSON as input when used standalone, or it=20 could check whether the input is (pandoc-style) JSON and do=20 something completely different if it isn't! I have some scripts=20 which do essentially the same things to HTML documents as some of=20 my pandoc filters, but they use entirely different libraries: an=20 HTML parser instead of a JSON parser, and a different library for=20 manipulating the data structure produced by the respective parser. Explicit piping of `-t json` output is also a rather outlandish=20 problem: it is now effectively only used by filter authors=20 debugging their filters, who then really should not expect to not=20 have to specify the output format as an argument to the program on=20 the rhs of the pipe. As for the problem of metadata being interpreted as markdown the=20 code which Pandoc::Elements uses to convert metadata to plain data=20 is not too complicated (the `string` methods are already there for=20 other purposes anyway): sub Pandoc::Document::metavalue { my $meta =3D $_[0]->meta; return { map { $_ =3D> $meta->{$_}->metavalue } keys %$meta } } sub Pandoc::Document::MetaMap::metavalue { my $map =3D $_[0]->{c}; return { map { $_ =3D> $map->{$_}->metavalue } keys %$map } } sub Pandoc::Document::MetaList::metavalue { [ map { $_->metavalue } @{$_[0]->{c}} ] } sub Pandoc::Document::MetaInlines::metavalue { join '', map { $_->string } @{$_[0]->{c}} } sub Pandoc::Document::MetaBlocks::metavalue { join "\n", map { $_->string } @{$_[0]->{c}} } sub Pandoc::Document::MetaString::metavalue { $_[0]->{c} } sub Pandoc::Document::MetaBool::metavalue { $_[0]->{c} ? 1 : 0 } As for hierarchical metadata structures being ugly I don't think=20 they are. They create a namespace and keep related data together=20 without relying on sorting order, and often hierarchical data make=20 things easier to do compared to non-hierarchical data. That's the=20 reason data structures in general and hierarchical data structures=20 in particular were invented. At a user experience level they keep=20 each mapping key shorter and less repetitive, since otherwise you=20 would in principle have to make every key a 'path' in order to=20 avoid field name clashes. I have been in the situation of having=20 to emulate hierarcical data structures in languages which don't=20 have them, or even associative arrays, in languages which don't=20 have them. It's no fun. Consider a case where the user would supply different data to be=20 used in processing elements with different classes with different=20 output formats, in an hierachical version myfilter: class: foo: latex: ... html: ... bar: latex: ... html: ... ... ... and a 'non-hierarchical' version myfilter-class-foo-latex: ... myfilter-class-foo-html: ... myfilter-class-bar-latex: ... myfilter-class-bar-html: ... I vastly prefer the first both as a document author and as a=20 filter author! /bpj --=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/c21c773d-c958-2e55-725d-90863f5f9792%40gmail.com. For more options, visit https://groups.google.com/d/optout.