{"id":153,"date":"2004-03-18T05:38:00","date_gmt":"2004-03-18T05:38:00","guid":{"rendered":"http:\/\/jclark.org\/weblog\/WebDev\/Blosxom\/Markdownredux.html"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-30T04:00:00","slug":"Markdownredux","status":"publish","type":"post","link":"https:\/\/jclark.org\/weblog\/2004\/03\/18\/Markdownredux\/","title":{"rendered":"Markdown Redux"},"content":{"rendered":"<p>As I&#8217;ve mentioned <a href=\"http:\/\/jclark.org\/weblog\/WebDev\/Blosxom\/Markdown.html\">previously<\/a>, I&#8217;ve recently started using <a href=\"http:\/\/daringfireball.net\/projects\/markdown\/\" title=\"Markdown Project Page at Daringfireball.net\">Markdown<\/a> to format my blog entries.  After using it for a few posts, I honestly think it&#8217;s lowered the &#8220;friction&#8221; it takes to compose an entry.  When I first saw it, my immediate reaction was, &#8220;Why?  We already have <a href=\"http:\/\/textism.com\/tools\/textile\/\">Textile<\/a>.&#8221;  However, Textile is a tool to &#8220;mark up&#8221; plain text to be formatted as (x)html, where Markdown is a tool to render plain text as (x)html.  In other words, Markdown strives to remove the need to insert markup; instead it uses existing plain text idioms, especially from email.  It doesn&#8217;t have as many features as Textile, but it has all the features I use.  It also handles certain things much more easily; I&#8217;m not sure I ever figured out how to mark up multi-paragraph blockquotes in Textile.<\/p>\n<p>The <a href=\"http:\/\/blosxom.com\">Blosxom<\/a> interface in the current beta releases (1-3) apply markdown formatting to every post.  In my <a href=\"http:\/\/jclark.org\/weblog\/WebDev\/Blosxom\/Markdown.html\">previous post<\/a> on Markdown, I offered a updated version that used the Blosxom meta plugin and a &#8220;meta-markup&#8221; header to enable Markdown on a per post basis.  <a href=\"http:\/\/daringfireball.net\">John Gruber<\/a>, author of Markdown, stated on the Markdown mailing list that he&#8217;d rather make this behavior optional.  I agreed, and have produced version 2 of my Markdown-Blosxom patch:<\/p>\n<p><strong>Update 3-25-04:<\/strong>  John Gruber has released Beta 4 of Markdown, which incorporates (and improves) these changes.  The code patch below is now deprecated; <a href=\"http:\/\/daringfireball.net\/projects\/markdown\/\" title=\"Markdown Project Page at Daringfireball.net\">go grab<\/a> a new (post-beta-3) copy of Markdown. :<\/p>\n<pre><code>#### Blosxom plug-in interface ##########################################\n\n# Change $blosxom_always to 0 to use &quot;meta-markup: markdown&quot; story\n# headers to enable Markdown on a per-story basis\nmy $blosxom_always = 1;\n\n#don&#039;t change; auto-detects\nmy $blosxom_hasmeta;\n\nsub start { 1; }\nsub filter {\n    $blosxom_hasmeta = defined(%meta::);\n    1;\n}\nsub story {\n    my($pkg, $path, $filename, $story_ref, $title_ref, $body_ref) = @_;\n\n     if ($blosxom_always or \n         ($blosxom_hasmeta and \n          defined($meta::markup) and \n          $meta::markup =~ \/^\\s*markdown\\s*$\/i))  {\n        $$body_ref  = Markdown($$body_ref);\n    }\n    1;\n}<\/code><\/pre>\n<p>Notes:<\/p>\n<ul>\n<li>\n<p>Install is as before.  Replace the existing Blosxom plug-in interface with the code above; remember to rename <code>Markdown.pl<\/code> to <code>Markdown<\/code> when you put it in your plugins directory. <\/p>\n<\/li>\n<li>\n<p>By default, it will always apply Markdown (as it was originally).  Even if the Meta plugin is present, we can&#8217;t assume the user wants to use it to control Markdown.  If you want to use meta-markup, set $blosxom_always to 0.<\/p>\n<\/li>\n<li>\n<p>I check for the presence of meta instead of assuming it&#8217;s avilable.  If blosxom_always is 0, but meta plugin is not available, Markdown will never be invoked.<\/p>\n<\/li>\n<li>\n<p>the check for meta occurs in blosxom interface&#8217;s filter() method.  start() is a poor choice because Markdown could be loaded before meta (and will be by default, which is alphabetical).  filter() will run for every plugin after all plugins are loaded.<\/p>\n<\/li>\n<\/ul>\n<p><strong>Updates:<\/strong><\/p>\n<ul>\n<li>\n<p>the meta-markup check is now a case insensitive regex.<\/p>\n<\/li>\n<li>\n<p>No longer applying markdown processing to the story title.  This was causing `<\/p>\n<p>` tags wrapped around the title, which is not appropriate in places like RSS feeds. <\/p>\n<\/li>\n<\/ul>\n<p><strong>Second Update:<\/strong><\/p>\n<ul>\n<li>Astute reader <a href=\"http:\/\/ofb.net\/~andrewc\/serenepia\/\">ArC<\/a> points out that if you are using meta but a post has no <code>meta-markup<\/code> in the header, the check of <code>$meta::markup<\/code> would cause perl to complain.  I&#8217;ve added a <code>defined($meta::markup)<\/code> test.<\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>As I&#8217;ve mentioned previously, I&#8217;ve recently started using Markdown to format my blog entries. After using it for a few posts, I honestly think it&#8217;s lowered the &#8220;friction&#8221; it takes to compose an entry. When I first saw it, my immediate reaction was, &#8220;Why? We already have Textile.&#8221; However, Textile is a tool to &#8220;mark [&hellip;]<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-153","post","type-post","status-publish","format-standard","hentry","category-blosxom"],"_links":{"self":[{"href":"https:\/\/jclark.org\/weblog\/wp-json\/wp\/v2\/posts\/153","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jclark.org\/weblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jclark.org\/weblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jclark.org\/weblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jclark.org\/weblog\/wp-json\/wp\/v2\/comments?post=153"}],"version-history":[{"count":0,"href":"https:\/\/jclark.org\/weblog\/wp-json\/wp\/v2\/posts\/153\/revisions"}],"wp:attachment":[{"href":"https:\/\/jclark.org\/weblog\/wp-json\/wp\/v2\/media?parent=153"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jclark.org\/weblog\/wp-json\/wp\/v2\/categories?post=153"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jclark.org\/weblog\/wp-json\/wp\/v2\/tags?post=153"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}