Tim Bunce wrote:
> I was hoping that it would output an html file. One that would include the
> TiddlyWiki code.
>
> If you'd rather not add a 272KB file to your distribution (which I'd
> fully understand) then perhaps the best approach would be a separate
> distribution containing a Pod::Simple::Wiki::TiddlywikiHTML module.
> That would subclass Pod::Simple::Wiki::Tiddlywiki and add the
> TiddlyWiki code.
>   
Hi,

Maybe converting to a tiddler for importing into the TiddlyWiki might be 
a better approach, see below. I may add it as an additional pod2wiki 
commandline option combined with some documentation.

> Meanwhile I've been puzzling over how to get the tiddlers generated by
> pod2wiki into a TiddlyWiki. It seems like this sequence ought to work:
>
>  - Download http://www.tiddlywiki.com/empty.html to a file
>     as per http://tiddlywiki.com/#DownloadSoftware
>  - Open the file:///path/to/your/empty.html
>  - Click on Backstage (in top righthand corner) then click on Import.
>  - Choose the file generated by pod2wiki
>  - Click Open.
>
> but sadly it doesn't work on either Safari or Firefox (though Firefox
> does seem to get slightly further). Any ideas?
>   

I tried that initially as well but eventually gave up and just copied 
and pasted in the things I needed to test. The fact that you had the 
same problem prompted me to dig a little deeper. :-)

I browsed the TiddlyWiki Google group and saw that the TiddlyWiki app 
expects to import another TiddlyWiki html file. From there I was able to 
isolate the actual section that it is looking for, which is: div 
id="storeArea".

 From that I created a quick and dirty filter to convert from the wiki 
text format to a self contained Tiddler, see below.

You can run it as follows:

  $ pod2wiki --style=tiddlywiki DBI.pm | perl wiki2tiddler.pl 
--title="DBI Docs" --author="Tim Bunce" > dbi.html

Program follows:


#!/usr/bin/perl -w

#######################################################################
#
# wiki2tiddler.pl - A utility to convert TiddlyWiki text to Tiddlers.
#
# Convert TiddlyWiki text to a Tiddler so that it can be imported into
# a wiki. The Tiddler is basically a html encoded block of TiddlyWiki
# text wrapped in some div sections.
#
#
# usage:
#       perl wiki2tiddler.pl wiki.txt > wiki.html
#       perl wiki2tiddler.pl --title="Title" --author="Iam Author" ...
#
# --title  -t : optional title. Defaults to "Imported Pod file".
# --author -a : option author. Defaults to "pos2wiki".
#
#
# Usage in conjunction with pod2wiki:
#
#       pod2wiki --style=tiddlywiki Foo.pm |
#          perl wiki2tiddler.pl --title="Foo Docs" > foo.html
#
# reverse('©'), August 2007, John McNamara, [EMAIL PROTECTED]
#


use strict;
use HTML::Entities;
use Getopt::Long; # Should use Pod::Usage as well.


# Some default data to identify the tiddler in TiddlyWiki.
my $title   = 'Imported Pod file';
my $author  = 'generated by pod2wiki';


# Override the defaults with command line options.
GetOptions(
            'title|t=s'     => \$title,
            'author|a=s'    => \$author,
          );


# Set the creation date and time of the tiddler.
my ($sec,$min,$hour,$mday,$mon,$year) = localtime();

my $date = sprintf "%d%02d%02d%02d%02d", 1900 + $year,
                                         $mon + 1,
                                         $mday,
                                         $hour,
                                         $min;


#
# Create the tiddler using a small bit of hard coded html.
#

# Print the html div section to indicate a tiddler.
print << "HEADER";
<div id="storeArea">
<div title="$title" modifier="$author" created="$date" changecount="1">
<pre>
HEADER


# Insert TiddlyWiki text while encoding any html entities.
while (<>) {
    print encode_entities($_);
}


# Print the html end section.
print << 'FOOTER';
</pre>
</div>
</div>
FOOTER


__END__


John.
-- 

Reply via email to