From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/18164 Path: news.gmane.org!.POSTED!not-for-mail From: Melroch Newsgroups: gmane.text.pandoc Subject: Re: Markdown -> plain: How to preserve blockquotes? Date: Fri, 8 Sep 2017 22:16:13 +0200 Message-ID: References: <8e1e0a64-7e87-4dbd-b669-0b55854fe110@googlegroups.com> <20170905045318.GE3765@Johns-MacBook-Pro.local> <6ec4d317-8de4-476d-86c5-91438eb47729@googlegroups.com> <9d2b4cdb-b236-42bd-baea-ff53da0ca1ed@googlegroups.com> <20170905181733.GD10851@Johns-MacBook-Pro.local> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="089e0828ddd8b0a0380558b33f11" X-Trace: blaine.gmane.org 1504901795 20377 195.159.176.226 (8 Sep 2017 20:16:35 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 8 Sep 2017 20:16:35 +0000 (UTC) To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBCWMVYEK54FRBD7VZPGQKGQEOSWTUEI-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Fri Sep 08 22:16:27 2017 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane.org Original-Received: from mail-it0-f59.google.com ([209.85.214.59]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dqPhA-000492-Qc for gtp-pandoc-discuss@m.gmane.org; Fri, 08 Sep 2017 22:16:09 +0200 Original-Received: by mail-it0-f59.google.com with SMTP id 195sf2704151itg.7 for ; Fri, 08 Sep 2017 13:16:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1504901776; cv=pass; d=google.com; s=arc-20160816; b=pVgAIW9c1Bb46F45adZtv7eKyzhggTXv0K2s/xCcoNF17QUaoEl2eCr+MOl2QyX+I+ J/drbtgqnRxSr+AHPiNMAhLMvg0wRw5fgTklJAbS1hB11gvkxdtPRmiHqgEzrYoSLW64 dFn4rxJtOSpLY0RdhmWvhkIM7pINbZrhK2+q9uy7dft2O/zTaA7aPi5W9xMm2L/H9TOB 6NWuFmXklTn8abpJuBfulwsFYc77/6h/mhCvvt7aZnWh1yEv1bw0CcIdZ7hs+uJyabzk phYxmZDzcAlAtZq6VoA42vn8Z5o1Qk/XrK4+NzOeu+rJYJ/T7H3JQGzOC7PS+UIoepfS mhBQ== 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:references:in-reply-to:mime-version:arc-authentication-results :arc-message-signature:sender:dkim-signature:dkim-signature :arc-authentication-results; bh=HZe38LqReic0QK3aJUQgEF7fsKAwBOHF5U/G6DODl4s=; b=PX8TSwE3p6A1NCMKGLuB8xudBNChl6lxtG58oUqTPDF9WMT1/6x9EPcWt8nPpaoP2/ S4czGHq1zdPmksV6sOJ+48wLnNi0bcf4rWHuV93s2rzfITOVEkjIfFZjMb8R6rDKr17e K2825GyTjG0DE4RhRjeB8QRpQkXjQQrNGvNiGocSd2E9OfGwQhdsgwtwdDMKOhNII5FR JIaVjXKMmc/ogXQovcMfWTjrsxeySqyIbDKDwEgiIymzXF6NKq1wWGM8Pxtk+RdOmjpk tmTB/7m7n2Bs8c5zTFkjJwDrn8dJiZtJ6+WipEaKlvi0IZ0/nqnYxuhKaxliYhr1JF6u pLMw== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fyKss6VB; spf=pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4002:c05::22f as permitted sender) smtp.mailfrom=melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:in-reply-to:references: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=HZe38LqReic0QK3aJUQgEF7fsKAwBOHF5U/G6DODl4s=; b=F3Idb2nXnGtS7jl9auzbBTsqGOZE0kbQYWhQuLKoN67MDmULRKpDgJwf2v5OYruPhP eFHWFb96PZatld/NuuO4msBxtcAVE2W2mv7y4OvQ4oxYiPkzLuCmY40O8GlhZaiCmUDS GXhdcL8gXvrPJDS0kAu7kwqr3L87112780fDI91WpvWtOB0TBYNwGozU9QB8zfp7y5TP xXozSJs9tSYmRR0W5/JqftdOhWXcR+q2VJ3KE3vXLiuUzIveUn/q6MVAEVLEv+T/7mPh 6ERmT4WakQwNd4QG8S5pJnXROlRpdI38DkcnQ4gJbReVRUW/EhUdKs6uUAgM+NvzWC9G Z/5A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references: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=HZe38LqReic0QK3aJUQgEF7fsKAwBOHF5U/G6DODl4s=; b=PSokvzLYD171RDQT16oUkHp/Q7Lk6nBpxRiUKC8tkbaL5ATOi7Yhu+LJQZlkCwxczr /W1VVlD1FK1mKmejhbmCcEnswh3s9Etj0EBocA6156lGeRjLeLDfDPjiTUSVorb0zEd9 npzo1ma/CeiAHMNQosoSUhLaS6slzr5AwCCNxx+chZSX67NvcJj1G0Ftz6NCEXgz4lny ubQ9hZZMdrEZq1Qcu6/Lu3Z+rlBIMTmGpzUJS2tdU9eHY1lv9wLBP8wCMbDAlnR4FKsk 9vjYDeqIzUxaea5CWuz4hCr7svdsnSxMIsBpvWzSrwNkqYjrLqaxBamqhLeWHZjj8ZV7 SPwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:in-reply-to:references: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=HZe38LqReic0QK3aJUQgEF7fsKAwBOHF5U/G6DODl4s=; b=YVmtcUpek4mfZ0iU+utBRTzDzoAAlDsLojTmufVo2Xt2IarrS+yLainavcG9ra3+eh Ot72YaAe/2VZ7wSG05zkoEHHBBBrRB2RjkahnUsiD6BYe6jVCfOUTP/s9YuYne/dkZ8f poyPTO0UsHVib3TXuDmQIao7gk1JGVsw+vNB6o3f8z1o8YZfZzvfGlBG4ycb8+2K4RNZ 3Qfo1eAd6oQ1qAPnY64dlnUhb4z9N5qeM+hiacIa3veOMTDzxbgH46IWheys45WI7aHM qO7bCvmyFQlxThkyzy3un2kY64cW84KS2IM6SUmd1yBEVvj9AQaAtwAq5tcmeHl3Z6r7 8Pfg== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AHPjjUg4+KvIi1D7Rx/UbSeo7Ke/TajzrPr/q5QW/skSc82Jdu6+W5S4 mo22Tgr4PU0V9aMWUrP0aVY= X-Google-Smtp-Source: ADKCNb6sU4x2i+o/mQT0+jrfoWqMyND7389KkTKiKXqWBHfEwK7GNLJvXQKG/Jb7yrdWpiaE7NS/XA== X-Received: by 10.36.211.15 with SMTP id n15mr193991itg.5.1504901775916; Fri, 08 Sep 2017 13:16:15 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 10.36.216.68 with SMTP id b65ls1932407itg.1.canary-gmail; Fri, 08 Sep 2017 13:16:15 -0700 (PDT) X-Received: by 10.84.247.9 with SMTP id n9mr2443419pll.54.1504901774979; Fri, 08 Sep 2017 13:16:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504901774; cv=none; d=google.com; s=arc-20160816; b=itz6RNz8r24VA7Caczv3iVYPmopWedDiwW5h3wP8FqogML+cgUla9sdIfJPcVyPFMO YckwbYy+zUIXwUe2VjruX9l2bKEKAz67FiLB9ovcVNYU7PwNb49nmDMUG3mtMtqMTrvP wKV7iPHDvo2lTpZfUpeMOR7pedrd8P5qLiZn06aSNkiQB2/Wpi+XDKqZ5QJXAYedhxUe 7VRxpXp/kTe39bw9JTaedE0mrI1MexwNDxm0MA05onLztVqSlIvIokhrjW7zUObBLCoV yyer1kRwPPE9KthLlZ+2625uSQedlfYghnMscWdJcEwWjGKtVg0sWuZOYDrFPaGBQJUR Y60g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:references:in-reply-to:mime-version :dkim-signature:arc-authentication-results; bh=7AYbmtaRn5bvIQBC70cVDP8AsNVIuUt4ZAL3JFmO2fw=; b=HZKRr4g5kuuOGmdO13CmpxhfH/1bzkJF6YzXA/0IVW8iGV0PcLtwWk0HKE1cEro+P0 TUA9yyndu7Vd/eGQXCEpZNZT0+ewc/o8/nwZUdOEFWQDNok5jJK7hfmkKFzpDZL5tTIf IVnhgnDU4jURSYPrAWOKAUab8qcfJ57GGOzOMOVUOIp/iYThCTcB9q+VRgKmUJbd5rJb Yc+M2URU5Z8yCkd+sVo3ETPhuhV7+6Af+5HhQz3JNvq+FhGZWrIPJCgOUjK5y7EhTfdw MD+pmOC/2LH8sL4A+y+fQIsKrKqRfKZXN9YzCwfOLHULoIJe3Espk8PZX8fE7uFVj1Gz qmzw== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fyKss6VB; spf=pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4002:c05::22f as permitted sender) smtp.mailfrom=melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Original-Received: from mail-yw0-x22f.google.com (mail-yw0-x22f.google.com. [2607:f8b0:4002:c05::22f]) by gmr-mx.google.com with ESMTPS id l77si228198ywc.16.2017.09.08.13.16.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Sep 2017 13:16:14 -0700 (PDT) Received-SPF: pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4002:c05::22f as permitted sender) client-ip=2607:f8b0:4002:c05::22f; Original-Received: by mail-yw0-x22f.google.com with SMTP id q80so10411688ywg.2 for ; Fri, 08 Sep 2017 13:16:14 -0700 (PDT) X-Received: by 10.37.102.82 with SMTP id z18mr3532995ybm.39.1504901774481; Fri, 08 Sep 2017 13:16:14 -0700 (PDT) Original-Received: by 10.37.175.199 with HTTP; Fri, 8 Sep 2017 13:16:13 -0700 (PDT) Original-Received: by 10.37.175.199 with HTTP; Fri, 8 Sep 2017 13:16:13 -0700 (PDT) In-Reply-To: <20170905181733.GD10851-9Rnp8PDaXcadBw3G0RLmbRFnWt+6NQIA@public.gmane.org> X-Original-Sender: melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fyKss6VB; spf=pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4002:c05::22f as permitted sender) smtp.mailfrom=melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=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:18164 Archived-At: --089e0828ddd8b0a0380558b33f11 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I have successfully used a filter to make plain output look like Perl POD documentation format. The beauty of plain is that you can just inject Str elements with whatever markup you like and plain will just output it verbatim. For example link URLs are present in the JSON which the filter receives, so you can just replace the Link elements with whatever literal strings you like which include the link text and the URL. For example a [Pandoc::Filter][] based filter for inserting the URL in angle brackets and the title if any in parentheses after the link text: ~~~~~~perl #!/usr/bin/env perl use 5.010001; use utf8; use strict; use warnings; use Pandoc::Filter; use Pandoc::Elements; pandoc_filter Link =3D> sub { my $url =3D $_->url; my $title =3D $_->title; my $content =3D $_->content; $title &&=3D qq{ ($title)}; return [@$content, Space, Str "<$url>", Str $title]; }; ~~~~~~ or to get traditional email emphasis: ~~~~~~perl #!/usr/bin/env perl use 5.010001; use utf8; use strict; use warnings; use Pandoc::Elements; use Pandoc::Walker qw[ action transform ]; my $action =3D action Emph =3D> sub { my($elem, $action) =3D @_; my $content =3D transform $elem->content, $action, $action; # recurse return [Str '_', @$content, Str '_']; }, Strong =3D> sub { my($elem, $action) =3D @_; my $content =3D transform $elem->content, $action, $action; # recurse return [Str '*', @$content, Str '*']; }; my $doc =3D pandoc_json(); transform $doc, $action, $action; # action both as callback and argument! print $doc->to_json; ~~~~~~ Block quotes are tougher but it could be done if you run pandoc (with Pandoc.pm) on the content with the same filter(s) to fix nested block quotes, then insert '> ' at the start of every line: ~~~~~~perl # less-plain.pl use Pandoc::Elements; use Pandoc::Walker qw[ action transform ]; use Pandoc; # wrapper module my $doc =3D pandoc_json(); my $meta =3D $doc->meta; my $api_version =3D $doc->api_version; my $action =3D action BlockQuote =3D> sub { my($elem, $action) =3D @_; my $content_doc =3D Document { blocks =3D> $elem->content, # works because content is an array of blocks! meta =3D> $meta, api_version =3D> $api_version, }; # convert with pandoc! my $content =3D $content_doc->to_pandoc( -t =3D> 'plain', -F =3D> $0 ); $content =3D~ s{^}{> }mg; return Para [ Str $content ]; }, Link =3D> ..., # replace ... with the subs above, and/or insert your own! Emph =3D> ..., Strong =3D> ...; transform $doc, $action, $action; # action both as callback and argument! print $doc->to_json; ~~~~~~ The trick with calling pandoc works because the `$0` variable contains the path to the current program which is the filter itself. Naturally you would like to put all your modifications in the same filter. [Pandoc::Filter]: https://metacpan.org/pod/Pandoc::Filter /bpj Den 5 sep 2017 20:18 skrev "John MacFarlane" : > You might have some success with filters. > You could use Markdown output, and intercept constructions > like Strong and Emph, replacing them with something else. > > +++ Francisco Lopes [Sep 05 17 11:02 ]: > >> Em ter=C3=A7a-feira, 5 de setembro de 2017 09:16:41 UTC-3, Kolen Cheun= g >> escreveu: >> >> As I guessed you don't really want to have plaintext. Again, try >> turning off markdown extensions to make it more "lightweight" and >> tailor that as your "plaintext". >> >> The problem is that turning off markdown extensions to achieve plain >> text will simply not work afaik. >> For example, current plain text output will turn bold markdown **text*= * >> to all caps plain TEXT. Which I find nice, >> I find it logical for plain text output. Can't it be done by turning >> off flags? >> The thing is that what I want has no standard yet, it's something >> target for plain text EML, between current plain >> text and markdown. IMO, **foo** etc, clutters plain text output. >> Another possible feature of such target output >> could be to always move url links to footer while leaving anchors in >> the main content. >> Regards >> >> Regarding treating list marker as plaintext or not: we need to ask >> ourselves what do we mean when we say plaintext and markdown. In the >> "markdown wins the plaintext war" camp, markdown is plaintext. Just >> to look up wikipedia in <[1]https://en.m.wikipedia.org/ >> wiki/Plain_text>, non-binary formats are plaintext, like most of the >> pandoc formats including HTML. So pandoc's plain format definitely >> has a special meaning than these. And @jgm just defined it above. >> Lastly, when I say the list marker isn't plaintext, I'm thinking in >> terms of "stringify". Like if given a document, if I'm to remove >> every formatting features, what would I be left with? Or in other >> words, if I speak it out without any help from those markups, what >> would that be? In this sense, a list in *plain* text is like "Give >> me a pen, pencil, and ruler." By the way, I think in typography, >> when you write that in a list (with list markers), the rule to apply >> punctuation marks and connectives is exactly as if you write it out >> in a sentence. i.e. the list marker is just a visual element to >> better represent the information. >> >> -- >> 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 email to [2]pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To post to this group, send email to >> [3]pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To view this discussion on the web visit >> [4]https://groups.google.com/d/msgid/pandoc-discuss/9d2b4cdb-b236-42bd= - >> baea-ff53da0ca1ed%40googlegroups.com. >> For more options, visit [5]https://groups.google.com/d/optout. >> >> References >> >> 1. https://en.m.wikipedia.org/wiki/Plain_text >> 2. mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org >> 3. mailto:pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org >> 4. https://groups.google.com/d/msgid/pandoc-discuss/9d2b4cdb-b2 >> 36-42bd-baea-ff53da0ca1ed-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org?utm_medium=3Demail& >> utm_source=3Dfooter >> 5. https://groups.google.com/d/optout >> > > -- > 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 > email 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/ms > gid/pandoc-discuss/20170905181733.GD10851%40Johns-MacBook-Pro.local. > For more options, visit https://groups.google.com/d/optout. > --=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/CADAJKhC1y5ip7M%3DHiEUjF2urMyciCUK%2BHroXw%2B5wabi7n4XXRA%40= mail.gmail.com. For more options, visit https://groups.google.com/d/optout. --089e0828ddd8b0a0380558b33f11 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I have successfully used a filter to make plain output lo= ok like Perl POD documentation format. The beauty of plain is that you can = just inject Str elements with whatever markup you like and plain will just = output it verbatim. For example link URLs are present in the JSON which the= filter receives, so you can just replace the Link elements with whatever l= iteral strings you like which include the link text and the URL. For exampl= e a [Pandoc::Filter][] based filter for inserting the URL in angle brackets= and the title if any in parentheses after the link text:
=
~~~~~~perl
#!/usr/bin/env perl

u= se 5.010001;
use utf8;
use st= rict;
use warnings;

use Pandoc::Filter;
use Pandoc::E= lements;

pandoc_filter L= ink =3D> sub {
=C2=A0 =C2=A0 my $url =3D $_->u= rl;
=C2=A0 =C2=A0 my $title =3D $_->title;
<= div dir=3D"auto">=C2=A0 =C2=A0 my $content =3D $_->content;
=C2=A0 =C2=A0 $title &&=3D qq{ ($title)};
=C2=A0 =C2=A0 return [@$content, Space, Str "<$url>&qu= ot;, Str $title];
};

~~~~~~

=
or to get tr= aditional email emphasis:

~~~~~~perl
#!/usr/bin/env perl

use 5.010001;
us= e utf8;
use strict;=
use warnings;

use Pandoc::Elements;
use Pandoc::Walker qw[ action tran= sform ];

my $action =3D action Em= ph =3D> sub {
= =C2=A0 =C2=A0 my($elem, $action) =3D @_;
=C2=A0 =C2=A0 my $content =3D transform $elem->con= tent, $action, $action; # recurse
=C2=A0 =C2=A0 return [Str '_', @$content, Str '= _'];
},<= /div>
Strong =3D> sub {
=C2=A0 =C2=A0 my($elem, = $action) =3D @_;
= =C2=A0 =C2=A0 my $content =3D transform $elem->content, $action, $action= ; # recurse
=C2=A0 = =C2=A0 return [Str '*', @$content, Str '*'];
};
=
my $doc =3D pandoc_json();

transform $doc, $action, $action; # action both as callback and argum= ent!

print $doc->to_json;
~~~~~~

= Block quotes are tougher but it could be done if = you run pandoc (with Pandoc.pm) on the content with the same filter(s) to f= ix nested block quotes,
then insert '> ' at the start of every line:

~~~~~~perl

use Pandoc::Elements;
<= div dir=3D"auto">use Pandoc::Walker qw[ action tr= ansform ];
use Pand= oc; # wrapper module

my $doc =3D = pandoc_json();
my $= meta =3D $doc->meta;
my $api_version =3D $doc->api_version;

my $action =3D action BlockQuote =3D> sub {
=
=C2=A0 =C2=A0 my($elem, $action= ) =3D @_;
=C2=A0 = =C2=A0 my $content_doc =3D Document {=C2=A0
<= font face=3D"sans-serif">=C2=A0 =C2=A0 =C2=A0 =C2=A0 blocks =3D> $elem-&= gt;content, # works because content is an array of blocks!
=C2=A0 =C2=A0 =C2=A0 =C2=A0 meta = =3D> $meta,
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 api_version =3D> $api_version,
=C2=A0 =C2=A0 };
=C2=A0 =C2=A0 # convert with pandoc!<= /font>
=C2=A0 =C2=A0 my $c= ontent =3D $content_doc->to_pandoc( -t =3D> 'plain', -F =3D&g= t; $0 );
=C2=A0 =C2= =A0 $content =3D~ s{^}{> }mg;
=C2=A0 =C2=A0 return Para [ Str $content ];
},
<= font face=3D"sans-serif">Link =3D> ..., =C2=A0 # replace ... with the su= bs above, and/or insert your own!
Emph =3D> ...,
Strong =3D> ...;

transform $doc, $action, $action; # action both as callback and argument= !

=
print $doc->to_json;<= /div>
~~~~~~

The trick with calling pandoc works because the `$0`= variable contains the path to the current program which is the filter itse= lf.
Naturally you w= ould like to put all your modifications in the same filter.

/bpj

=
Den 5 sep 2017 20:18 skrev "John MacFarlane= " <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org>:
You might have some su= ccess with filters.
You could use Markdown output, and intercept constructions
like Strong and Emph, replacing them with something else.

+++ Francisco Lopes [Sep 05 17 11:02 ]:
=C2=A0 Em ter=C3=A7a-feira, 5 de setembro de 2017 09:16:41 UTC-3, Kolen Che= ung
=C2=A0 escreveu:

=C2=A0 =C2=A0 As I guessed you don't really want to have plaintext. Aga= in, try
=C2=A0 =C2=A0 turning off markdown extensions to make it more "lightwe= ight" and
=C2=A0 =C2=A0 tailor that as your "plaintext".

=C2=A0 The problem is that turning off markdown extensions to achieve plain=
=C2=A0 text will simply not work afaik.
=C2=A0 For example, current plain text output will turn bold markdown **tex= t**
=C2=A0 to all caps plain TEXT. Which I find nice,
=C2=A0 I find it logical for plain text output. Can't it be done by tur= ning
=C2=A0 off flags?
=C2=A0 The thing is that what I want has no standard yet, it's somethin= g
=C2=A0 target for plain text EML, between current plain
=C2=A0 text and markdown. IMO, **foo** etc, clutters plain text output.
=C2=A0 Another possible feature of such target output
=C2=A0 could be to always move url links to footer while leaving anchors in=
=C2=A0 the main content.
=C2=A0 Regards

=C2=A0 =C2=A0 Regarding treating list marker as plaintext or not: we need t= o ask
=C2=A0 =C2=A0 ourselves what do we mean when we say plaintext and markdown.= In the
=C2=A0 =C2=A0 "markdown wins the plaintext war" camp, markdown is= plaintext. Just
=C2=A0 =C2=A0 to look up wikipedia in <[1]https://en.m.wikipedia.org/
=C2=A0 =C2=A0 wiki/Plain_text>, non-binary formats are plaintext, like m= ost of the
=C2=A0 =C2=A0 pandoc formats including HTML. So pandoc's plain format d= efinitely
=C2=A0 =C2=A0 has a special meaning than these. And @jgm just defined it ab= ove.
=C2=A0 =C2=A0 Lastly, when I say the list marker isn't plaintext, I'= ;m thinking in
=C2=A0 =C2=A0 terms of "stringify". Like if given a document, if = I'm to remove
=C2=A0 =C2=A0 every formatting features, what would I be left with? Or in o= ther
=C2=A0 =C2=A0 words, if I speak it out without any help from those markups,= what
=C2=A0 =C2=A0 would that be? In this sense, a list in *plain* text is like = "Give
=C2=A0 =C2=A0 me a pen, pencil, and ruler." By the way, I think in typ= ography,
=C2=A0 =C2=A0 when you write that in a list (with list markers), the rule t= o apply
=C2=A0 =C2=A0 punctuation marks and connectives is exactly as if you write = it out
=C2=A0 =C2=A0 in a sentence. i.e. the list marker is just a visual element = to
=C2=A0 =C2=A0 better represent the information.

=C2=A0 --
=C2=A0 You received this message because you are subscribed to the Google =C2=A0 Groups "pandoc-discuss" group.
=C2=A0 To unsubscribe from this group and stop receiving emails from it, se= nd
=C2=A0 an email to [2]pandoc-discuss+unsubscribe@googlegroups.= com.
=C2=A0 To post to this group, send email to
=C2=A0 [3]pandoc-discuss@googlegroups.com.
=C2=A0 To view this discussion on the web visit
=C2=A0 [4]https://groups.google.= com/d/msgid/pandoc-discuss/9d2b4cdb-b236-42bd-
=C2=A0 baea-ff53da0ca1ed%40googlegroups.com.
=C2=A0 For more options, visit [5]https://groups.google.com/d= /optout.

References

=C2=A0 1. https://en.m.wikipedia.org/wiki/Plain_text<= /a>
=C2=A0 2. mailto:
pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
=C2=A0 3. mailto:
pandoc-discuss@googlegroups.com
=C2=A0 4. https://groups.googl= e.com/d/msgid/pandoc-discuss/9d2b4cdb-b236-42bd-baea-ff53da0ca1ed= @googlegroups.com?utm_medium=3Demail&utm_source=3Dfooter<= br> =C2=A0 5. https://groups.google.com/d/optout

--
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-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to pandoc-discuss-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.orgm. To view this discussion on the web visit https://groups.google.com/d/msgi= d/pandoc-discuss/20170905181733.GD10851%40Johns-MacBook-Pro.local= .
For more options, visit https://groups.google.com/d/optout.

--
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://g= roups.google.com/d/msgid/pandoc-discuss/CADAJKhC1y5ip7M%3DHiEUjF2urMyciCUK%= 2BHroXw%2B5wabi7n4XXRA%40mail.gmail.com.
For more options, visit http= s://groups.google.com/d/optout.
--089e0828ddd8b0a0380558b33f11--