public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* syntax for generic spans and divs
@ 2013-08-14 17:46 John MacFarlane
       [not found] ` <20130814174642.GA28736-nFAEphtLEs+AA6luYCgp0U1S2cYJDpTV9nwVQlTi/Pw@public.gmane.org>
  0 siblings, 1 reply; 39+ messages in thread
From: John MacFarlane @ 2013-08-14 17:46 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

I've finally added a generic Div and Span element to pandoc, to which
attributes may be added.  Most of the writers just treat these
transparently, printing their contents (though in HTML span and div
containers are used).

I'd like to introduce a markdown syntax for these.  Together with the
new scripting capabilities, this will make pandoc markdown very
easy to customize and extend.  The question is what syntax to use.


1. SPANS

For inline spans, I think the best approach is to use the bracket
containers currently used for link labels and image alt text:

    [this is a *span*, which can contain [links](/url) and
    other inline elements]{#id .class key="value"}

The attribute syntax would be the same as currently in code blocks
and headers.  An attribute block would be required, but could be
empty:

    [plain span]{}


2. DIVS

For block containers (div), I have a number of ideas, and I'm not sure
what is best.  So I'd be curious to get feedback, though I don't expect
convergence.

There are three general approaches:  side-marking (as with markdown block
quotes), surround-marking (as with fenced code blocks), and indented
block (as with lists and footnotes).


2.1 SIDE-MARKING

The simplest side-marking approach would be just to use the current
blockquote syntax.  A block quote beginning with attributes
would be marked up as a generic div rather than a block quote:

    Blah blah blah.

    > {.TIP}
    >
    > # Don't use closed-source tools!
    >
    > You can't change them and you can't count on them
    > being around in the future.

    More regular text.

One advantage of this approach would be that it would degrade gracefully
in standard markdown parsers that don't support this syntax extension.
The "tip" above would render as a block quote with some funny stuff
at the beginning.  Existing syntax highlighting would also work.

An alternative would be to introduce a side-marking syntax that works
like block quotes, but with a different symbol.  The best choices
choices would be period (.) and exclamation mark (!).  (None of these
would occur at the beginning of the line, followed by a space, in
regular text.  And none would be confused with other markdown syntax.)

    Blah blah blah.

    . {.TIP}
    .
    . # Don't use closed-source tools!
    .
    . You can't change them and you can't count on them
    . being around in the future.

    More regular text.  Blah blah blah.

    ! {.TIP}
    !
    ! # Don't use closed-source tools!
    !
    ! You can't change them and you can't count on them
    ! being around in the future.

    More regular text.

I think I like the exclamation mark version best.


2.2 SURROUND-MARKING

The second approach is a surround-marking approach.  It would work like
fenced code blocks, with nesting handled by the rule that a block is
closed by a line at least as long as the one that started the block.
There are many possibilities here.

    We could use underline:

    __________________________________________ {.TIP}
    # Don't use closed-source tools!

    You can't change them and you can't count on them
    being around in the future.
    __________________________________________________

    The low position on the line looks a bit bad, though.
    Or colons:

    :::::::::::::::::::::::::::::::::::::::::: {.TIP}
    # Don't use closed-source tools!

    You can't change them and you can't count on them
    being around in the future.
    ::::::::::::::::::::::::::::::::::::::::::::::::::

    Or periods:

    .......................................... {.TIP}
    # Don't use closed-source tools.

    You can't change them and you can't count on them
    being around in the future.
    ..................................................

    In addition, the attribute could be allowed to occur
    inside the block:

    _________________________________________________
    {.TIP}
    # Don't use closed-source tools!

    You can't change them and you can't count on them
    being around in the future.
    __________________________________________________

    And maybe we'd want to allow a bare word to count
    as a class attribute, as with github-style fenced
    code blocks:

    .......................................... TIP
    # Don't use closed-source tools.

    You can't change them and you can't count on them
    being around in the future.
    ..................................................

    Perhaps it should even be allowed in the middle:

    .......................................... TIP ...
    # Don't use closed-source tools.

    You can't change them and you can't count on them
    being around in the future.
    ..................................................

I think a case can be made that the side-marking approach is
more markdownish, since it just follows an existing markdown
block-container (block quotes).  Delimited blocks make sense
for code, since you want it to be easy to cut and paste, but
less so for regular text.  But arguably the surround-marking
approach is easier to read and write.

One could also allow several different symbols to be used
(say, period, colon, exclamation mark, underline), and store
the symbol used in the attributes.  So the last example above
would be parsed as a Div with class "TIP" and symbol=".".
This would allow scripts to treat differently-delimited blocks
differently, so that authors could avoid using explicit
attributes to distinguish (say) sidebars from tips.  The same
goes for the side-marking proposal.


2.3 INDENTED BLOCKS

One idea (which would also degrade gracefully) would be to overload
existing bullet list syntax.  A bullet list item starting with an
attribute block would be treated as a div.

    Blah blah blah.

    *   {.TIP}

        # Don't use closed-source tools!

        You can't change them and you can't count on them
        being around in the future.

    More regular text.  Blah blah blah.

The nice thing about this is that it would display as a regular
bullet list item (which is a block container after all) in
"regular" markdown processors, which wouldn't look too bad
(whereas the side-marking and surround approaches with special
symbols would just be a mess).

Alternatively, one could overload definition list syntax:

    Blah blah blah.

    {.TIP}
    :   # Don't use closed-source tools!

        You can't change them and you can't count on them
        being around in the future.

    More regular text.  Blah blah blah.

Or one could avoid confusion with existing syntax by using a
special marker:

    Blah blah blah.

    !   {.TIP}

        # Don't use closed-source tools!

        You can't change them and you can't count on them
        being around in the future.

    More regular text.  Blah blah blah.

Or one could require no marker, letting the attributes itself
do the work:

    Blah blah blah.

    {.TIP}

        # Don't use closed-source tools!

        You can't change them and you can't count on them
        being around in the future.

    More regular text.  Blah blah blah.

These last two options would not degrade as well.

I'm eager to hear thoughts about these proposals.

John


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

end of thread, other threads:[~2014-12-13  0:06 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-14 17:46 syntax for generic spans and divs John MacFarlane
     [not found] ` <20130814174642.GA28736-nFAEphtLEs+AA6luYCgp0U1S2cYJDpTV9nwVQlTi/Pw@public.gmane.org>
2013-08-14 18:00   ` Joseph Reagle
2013-08-14 18:31   ` Daniel Staal
2013-08-14 18:46     ` Joseph Reagle
     [not found]       ` <520BD095.9060902-T1oY19WcHSwdnm+yROfE0A@public.gmane.org>
2013-08-14 20:22         ` Shahbaz Youssefi
     [not found]           ` <CALeOzZ8+NZTr4BdLjuachvie24wkpDyfAWYazUy5=pZTR7Y5rg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-08-15  3:16             ` John MacFarlane
     [not found]               ` <20130815031601.GB13193-9Rnp8PDaXcadBw3G0RLmbRFnWt+6NQIA@public.gmane.org>
2013-08-15  4:58                 ` Daniel Staal
2013-08-19 11:13                   ` Jesse Rosenthal
     [not found]                     ` <871u5q9bnl.fsf-4GNroTWusrE@public.gmane.org>
2013-08-19 14:31                       ` John Gabriele
     [not found]                         ` <CAO9PwMVhb6=wXGobJW-6qsMH10_zzaNKChxAYdbBeH8AVsMTag-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-08-19 16:16                           ` Daniel Staal
2013-08-15 13:42                 ` Shahbaz Youssefi
     [not found]                   ` <CALeOzZ9PU7F199tJvCw2HRodP71-oQA_aDSLC+_CHa--_0aJdg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-08-15 14:18                     ` John MacFarlane
2013-08-15  6:56   ` Dirk Laurie
     [not found]     ` <CABcj=tnKj5eUbngA=opxVmuZNT2czgjpszs8EYVsPQh+QpMrTg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-08-15 14:24       ` John MacFarlane
     [not found]         ` <20130815142443.GC17742-9Rnp8PDaXcadBw3G0RLmbRFnWt+6NQIA@public.gmane.org>
2013-08-15 17:54           ` Dirk Laurie
     [not found]             ` <CABcj=t=V6CBmyVaZM4GuHAcV1HRz3OzLH5ApoE7JDb=PLybHsw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-08-15 18:43               ` John MacFarlane
     [not found]                 ` <20130815184352.GD3394-0VdLhd/A9Pm0ooXD8Eul3adDtQfY2H3paxvHy9gZ5WyVc3sceRu5cw@public.gmane.org>
2013-08-16  2:22                   ` Dirk Laurie
     [not found]                     ` <CABcj=tnyLnmhK6m1bhwk0FeqTf5sZfvtXExOxTpFefBPfcqb0A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-08-16  3:14                       ` John MacFarlane
     [not found]                         ` <20130816031415.GB18153-9Rnp8PDaXcadBw3G0RLmbRFnWt+6NQIA@public.gmane.org>
2013-08-16  5:08                           ` Dirk Laurie
2013-08-15 14:24   ` John Gabriele
     [not found]     ` <CAO9PwMXmsEJhW_pKpb_9pQqRHxM1RHhhm2Widgdqyc1OvU4bnQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-08-15 14:44       ` BP Jonsson
2013-08-15 15:41       ` John MacFarlane
     [not found]         ` <20130815154144.GB17824-9Rnp8PDaXcadBw3G0RLmbRFnWt+6NQIA@public.gmane.org>
2013-08-15 17:08           ` John Gabriele
2013-08-16  9:38   ` Gilles Pérez
     [not found]     ` <520DF300.7030807-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-08-17 14:44       ` David Sanson
     [not found]         ` <35fe9b44-eb55-4b24-ad68-c958718684e7-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2013-08-19  7:14           ` Matthias Hüning
     [not found]             ` <569131ac-aae7-4237-9745-133133ce72f5-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2013-08-19 17:13               ` John MacFarlane
     [not found]                 ` <20130819171309.GI563-0VdLhd/A9Pm0ooXD8Eul3adDtQfY2H3paxvHy9gZ5WyVc3sceRu5cw@public.gmane.org>
2013-08-19 18:06                   ` Nick Moffitt
     [not found]                     ` <20130819180634.GB24194-iTLVOByc1N8@public.gmane.org>
2013-08-19 23:06                       ` John MacFarlane
2013-08-24 15:47                   ` BP Jonsson
     [not found]                     ` <5218D585.20702-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-08-25 14:23                       ` John MacFarlane
2013-08-18 13:37   ` Bernhard Weichel
2013-08-19 14:27   ` Pablo Rodríguez
2014-10-29 20:43   ` mb21
     [not found]     ` <381057ba-1977-4ae5-8fe7-efc880e7aa4b-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2014-11-02 16:16       ` mb21
     [not found]         ` <3c0e9819-64b6-485c-ba43-2ad1cf092435-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2014-12-07 12:09           ` Matthew Pickering
     [not found]             ` <01312d37-bd7d-4d61-958d-c04f6d709e4a-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2014-12-08 11:01               ` Bernhard Weichel
     [not found]                 ` <f8ed3b3c-5ed0-4edc-847d-5100314cbc2f-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2014-12-09 19:28                   ` Daniel Staal
     [not found]                 ` <F9A02579C87697FEFF7442EA@192.168.1.50>
     [not found]                   ` <F9A02579C87697FEFF7442EA-Q0ErXNX1RuZz+/J76PBWHg@public.gmane.org>
2014-12-13  0:06                     ` BPJ

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).