Flat code block syntax

John Gabriele jmg3000 at gmail.com
Tue Dec 4 23:52:05 EST 2007


On Dec 4, 2007 4:29 PM, Thomas Nichols <nichols7 at googlemail.com> wrote:

> Bruce Phillips wrote on 2007/10/11 2:05:

> >> Date: Tue, 09 Oct 2007 22:41:41 -0400

> >> From: Michel Fortin <michel.fortin at michelf.com>

> >>

> >> Here are our options: ... Any opinion? Should we look into non-ASCII

> >> characters too?

> >>

> >> Personally, my preference still goes to tilde.

> >

> > After comparing various characters in a real document, I also prefer

> > the tilde.

> >

> > [snip]

> >

> >>

> >> Here I've followed the planned syntax for adding attributes to

> >> Markdown elements which was discussed some time ago on this list,

> >> where attributes are in braces and class names can be added by

> >> preceding them with a dot. It is still unimplemented in PHP Markdown

> >> Extra, but I think Markuru has most of it. I think it's better to

> >> reuse that than to create an entirely new syntax for the same purpose.

> >

> [snip]

>

> I've been using the ~~~ syntax for marking code blocks for a few weeks,

> and it's certainly an improvement over the existing four-space indent.

>

> [snip]

>

> This is the approach that the Trac wiki syntax takes, using

>

> {{{

> chunk of code here

> }}}

>

> Is there any enthusiasm are doing something similar for the proposed

> Markdown extension syntax? Or will this cause conflicts (for example,

> with Maruku's metadata syntax, or maybe with Pandoc)? I'm not too

> concerned about the specific characters selected; perhaps

>

> {~~~~

> code

> ~~~~}

>

> or

>

> <~~~~

> code

> ~~~~>

>

> might cause fewer conflicts but remain easy to read.

>

> Does anyone else feel that separate begin-block and end-block markers

> would, in this rather special case where it is expected that the content

> will be output verbatim, be an improvement?

>


I tend to like:

---{code}---
code goes here
and here too
---{/code}---

Maybe also even with an option syntax for specifying what sort of code
is present:

---{code:perl}---
while (<>) {
next if m/^#/;
# ...
}
---{/code}---

I think it's good because:

* Having different start and stop marks (each on lines of their own)
seems easier to read (for humans, but also for regexen too, I suppose)
than using the same mark for both.

* I could definitely see using it in an email to someone. (Actually, I
think I have used it in the past (without the ":option" extra bit),
but didn't really think anything of it at the time.)

* It looks good, IMO. The dashes line up nicely with the little nubs
on the braces. :) And tilde's are a little too high up in some fonts.

* Most everyone putting a block of code in a document probably knows
that if "foo" starts something, then "/foo" ends it. If not, it's a
pretty simple rule to pick up.

* Regarding the possible option for specifying what type of code the
snippet contains, the colon looks like what it means.

* The markup could possibly even be used as a special case of a more
general `---{something}---` markup, for example:

---{table:border="1"}---

|| food || color || taste ||

| apricot | orange | fruity |

| pepper | red | zingy |

| olive | green | olivey |

---{/table}---

The triple brace notation would seem to work well, and it's helpful
that some wiki's are currently using it, but isn't very pretty to look
at.

---John


More information about the Markdown-Discuss mailing list