From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/11903 Path: news.gmane.org!not-for-mail From: Gordon Steemson Newsgroups: gmane.text.pandoc Subject: Re: Idea: Support for centred block-level elements, without necessarily needing to revise pandoc Date: Mon, 2 Feb 2015 03:07:49 -0800 Message-ID: References: <2a08b6a8-d381-45bc-9361-3bf402544fb0@googlegroups.com> <20150201064534.GB12964@localhost.hsd1.ca.comcast.net> <15411876-5ead-405f-b72f-4db72406b9d4@googlegroups.com> <20150201184124.GE13226@localhost.hsd1.ca.comcast.net> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=089e0158c0f600cd74050e18f74b X-Trace: ger.gmane.org 1422875272 19056 80.91.229.3 (2 Feb 2015 11:07:52 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 2 Feb 2015 11:07:52 +0000 (UTC) To: "pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org" , John MacFarlane Original-X-From: pandoc-discuss+bncBCU3VGUM3AGRBBNVXWTAKGQEA5MT73Y-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mon Feb 02 12:07:52 2015 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane.org Original-Received: from mail-ie0-f192.google.com ([209.85.223.192]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YIEr9-0002gZ-69 for gtp-pandoc-discuss@m.gmane.org; Mon, 02 Feb 2015 12:07:51 +0100 Original-Received: by mail-ie0-f192.google.com with SMTP id rd18sf34062951iec.9 for ; Mon, 02 Feb 2015 03:07:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:x-original-sender:x-original-authentication-results :reply-to:precedence:mailing-list:list-id:list-post:list-help :list-archive:sender:list-subscribe:list-unsubscribe; bh=opiah6UPeDFpp6OjBYPfbAj47WboF7RLBwkeStiXzIE=; b=mJbKYZaOOiFJWjZ8So2iK95T4zFbrCuSlkgE4rrSFjdlO76Yj1giGnFi9let90jL8z pDWrMBhmkp4lO0touQSBzXmGxvlVacH+Jgp87ajvtYadqbD4sP34x5NQ94/SG15RLsFV nMwDi0OA4CbCtOu9Ky7BMzMb8t9zpnGRet0RNzTuvSGVEtXiQjaty5dSRvZUDtHFYkV+ 91RuTeBUZeSZVFeYeAQCVRLe+BUbYjK1f/kwZ+a4y20YbyxnHVpMk9wSGYxqBlaSZ4xU P/03ReC78YO20QGg/4f0lTN1E6OcfWeWhHN3gHbftUIi9Vyb5PJ54u8VRmeOY/AGp1kv o5Ww== X-Received: by 10.50.120.98 with SMTP id lb2mr127392igb.4.1422875270435; Mon, 02 Feb 2015 03:07:50 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 10.107.4.144 with SMTP id 138ls1976498ioe.24.gmail; Mon, 02 Feb 2015 03:07:49 -0800 (PST) X-Received: by 10.70.35.177 with SMTP id i17mr16593266pdj.5.1422875269763; Mon, 02 Feb 2015 03:07:49 -0800 (PST) Original-Received: from mail-pa0-x230.google.com (mail-pa0-x230.google.com. [2607:f8b0:400e:c03::230]) by gmr-mx.google.com with ESMTPS id gk4si936274pbb.2.2015.02.02.03.07.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 02 Feb 2015 03:07:49 -0800 (PST) Received-SPF: pass (google.com: domain of gsteemso-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:400e:c03::230 as permitted sender) client-ip=2607:f8b0:400e:c03::230; Original-Received: by mail-pa0-x230.google.com with SMTP id ey11so81224704pad.7 for ; Mon, 02 Feb 2015 03:07:49 -0800 (PST) X-Received: by 10.70.55.228 with SMTP id v4mr28997270pdp.23.1422875269580; Mon, 02 Feb 2015 03:07:49 -0800 (PST) Original-Received: by 10.70.46.196 with HTTP; Mon, 2 Feb 2015 03:07:49 -0800 (PST) In-Reply-To: <20150201184124.GE13226-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org> X-Original-Sender: gsteemso-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of gsteemso-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:400e:c03::230 as permitted sender) smtp.mail=gsteemso-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dkim=pass header.i=@gmail.com; dmarc=pass (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:11903 Archived-At: --089e0158c0f600cd74050e18f74b Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I actually tried that already. Since I have a custom writer, I just needed to have Blockquote() emit
instead of
tags. Alas, in addition to the crippled formats I described earlier, I also publish to real HTML and actually do need real block quotes as well, so I think the =E2=80=9C-> markup <-=E2=80=9D and filtering option is my best bet. Thank you for explaining about the --filter option. I had somehow managed to not see that despite repeatedly scanning through the documentation. On Sunday, 1 February 2015, John MacFarlane wrote: > I think for your purposes (if you don't need blockquotes for another > purpose, which sounds like the case), you could just write a filter that > converts blockquotes to HTML center elements. > > You can write the filter in Haskell or in python, perl, or a number of > other languages with pandoc filter libraries. > > In Haskell it would look something like > > ``` haskell > #!/usr/bin/env runhaskell > import Text.Pandoc.JSON > > main =3D toJSONFilter bqToCenter > where bqToCenter (Just (Format "html")) (BlockQuote bs) =3D > RawBlock (Format "html") "
" : > bs ++ [RawBlock (Format "html") "
" > bqToCenter x =3D [x] > ``` > > (untested). See the pandocfilters library in PyPI for many examples > using the python library, if that's what you prefer. > > To invoke your filter (assuming it's executable and called bqToCenter.hs)= : > > pandoc --filter ./bqToCenter.hs etc. > > > +++ Gordon Steemson [Feb 01 15 00:14 ]: > >> Well, it still seems straightforward enough. These days Unicode is >> available. If someone wants a literal arrow in those positions they can >> use >> a dash other than an ASCII hyphen-minus, or use an angle bracket other >> than >> an ASCII less-than / greater-than, or just break down and use a Unicode >> arrow character directly (several exist to choose from). >> >> I agree with you that centred or right alignment are presentational thin= gs >> (unless you=E2=80=99re trying to write Arabic or Hebrew, in which case l= eft >> alignment is), but I strongly believe that being able to centre somethin= g >> on the page is nevertheless important to conveying meaning in certain >> narrow use cases, in the same way as a hard line break is within a posta= l >> address. I am attempting to use Pandoc to publish my mediocre attempts a= t >> fiction to various online repositories, and in examining the results of = my >> past (pre-Pandoc) efforts, I have come to the conclusion that there is a >> marked difference in effect when some important bit of information is >> placed in the middle of the page, versus as just an unusually short >> paragraph clustered at the left edge with all the others. >> >> I approve in principle of your proposed solution (=E2=80=9Cjust use a = =E2=80=B9div=E2=80=BA >> element >> and style it with CSS=E2=80=9D); unfortunately, several of the submissio= n formats >> I >> am forced to conform to are extremely crippled, and do not support eithe= r >> of those features of HTML. Rephrasing them as some other feature is far >> from simple from within the Lua custom writer. >> >> Short of outputting to a native Haskell representation file, piping that >> to >> a filter program, and piping that result back through a second invocatio= n >> of Pandoc, is there any way of invoking a transformational filter on the >> native AST as it is being processed? I keep seeing various language >> bindings (Perl, Python, PHP, etc.) that appear to be for doing just that= , >> but I can=E2=80=99t find any mention of how you actually invoke a filter= written >> to >> use one of them when you start the Pandoc tool. >> >> On Saturday, 31 January 2015 22:45:48 UTC-8, John MacFarlane wrote: >> >>> >>> +++ Gordon Steemson [Jan 31 15 18:25 ]: >>> >1) If someone, just to be difficult, needs to have literal ASCII arrow= s >>> at >>> >the start and/or end of their actual output text block, can it be >>> >accommodated in a simple way by backslash-escaping? At what stage does >>> that >>> >get stripped out =E2=80=94 before the custom writer functions get call= ed or >>> after? >>> >>> Before. The escaping is resolved in the parser. >>> >>> >> >> 2) What would be involved in modifying the Pandoc markdown parser to >>> >recognize the obvious extension to this syntax, demonstrated below? >>> >>> Well, it would be quite involved. We'd need to modify the Pandoc >>> document model to add these alignment containers (though I suppose >>> we could use Div elements with special classes), then modify the >>> Markdown parser and all the writers. >>> >>> Centering has come up before on this list (you can search for earlier >>> discussions). My general feeling is that pandoc should focus on >>> structural elements of documents, and things like centering and >>> right-aligning are too presentational. >>> >>> Note you can always put things in divs with classes, and format them >>> with CSS in HTML or with a simple filter in other formats. >>> >>> >> -- >> You received this message because you are subscribed to the Google Group= s >> "pandoc-discuss" group. >> To unsubscribe from this group and stop receiving emails from it, send a= n >> 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/ >> msgid/pandoc-discuss/15411876-5ead-405f-b72f-4db72406b9d4% >> 40googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. >> > > -- > You received this message because you are subscribed to a topic in the > Google Groups "pandoc-discuss" group. > To unsubscribe from this topic, visit https://groups.google.com/d/ > topic/pandoc-discuss/NXNm-Vx0Scs/unsubscribe. > To unsubscribe from this group and all its topics, 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/ > msgid/pandoc-discuss/20150201184124.GE13226%40localhost.hsd1.ca.comcast. > net. > For more options, visit https://groups.google.com/d/optout. > --=20 The world=E2=80=99s only gsteemso --=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/CABKoxZovtDmabdtnQRzHcN1o_G0aYjKSW_GAcn6n%2BRBXk8YErw%40mail= .gmail.com. For more options, visit https://groups.google.com/d/optout. --089e0158c0f600cd74050e18f74b Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I actually tried that already. Since I have a custom writer,=C2=A0I just ne= eded to have Blockquote() emit <CENTER> instead of <BLOCKQUOTE>= tags. Alas, in addition to the crippled formats I described earlier, I als= o publish to real HTML and actually do need real block quotes as well, so I= think the =E2=80=9C-> markup <-=E2=80=9D and=C2=A0filtering option i= s my best bet.

Thank you for explaining about=C2=A0the -= -filter option. I had somehow managed to not see that despite repeatedly sc= anning through the documentation.

On Sunday, 1 February 2015, John M= acFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> = wrote:
I think for your purposes (if you = don't need blockquotes for another
purpose, which sounds like the case), you could just write a filter that converts blockquotes to HTML center elements.

You can write the filter in Haskell or in python, perl, or a number of
other languages with pandoc filter libraries.

In Haskell it would look something like

``` haskell
#!/usr/bin/env runhaskell
import Text.Pandoc.JSON

main =3D toJSONFilter bqToCenter
=C2=A0where bqToCenter (Just (Format "html")) (BlockQuote bs) =3D=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0RawBlock (Format "html") "= <center>" :
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0bs ++ [RawBlock (Format "html")= "</center>"
=C2=A0 =C2=A0 =C2=A0 =C2=A0bqToCenter x =3D [x]
```

(untested).=C2=A0 See the pandocfilters library in PyPI for many examples using the python library, if that's what you prefer.

To invoke your filter (assuming it's executable and called bqToCenter.h= s):

=C2=A0 =C2=A0pandoc --filter ./bqToCenter.hs etc.


+++ Gordon Steemson [Feb 01 15 00:14 ]:
Well, it still seems straightforward enough. These days Unicode is
available. If someone wants a literal arrow in those positions they can use=
a dash other than an ASCII hyphen-minus, or use an angle bracket other than=
an ASCII less-than / greater-than, or just break down and use a Unicode
arrow character directly (several exist to choose from).

I agree with you that centred or right alignment are presentational things<= br> (unless you=E2=80=99re trying to write Arabic or Hebrew, in which case left=
alignment is), but I strongly believe that being able to centre something on the page is nevertheless important to conveying meaning in certain
narrow use cases, in the same way as a hard line break is within a postal address. I am attempting to use Pandoc to publish my mediocre attempts at fiction to various online repositories, and in examining the results of my<= br> past (pre-Pandoc) efforts, I have come to the conclusion that there is a marked difference in effect when some important bit of information is
placed in the middle of the page, versus as just an unusually short
paragraph clustered at the left edge with all the others.

I approve in principle of your proposed solution (=E2=80=9Cjust use a =E2= =80=B9div=E2=80=BA element
and style it with CSS=E2=80=9D); unfortunately, several of the submission f= ormats I
am forced to conform to are extremely crippled, and do not support either of those features of HTML. Rephrasing them as some other feature is far
from simple from within the Lua custom writer.

Short of outputting to a native Haskell representation file, piping that to=
a filter program, and piping that result back through a second invocation of Pandoc, is there any way of invoking a transformational filter on the native AST as it is being processed? I keep seeing various language
bindings (Perl, Python, PHP, etc.) that appear to be for doing just that, but I can=E2=80=99t find any mention of how you actually invoke a filter wr= itten to
use one of them when you start the Pandoc tool.

On Saturday, 31 January 2015 22:45:48 UTC-8, John MacFarlane wrote:

+++ Gordon Steemson [Jan 31 15 18:25 ]:
>1) If someone, just to be difficult, needs to have literal ASCII arrows=
at
>the start and/or end of their actual output text block, can it be
>accommodated in a simple way by backslash-escaping? At what stage does<= br> that
>get stripped out =E2=80=94 before the custom writer functions get calle= d or
after?

Before.=C2=A0 The escaping is resolved in the parser.



2) What would be involved in modifying the Pandoc markdown parser to
>recognize the obvious extension to this syntax, demonstrated below?

Well, it would be quite involved.=C2=A0 We'd need to modify the Pandoc<= br> document model to add these alignment containers (though I suppose
we could use Div elements with special classes), then modify the
Markdown parser and all the writers.

Centering has come up before on this list (you can search for earlier
discussions).=C2=A0 My general feeling is that pandoc should focus on
structural elements of documents, and things like centering and
right-aligning are too presentational.

Note you can always put things in divs with classes, and format them
with CSS in HTML or with a simple filter in other formats.


--
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-/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-d= iscuss/15411876-5ead-405f-b72f-4db72406b9d4%40googlegroups.co= m.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Goog= le Groups "pandoc-discuss" group.
To unsubscribe from this topic, visit https://g= roups.google.com/d/topic/pandoc-discuss/NXNm-Vx0Scs/unsubscri= be.
To unsubscribe from this group and all its topics, send an email 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-di= scuss/20150201184124.GE13226%40localhost.hsd1.ca.comcast.<= /u>net.
For more options, visit https://groups.google.com/d/optout.


--
The world=E2=80=99s only gsteemso

--
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://group= s.google.com/d/msgid/pandoc-discuss/CABKoxZovtDmabdtnQRzHcN1o_G0aYjKSW_GAcn= 6n%2BRBXk8YErw%40mail.gmail.com.
For more options, visit http= s://groups.google.com/d/optout.
--089e0158c0f600cd74050e18f74b--