The Web forum of this mailing list uses a custom text-to-HTML parser which begins with Michel Fortin’s PHP Markdown Extra parser, combined with some custom regular expressions which I have written over the years, to convert code into readable HTML. I interact with this list almost exclusively through e-mail, and I labored long and hard when I built the Web interface to make sure that Web and e-mail were equal citizens in every respect.
Any time you want to make a block of HTML, all you need to do is type four tildes (~) in a row on a single line, follow it by a return, then start typing your code. When you’re done, add a final line of tildes, and you have created what’s called a “fenced” code block in the extended form of Markdown[1] that we use here.
If your example is simpler, say if each line of code is less than 40 characters or so, then you can also do the same thing by prefixing each line of your code example with four or more spaces. Four spaces signals that the rest of the line is a code block. If more than one line in a row begins with four spaces, then they are treated as a contiguous code block. You break out of such a block by adding two returns after the last line.
Finally, if you just want to put a few words inline in a paragraph, and still ensure that the quotation marks aren’t “curled” or the code-specific meaning isn’t lost entirely, then fencing off that word or phrase with back-tick symbols ( -- the character that shares a keycap with the tilde on the US-English keyboard of the Mac) that phrase will become an inline code example, like this:print $foo;`.
There are lots of other niceties in the Markdown language, which is designed to read like text that has been marked up as you might when signaling various forms of emphasis in a plain-text e-mail message. Two asterisks on either side of a word make it bold, an underscore on either side of a word makes it italic, etc.
Finally, I have also incorporated support for Gist and Pastie, for more complex code examples. If you visit either of those services (https://gist.github.com or http://pastie.org) and create a page, you can paste the URL of that page here (all by itself on one line) to have the entire code example injected into the body of the message on the Web. If you use Gist, there are different color-enhanced formats available for each form of code. This syntax highlighting is a feature of most professional coding applications, and anyone used to those will appreciate the subtleties of the code and be able to read it more quickly as a result.
Hope this helps,
Walter
1
On Sep 23, 2013, at 10:12 AM, WildCottage wrote:
Hi Walter
Thanks for the info. Something to look out for.
As an aside, how did you add the ‘script box’ [for want of a better description!] to your reply? I know lots of folk on this list show their scripts, but I’ve never understood how to add these.
Many thanks,
Andy
freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options
freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options