Matt Kraai wrote:
> > BEGIN {
> >         $blosxom::version="is a proper perl module too much to ask?";
> >         do "/usr/bin/markdown";
> > }
> > 
> > Markdown::Markdown($text);
> 
> [I don't know much Perl, so I hope you'll bear with me.]
> 
> You're suggesting that I create a module under /usr/lib/perl somewhere
> with the above code?  What should I call it?  Where should it go?
> What else should I ask?

Sticking that in a perl module would actually work, and is probably the
minimal patch to fix this bug, but it's ugly beyond belief. Note the
disgusting use of $blosxom::version to trick markdown into thinking it's
being run by blosxom, and so behave sorta as a library -- but avoid
actually running any of the blosxom-specific code. Highly implementation
dependent, could break anytime. Which is why I don't like having that
code in my wiki right now..

I've attached a patch that does it a bit more cleanly while still being
minimal enough to maintain if upstream doesn't accept it.

(BTW, your rules file sucks and leaves debian/files behind after
debian/rules clean.)

-- 
see shy jo
diff -ur old/markdown-1.0.1/Markdown.pl markdown-1.0.1/Markdown.pl
--- old/markdown-1.0.1/Markdown.pl      2006-03-10 02:45:27.000000000 -0500
+++ markdown-1.0.1/Markdown.pl  2006-03-10 03:14:26.000000000 -0500
@@ -64,6 +64,9 @@
 # (see _ProcessListItems() for details):
 my $g_list_level = 0;
 
+# Check to see if Markdown.pm has been loaded; if so we must be loaded
+# as a perl module.
+my $g_perl_module = exists $INC{'Markdown.pm'};
 
 #### Blosxom plug-in interface ##########################################
 
@@ -87,8 +90,8 @@
 
 
 #### Movable Type plug-in interface #####################################
-eval {require MT};  # Test to see if we're running in MT.
-unless ($@) {
+eval {require MT} unless $g_perl_module;  # Test to see if we're running in MT.
+unless ($g_perl_module || $@) {
     require MT;
     import  MT;
     require MT::Template::Context;
@@ -178,7 +181,7 @@
                });
        }
 }
-else {
+elsif (! $g_perl_module) {
 #### BBEdit/command-line text filter interface ##########################
 # Needs to be hidden from MT (and Blosxom when running in static mode).
 
@@ -189,7 +192,7 @@
 
                #### Check for command-line switches: #################
                my %cli_opts;
-               use Getopt::Long;
+               eval {use Getopt::Long}; # don't load in library mode
                Getopt::Long::Configure('pass_through');
                GetOptions(\%cli_opts,
                        'version',
@@ -1325,14 +1328,15 @@
 
 =head1 NAME
 
-B<Markdown>
+B<markdown>
 
 
 =head1 SYNOPSIS
 
-B<Markdown.pl> [ B<--html4tags> ] [ B<--version> ] [ B<-shortversion> ]
-    [ I<file> ... ]
+B<markdown> [ B<--html4tags> ] [ B<--version> ] [ B<-shortversion> ] [ I<file> 
... ]
 
+use Markdown;
+$html=Markdown::Markdown($text);
 
 =head1 DESCRIPTION
 
@@ -1355,7 +1359,7 @@
 
 Use "--" to end switch parsing. For example, to open a file named "-z", use:
 
-       Markdown.pl -- -z
+       markdown -- -z
 
 =over 4
 
Only in markdown-1.0.1/debian: files
diff -ur old/markdown-1.0.1/debian/rules markdown-1.0.1/debian/rules
--- old/markdown-1.0.1/debian/rules     2006-03-10 02:45:27.000000000 -0500
+++ markdown-1.0.1/debian/rules 2006-03-10 03:13:06.000000000 -0500
@@ -3,12 +3,16 @@
 binary: binary-indep
 
 binary-indep:
-       install -d debian/tmp/usr/bin
+       install -d debian/tmp/usr/bin debian/tmp/usr/share/perl5
        install Markdown.pl debian/tmp/usr/bin/markdown
+       ln -sf ../../bin/markdown debian/tmp/usr/share/perl5/Markdown.pm
 
-       install -d debian/tmp/usr/share/man/man1
+       install -d debian/tmp/usr/share/man/man1 
+       install -d debian/tmp/usr/share/man/man3
        install -m 644 markdown.1 debian/tmp/usr/share/man/man1/markdown.1
        gzip -9 debian/tmp/usr/share/man/man1/markdown.1
+       ln -sf ../man1/markdown.1.gz \
+               debian/tmp/usr/share/man/man3/Markdown.3.gz
 
        install -d debian/tmp/usr/share/doc/markdown
        install -m 644 debian/changelog \

Attachment: signature.asc
Description: Digital signature

Reply via email to