[WM] Text::Textile and WebMake

Justin Mason jm at jmason.org
Thu Nov 20 19:49:00 GMT 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


webmake at technomage.net writes:
>+  $self->add_converter ('text/tt', 'text/html',
>+                       'Text::Textile', \&tt_to_html);

Thanks everyone ;) who added support for it -- that's now in CVS.
I made a minor change to ensure that it'd work OK for folks who
don't have Text::Textile installed, by putting the module 'require'
into an eval { } block.  Updated patch below...

- --j.

diff -u -3 -p -r1.17 FormatConvert.pm
- --- lib/HTML/WebMake/FormatConvert.pm   26 Nov 2001 07:01:38 -0000      1.17
+++ lib/HTML/WebMake/FormatConvert.pm   20 Nov 2003 19:45:48 -0000
@@ -23,6 +23,9 @@ package HTML::WebMake::FormatConvert;
 sub set_converters {
   my $self = shift;
 
+  $self->add_converter ('text/tt', 'text/html',
+                       'Text::Textile', \&tt_to_html);
+
   $self->add_converter ('text/et', 'text/html',
                        'Text::EtText::EtText2HTML', \&et_to_html);
 
@@ -189,6 +192,26 @@ sub et_to_html {
 
   $self->{ettext}->text2html ($txt);
 }
 }
+
+# -------------------------------------------------------------------------
+# textile stuff
+
+sub tt_to_html
+{
+  my ($self,$contobj,$txt) = @_;
+
+  if (!defined $self->{textile}) {
+    eval {
+      require Text::Textile;
+      $self->{textile} = new Text::Textile;
+      1;
+    } or die "FormatConvert: cannot create Text::Textile object: $!";
+  }
+
+  $self = $self->{textile}->process($txt);
+  return $self;
+}
+
 
 # -------------------------------------------------------------------------
 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)
Comment: Exmh CVS

iD8DBQE/vRpeQTcbUG5Y7woRAodTAKDdCNJoBitAAzxZOf/ivnst4ecs5QCg6vFV
/q3Ro/MDCGF15SwHx02SwJg=
=ukzb
-----END PGP SIGNATURE-----




More information about the Webmake-talk mailing list