Plain text publishing with MT.

John Gruber gruber at fedora.net
Thu Mar 25 23:21:08 EST 2004


One of the features I'm adding for b5 is a "raw" mode.

In Movable Type, you can invoke this mode on a per-template basis
like this:

    <$MTMarkdownOptions output="raw"$>

The result of this is that Markdown will not filter your entry at
all; it will pass-through exactly as you wrote it. Thus, you can use
this feature to build plain text pages on your site.

I'm now running this code live on Daring Fireball. Just add a
".text" extension to any of my individual archive URLs, and you'll
get a plain text version of that article. For example:

  <http://daringfireball.net/2004/03/marcia_marcia_markdown.text>  
  <http://daringfireball.net/2004/03/dive_into_markdown.text>  
  <http://daringfireball.net/2004/03/introducing_markdown.text>

The .text files include a little bit more than just the entry body
in raw Markdown format. I also include the entry title, underlined
with just enough `=` characters to match the title length. And I
added a byline and a URL pointing to the permanent URL for the
article.

Here's the entire template I'm using to do this:

* * *

<MTAddRegex name="h1_underline">s{(.+)}{
    $1 . "\n" . ("=" x (length $1));}e
</MTAddRegex><MTAddRegex name="StripExt">s{\.\w+$}{}g</MTAddRegex>
<$MTMarkdownOptions output="raw"$><$MTEntryTitle regex="h1_underline" $>

  By John Gruber  
  <<$MTEntryLink regex='StripExt'$>>  
  <$MTFireballDateline$>


<$MTEntryBody$>
<MTEntryIfExtended>
<$MTEntryMore$>
</MTEntryIfExtended>

* * *

I use Brad Choate's MTRegex plug-in to add the underlines, via a
regex substitution. I also use MTRegex to strip the .php extension
from my regular HTML archive page links -- my pages are written to
disk with .php extension, but I link to them without the extension
and let Apache's content negotiation figure out which file to send.

I'd like to release a few interim releases of Markdown.pl to you
folks on this list. The next publicly announced version with be
called "1.0b5"; the interim builds will be numbered like this:
"1.0b5_1", "1.0b5_2", etc.

-J.G.
 


More information about the Markdown-discuss mailing list