From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/14851 Path: news.gmane.org!not-for-mail From: Sergio Correia Newsgroups: gmane.text.pandoc Subject: Re: panflute: a pythonic alternative to pandocfilters Date: Wed, 27 Apr 2016 01:46:29 -0700 (PDT) Message-ID: <6a0a11df-8825-4e0c-8582-948922e9f66b@googlegroups.com> References: <5ee6e6e1-8e2e-450d-b793-c0464e4be449@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_6077_642209140.1461746789572" X-Trace: ger.gmane.org 1461746805 9537 80.91.229.3 (27 Apr 2016 08:46:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 27 Apr 2016 08:46:45 +0000 (UTC) To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCOYT6WP5QGRBZXYQG4QKGQESPV2ULI-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Wed Apr 27 10:46:38 2016 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane.org Original-Received: from mail-ob0-f190.google.com ([209.85.214.190]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1avL7E-00057P-Dj for gtp-pandoc-discuss@m.gmane.org; Wed, 27 Apr 2016 10:46:36 +0200 Original-Received: by mail-ob0-f190.google.com with SMTP id n10sf9733644obb.0 for ; Wed, 27 Apr 2016 01:46:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; 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=CGzazzRZMnOxY6WlyjbT2IKjijUDwlFGDE9QKdj0Sdc=; b=meWswGWJofeHhW4q2mCksdLf3RukDJHrsG2SPvhOKy37UBOxURt/GqZV/L5872crKu fhietSYqSQLAAwoJpTg8DhonDXq+rlwNjE3Nr3JeHMsao2vlK/wQcIaP8Bj5rCoRsd2e nbyaq//5/MxJNtYJHye+5KOyhLQCB2qn5jhsLmxijG+cRSm+3KMc+O+HL6q22GNB7k6W 0ZOSuKDBPVJCy1y3ddfdZsR1jZTMyYTOF9bAg8An7hYWhZhfSkmb8z2OJtMpr8kC28Cu hCsd1W251Tp0vW6v3LyQ+L8xOgr2rQ/di/JHnTaw97oOy9j+DIOQSNmjRbY+3sm9fFbm rtfw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; 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=CGzazzRZMnOxY6WlyjbT2IKjijUDwlFGDE9QKdj0Sdc=; b=e9bndEcqH0DTH21w1zmkU7GkABoGGCjbfvDbzXExI9tDUTWMS/WKEwdB4ZPC7W78Ks IToxioxuNDX1MW3y3/kYu6lZiwqbpiSYAdyQyuDLrsKEugGRHOBdm/WweC0gF8hxVJWl aCYmd8V/rinZROm0VmQVyR13TbqJRkWedQnJPJ+R4otIOnZGfSk7paEiZEScvmUHaDTE hN+8jPMQcd40mQH3s1faNSS0a/eWibNKt9md4nTXh8s5A8PBxNfQneAYHtTQ35J2ifvT jpmm2bQLOJaeyEg4gH8V72LtAtspWAApQoIw+IT5rG1smx+az65zjDpkowYCdf0Zkvm0 DCkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; 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=CGzazzRZMnOxY6WlyjbT2IKjijUDwlFGDE9QKdj0Sdc=; b=DxoYglNx5wZM4E1MBsdC9J1jt3subIo1nyoTghiIQO3vdDggm63il8FL+Zx063i96K a7gkmyXGEV8NKTwjeOSUymPVeJgWson8Lq3MC4G7OtOtELCxf3OoC6I14dBvand7HydV 1MJjmzlnk2r1qufLeEmqzAm3SnFRNjo43sGEif25lEHSISvP6iLJQ6a0DYMLFYPGdca9 8+4uvdhTCiEaSgDsT9yAq1pg9DrnwlPWLYyWPYvAoXLM08eeyxWkS9uQD1sbdW4Oi/Fx GRHGe1w0pGS3L7pjgsjOpwwx12772MYMLqjmWuBlMqV2FZLo+XxJfPc4Bwzt9+x0tXJW b6vw== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOPr4FUKlwI3Cdy54SR5WIwU5R3JeYqAArUjk14syfIXbr3lsLQw63Rjl3a3AhVJfn/Lcg== X-Received: by 10.182.88.129 with SMTP id bg1mr86052obb.3.1461746790685; Wed, 27 Apr 2016 01:46:30 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 10.182.97.73 with SMTP id dy9ls35039obb.35.gmail; Wed, 27 Apr 2016 01:46:30 -0700 (PDT) X-Received: by 10.157.45.79 with SMTP id v73mr85586ota.9.1461746790093; Wed, 27 Apr 2016 01:46:30 -0700 (PDT) In-Reply-To: X-Original-Sender: sergio.correia-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-Spam-Checked-In-Group: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Google-Group-Id: 1007024079513 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Xref: news.gmane.org gmane.text.pandoc:14851 Archived-At: ------=_Part_6077_642209140.1461746789572 Content-Type: multipart/alternative; boundary="----=_Part_6078_57286504.1461746789573" ------=_Part_6078_57286504.1461746789573 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I've thought a bit about adding .parent and .next .previous elements. It=20 can be done, but with two disclaimers (which I'm not sure if make it worth= =20 it): 1. With some elements, such as tables, parent is not very useful as I=20 don't know whether a list belonged to a cell in the header or in the tab= le=20 body (same for definition lists, etc.). A solution would be to add speci= al=20 TableCell, TableRow, TableHeader, TableData elements, and so on, but thi= s=20 complicates things. On the other hand, we could then do filters that app= ly=20 only to table cells and so on. 2. People might try to modify elem.next or elem.parent, which shouldn't= =20 be done, as it messes up walk() function. This is a similar problem to= =20 modifying a list that is being iterated. Do you thing it would be useful, given these issues? On Wednesday, April 27, 2016 at 4:23:43 AM UTC-4, Samuel Coavoux wrote: > > This looks very promising, thank you for the package. > > One thing that is missing from pandocfilters is the ability to easily=20 > manipulate sequences of elements rather than single ones. Something like= =20 > (pseudo code): > > if type(elem) =3D=3D "Quoted" and type(next.elem) =3D=3D "Cite": > > there was a library aiming at this functionality, pandocpatterns[^1], but= =20 > it hasn't been updated in a while, and I personally never could make it= =20 > work. > > Do you think that it would be possible to implement this in panflutes? > > [^1]: https://bitbucket.org/elliottslaughter/pandocpatterns ; discussed= =20 > on the list here :=20 > https://groups.google.com/forum/#!searchin/pandoc-discuss/pandocpatterns/= pandoc-discuss/NsEGkTN4fnk/Y520jtQ5EzkJ > > Le mardi 26 avril 2016 17:20:47 UTC+2, Wagner Macedo a =C3=A9crit : >> >> Agree. I checked some of the documentation and I'm impressed, it's a ver= y=20 >> good job. >> >> I'll try in the following days to convert some of my current scripts to= =20 >> panflute and I'll let you know. >> >> -- >> Wagner Macedo=20 >> >> On 26 April 2016 at 12:00, Sergio Correia wrote: >> >>> Did a quick check of the whatsnew for 3.3, 3.4 and 3.5 and it seems I'm= =20 >>> not using features specific to any of these sub versions. That said, fo= r=20 >>> big documents it might be faster to have 3.5+ because OrderedDict was= =20 >>> rewritten in C. >>> >>> On Tuesday, April 26, 2016 at 5:36:32 AM UTC-4, Wagner Macedo wrote: >>>> >>>> Excellent, congratulations for the effort. >>>> >>>> What subversion of Python 3 is targeted? >>>> Em 26/04/2016 02:12, "Sergio Correia" escreveu: >>>> >>>> Dear all, >>>> >>>> After being a heavy user of pandocfilters.py for a few years, I wrote= =20 >>>> an alternative package (with a very similar API) that takes a more pyt= honic=20 >>>> approach: >>>> >>>> >>>> - Elements are proper objects (with properties and methods) instead= =20 >>>> of dicts and lists >>>> - Elements can be created using named arguments: Header(Str('The'),= =20 >>>> Space, Str('Title'), level=3D1) >>>> - Batteries are included: I included functions that I ended up=20 >>>> reusing through my different filters\ >>>> >>>> The source and documentation is here:=20 >>>> https://github.com/sergiocorreia/panflute . It currently uses Python 3= =20 >>>> but if there is demand from Python 2 users we could try a port. >>>> >>>> Ports of some of the existing filters are here:=20 >>>> https://github.com/sergiocorreia/panflute/tree/master/examples/panflut= e >>>> >>>> More examples will be placed here:=20 >>>> https://github.com/sergiocorreia/panflute-filters >>>> >>>> Feel free to comment here or on github; any suggestions or pull=20 >>>> requests are more than welcome :) >>>> >>>> Best, >>>> Sergio >>>> >>>> --=20 >>>> You received this message because you are subscribed to the Google=20 >>>> Groups "pandoc-discuss" group. >>>> To unsubscribe from this group and stop receiving emails from it, send= =20 >>>> an email to pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> To post to this group, send email to pandoc-...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> To view this discussion on the web visit=20 >>>> https://groups.google.com/d/msgid/pandoc-discuss/b6a8c6cf-cae7-403a-99= e9-4e170a150428%40googlegroups.com=20 >>>> >>>> . >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>>> --=20 >>> You received this message because you are subscribed to the Google=20 >>> Groups "pandoc-discuss" group. >>> To unsubscribe from this group and stop receiving emails from it, send= =20 >>> an email to pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To post to this group, send email to pandoc-...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To view this discussion on the web visit=20 >>> https://groups.google.com/d/msgid/pandoc-discuss/5ee6e6e1-8e2e-450d-b79= 3-c0464e4be449%40googlegroups.com=20 >>> >>> . >>> >>> 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/6a0a11df-8825-4e0c-8582-948922e9f66b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout. ------=_Part_6078_57286504.1461746789573 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I've thought a bit about adding .parent and .next .pre= vious elements. It can be done, but with two disclaimers (which I'm not= sure if make it worth it):

  1. With some elements, such as tables, parent is not very use= ful as I don't know whether a list belonged to a cell in the header or = in the table body (same for definition lists, etc.). A solution would be to= add special TableCell, TableRow, TableHeader, TableData elements, and so o= n, but this complicates things. On the other hand, we could then do filters= that apply only to table cells and so on.
  2. People might try to modify elem.next or elem.parent, wh= ich shouldn't be done, as it messes up walk() function. This is a simil= ar problem to modifying a list that is being iterated.
Do you thing it would be useful, given these issues?

On Wednesday= , April 27, 2016 at 4:23:43 AM UTC-4, Samuel Coavoux wrote:
This looks very promising, th= ank you for the package.

One thing that is missing from pandocfilter= s is the ability to easily manipulate sequences of elements rather than sin= gle ones. Something like (pseudo code):

=C2=A0=C2=A0=C2=A0 if type(e= lem) =3D=3D "Quoted" and type(next.elem) =3D=3D "Cite":=

there was a library aiming at this functionality, pandocpatterns[^1= ], but it hasn't been updated in a while, and I personally never could = make it work.

Do you think that it would be possible to implement th= is in panflutes?

[^1]: https://bitbucket.org/elliottslaught= er/pandocpatterns ; discussed on=20 the list here :=20 https://groups.google.com/forum/#!se= archin/pandoc-discuss/pandocpatterns/pandoc-discuss/NsEGkTN4fnk/<= wbr>Y520jtQ5EzkJ

Le mardi 26 avril 2016 17:20:47 UTC+2, Wagner M= acedo a =C3=A9crit=C2=A0:
Agree. I checked some of the documentation and I'm impressed, = it's a very good job.

I'll try in the following = days to convert some of my current scripts to panflute and I'll let you= know.

--
Wagner Macedo

On 26 April 2016 at 12:00, Sergio Correia <sergio....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>= wrote:
Did a quick chec= k of the whatsnew for 3.3, 3.4 and 3.5 and it seems I'm not using featu= res specific to any of these sub versions. That said, for big documents it = might be faster to have 3.5+ because OrderedDict was rewritten in C.<= br>
On Tuesday, April 26, 2016 at 5:36:32 AM UTC-4, Wagner Macedo wrote:=

Excelle= nt, congratulations for the effort.

What subversion of Python 3 is targeted?

Em 26/04/2016 02:12, "Sergio C= orreia" <sergio....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> escreveu:=
Dear all,
After being a heavy user of pandocfilters.py for a few ye= ars, I wrote an alternative package (with a very similar API) that takes a = more pythonic approach:

  • Elements are proper objects (with properties and methods) = instead of dicts and lists
  • Elements can be created using named arguments: Header(Str('The'),= Space, Str('Title'), level=3D1)
  • Batteries are included: I included functions that I ended u= p reusing through my different filters\
The source and= documentation is here:=C2=A0htt= ps://github.com/sergiocorreia/panflute . It currently uses Python = 3 but if there is demand from Python 2 users we could try a port.

Ports of some of the existing filters are here:=C2=A0https:/= /github.com/sergiocorreia/panflute/tree/master/examples/panflute<= /a>


Feel = free to comment here or on github; any suggestions or pull requests are mor= e than welcome :)

Best,
Sergio

--
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-discus...@googlegroups.com.
To post to this group, send email to pandoc-...@googleg= roups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pan= doc-discuss/b6a8c6cf-cae7-403a-99e9-4e170a150428%40googlegroups.c= om.
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 pandoc-discus...@googlegroups.com.
To post to this group, send email to pandoc-...@googleg= roups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pan= doc-discuss/5ee6e6e1-8e2e-450d-b793-c0464e4be449%40googlegroups.c= om.

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://groups.google.com/d/= msgid/pandoc-discuss/6a0a11df-8825-4e0c-8582-948922e9f66b%40googlegroups.co= m.
For more options, visit http= s://groups.google.com/d/optout.
------=_Part_6078_57286504.1461746789573-- ------=_Part_6077_642209140.1461746789572--