Wee blosxom bug in markdown.pl

Stu MacKenzie s2_mac at yahoo.com
Tue Dec 21 20:04:10 EST 2004


Howdy, Markdownians;

Writing to you about a small glitch in Markdown's behavior with
blosxom. Near the top of the markdown() sub, these two lines
"Standardize line endings:"
        $text =~ s{\r\n}{\n}g;  # DOS to Unix
        $text =~ s{\r}{\n}g;    # Mac to Unix

Good intentions, but this won't touch any returns in blosxom
entries; adding a couple of lines in the story() sub will fix
it. (Not to worry, we can lay the blame entirely on Rael ;-)

When blosxom reads entry files, it assumes that lines are
delimited by newlines, with this code:
    chomp($title = <$fh>);
    chomp($body = join '', <$fh>);
As you can see, if the file is delimited with returns, its
entire contents wind up in $title, and $body gets nothing. Thus
-- in the case of "Mac-formatted" entries -- when Markdown's
story() sub hands off $$body_ref to the markdown() sub, nothing
is being passed; wups.

To fix, the story() sub should look something like this:
sub story {
  my($pkg, $path, $filename, $story_ref, $title_ref, $body_ref)
= @_;
  if (
    (! $g_blosxom_use_meta) or
    (defined($meta::markup) and 
    ($meta::markup =~ /^\s*markdown\s*$/i))
  ){
    if ($$title_ref =~ s/\r/\n/) {
      ($$title_ref, my $temp) = split /\n/, $$title_ref, 2;
      $$body_ref = $temp . $$body_ref;
    }
    $$body_ref  = Markdown($$body_ref);
  }
  1;
}

Sorry to be so late in reporting this glitch. I've been writing
to 
John about it since news of the early betas hit the blosxom
list
(my wups); only found out about this Markdown list today.

Seizure later,
S2


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - 250MB free storage. Do more. Manage less. 
http://info.mail.yahoo.com/mail_250


More information about the Markdown-Discuss mailing list