« Installing Windows 3.1 in VMWare | Main | Packaging and Shipping eBay Items. »

February 26, 2008

Markdown and flickrnotes

Markdown makes writing in Movable Type painless and makes embedding flickr images relatively easy, but together, they make embedding flickr images completely painless.

I won't go into how to install both packages, so go make them both work, then come back.

I use the format %(flick-image-number) to engage flickrnotes from within markdown. To do this: open your Markdown.pl file (usually in the movable type plugin directory). Scroll down to sub _DoImages {. At the very end of the subroutine insert the following code (you will need to change the path to flickrnotes from /script/flickrnotes.php:

# Next, handle inline flickr images:  %(flickr_image_number)

$text =~ s{
    (               # wrap whole match in $1
      %\(           # literal paren
        [ \t]*
        <?(\S+?)>?  # src url = $2
        [ \t]*
      \)
    )
}{
    my $result;
    my $whole_match = $1;
    my $url         = $2;

    $result = "<script src=\"/script/flickrnotes.php?$url\"></script>";

    $result;
}xsge;

Alternately, you can download my pre-modified Markdown.pl file and simply replace your existing one.

Now try it out. Before markdown, linking to flickr was something like this: <a href="http://flickr.com/photos/spiffed/2283833703/"><img src="http://farm3.static.flickr.com/2362/2283833703_bd86b1477c.jpg?v=0">.

After markdown, it looked something like this: [![](http://farm3.static.flickr.com/2362/2283833703_bd86b1477c.jpg?v=0)](http://flickr.com/photos/spiffed/2283833703/)

With flickrnotes, it looked something like: <script src="/script/flickrnotes/?2283833703"></script>

Now it just looks like this:

 %(2283833703)

Posted by spiffed at February 26, 2008 1:30 PM

Comments

Post a comment