public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Idea: Support for centred block-level elements, without necessarily needing to revise pandoc
@ 2015-02-01  2:25 Gordon Steemson
       [not found] ` <2a08b6a8-d381-45bc-9361-3bf402544fb0-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Gordon Steemson @ 2015-02-01  2:25 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


[-- Attachment #1.1: Type: text/plain, Size: 3198 bytes --]

When I began switching over to Pandoc a couple of months ago, I searched 
extensively for some way to specify centred text in Markdown, and found a 
syntax extension that numerous end-users advocate, but no tool I know of 
supports:

>
> Basically, the Markdown text (potentially contained
> within some larger construct) is bracketed with little
> ASCII-art arrows, like so:
>
> -> This paragraph
> is centred. <-
>
> ### -> This level-3 heading is centred. <- ###
>
> -> This level-1 heading is centred. <-
> ======================================
>

As I said, numerous people online claim this works, but I have yet to 
encounter any software that actually supports it.

It seems simple enough in principle for us end-using peons to support, at 
least when using a custom writer. It appears that any kind of text that 
might qualify for this treatment will be passed to one of Para() or 
Header(), which can then special-case based on finding or not finding 
literal ASCII-art arrows at the beginning and end of the given string 
argument. I conjecture that it might also turn up in Plain(), but I haven’t 
yet figured out just what circumstance causes that function to get called.

There are two obvious questions here that Mr. MacFarlane or someone equally 
“dialled in” to the Pandoc project can save a lot of trial and error by 
answering:

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 that 
get stripped out — before the custom writer functions get called or after?

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

-> This text should
-> be right-aligned
-> in output formats
-> that support that,
-> without being
-> mistaken for a
-> block quote.

While I’m on the subject…

-> Right-alignment
->   and centering
->    should also…

->   …work with
     irregular
    margins, for
  obvious reasons. <-

If it simplifies anything, I find it difficult to envision a circumstance 
where someone might need a centred or right-aligned block quotation (the 
closest I can come is where someone’s abusing HTML blockquotes to get a 
narrower canvas for part of the document), so the two notations can easily 
be defined as mutually exclusive — a good thing, as it would likely look 
terrible in the original formatting, thus violating a key design goal of 
Markdown.

-- 
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/msgid/pandoc-discuss/2a08b6a8-d381-45bc-9361-3bf402544fb0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 7282 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Idea: Support for centred block-level elements, without necessarily needing to revise pandoc
       [not found] ` <2a08b6a8-d381-45bc-9361-3bf402544fb0-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2015-02-01  6:45   ` John MacFarlane
       [not found]     ` <20150201064534.GB12964-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: John MacFarlane @ 2015-02-01  6:45 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

+++ 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 that
>get stripped out — before the custom writer functions get called 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 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/msgid/pandoc-discuss/20150201064534.GB12964%40localhost.hsd1.ca.comcast.net.
For more options, visit https://groups.google.com/d/optout.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Idea: Support for centred block-level elements, without necessarily needing to revise pandoc
       [not found]     ` <20150201064534.GB12964-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
@ 2015-02-01  8:14       ` Gordon Steemson
       [not found]         ` <15411876-5ead-405f-b72f-4db72406b9d4-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Gordon Steemson @ 2015-02-01  8:14 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


[-- Attachment #1.1: Type: text/plain, Size: 3917 bytes --]

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 
(unless you’re 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 
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 (“just use a ‹div› element 
and style it with CSS”); unfortunately, several of the submission formats 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’t 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 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 
> that 
> >get stripped out — before the custom writer functions get called 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 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/msgid/pandoc-discuss/15411876-5ead-405f-b72f-4db72406b9d4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 4839 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Idea: Support for centred block-level elements, without necessarily needing to revise pandoc
       [not found]         ` <15411876-5ead-405f-b72f-4db72406b9d4-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2015-02-01 18:41           ` John MacFarlane
       [not found]             ` <20150201184124.GE13226-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: John MacFarlane @ 2015-02-01 18:41 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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 = toJSONFilter bqToCenter
  where bqToCenter (Just (Format "html")) (BlockQuote bs) =
          RawBlock (Format "html") "<center>" :
          bs ++ [RawBlock (Format "html") "</center>"
        bqToCenter x = [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 things
>(unless you’re 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
>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 (“just use a ‹div› element
>and style it with CSS”); unfortunately, several of the submission formats 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’t 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 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
>> that
>> >get stripped out — before the custom writer functions get called 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 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/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 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/msgid/pandoc-discuss/20150201184124.GE13226%40localhost.hsd1.ca.comcast.net.
For more options, visit https://groups.google.com/d/optout.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Idea: Support for centred block-level elements, without necessarily needing to revise pandoc
       [not found]             ` <20150201184124.GE13226-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
@ 2015-02-02 11:07               ` Gordon Steemson
  0 siblings, 0 replies; 5+ messages in thread
From: Gordon Steemson @ 2015-02-02 11:07 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw, John MacFarlane

[-- Attachment #1: Type: text/plain, Size: 7051 bytes --]

I actually tried that already. Since I have a custom writer, I just needed
to have Blockquote() emit <CENTER> instead of <BLOCKQUOTE> 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
“-> markup <-” 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 <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 = toJSONFilter bqToCenter
>  where bqToCenter (Just (Format "html")) (BlockQuote bs) =
>          RawBlock (Format "html") "<center>" :
>          bs ++ [RawBlock (Format "html") "</center>"
>        bqToCenter x = [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 things
>> (unless you’re 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
>> 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 (“just use a ‹div›
>> element
>> and style it with CSS”); unfortunately, several of the submission formats
>> 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’t 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 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
>>> that
>>> >get stripped out — before the custom writer functions get called 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 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/
>> 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.
>


-- 
The world’s only gsteemso

-- 
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/msgid/pandoc-discuss/CABKoxZovtDmabdtnQRzHcN1o_G0aYjKSW_GAcn6n%2BRBXk8YErw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #2: Type: text/html, Size: 8815 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-02-02 11:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-01  2:25 Idea: Support for centred block-level elements, without necessarily needing to revise pandoc Gordon Steemson
     [not found] ` <2a08b6a8-d381-45bc-9361-3bf402544fb0-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-02-01  6:45   ` John MacFarlane
     [not found]     ` <20150201064534.GB12964-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
2015-02-01  8:14       ` Gordon Steemson
     [not found]         ` <15411876-5ead-405f-b72f-4db72406b9d4-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-02-01 18:41           ` John MacFarlane
     [not found]             ` <20150201184124.GE13226-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
2015-02-02 11:07               ` Gordon Steemson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).