On Tue, Dec 20, 2005 at 09:48:15PM +0100, Gerald Richter wrote:
> The other one is to create a syntax module, which uses HTML::TextToHTML for
> the actual work.
>
> To do so, just make a copy of Embperl/Syntax/Perl.pm, then in the call to
> AddInitCode you would pass some code like:
[snip]
Well, I have now actually gotten around to trying to implement it, and I
can't get it to work. I am completely stumped!
Attached is the module I made, Embperl::Syntax::TextToHTML
and I have a recipe which correctly sets the syntax to 'TextToHTML' when
trying to process a .txt file. However, hear is an example of the error
I get whenever I try to display a converted text file:
[13125]ERR: 24: Error in Perl code: Missing right curly or square
bracket at /home/kat/kat_web/katspace2/html/computers/linux_tips.txt
line 16, at end of line
syntax error at
/home/kat/kat_web/katspace2/html/computers/linux_tips.txt line 16, at
EOF
I've changed the code around trying to get it to work, and I get worse
errors, like it's trying to interpret the text file as perl code, and it
gives a flurry of perl syntax error messages.
Please can you help? This is a showstopper for me. Either that, or can
we have the plugin mechanism you were thinking of doing?
Kathryn Andersen
--
_--_|\ | Kathryn Andersen <http://www.katspace.com>
/ \ |
\_.--.*/ | GenFicCrit mailing list <http://www.katspace.com/gen_fic_crit/>
v |
------------| Melbourne -> Victoria -> Australia -> Southern Hemisphere
Maranatha! | -> Earth -> Sol -> Milky Way Galaxy -> Universe
package Embperl::Syntax::TextToHTML ;
use Embperl::Syntax qw{:types} ;
use Embperl::Syntax ;
use strict ;
use vars [EMAIL PROTECTED] ;
@ISA = qw(Embperl::Syntax) ;
###################################################################################
#
# Methods
#
###################################################################################
# ---------------------------------------------------------------------------------
#
# Create new Syntax Object
#
# ---------------------------------------------------------------------------------
sub new
{
my $class = shift ;
my $self = Embperl::Syntax::new ($class) ;
if (!$self -> {-perlInit})
{
$self -> {-perlInit} = 1 ;
$self -> AddInitCode (undef,
'
use HTML::TextToHTML ;
{
local $/ = undef ;
my $text = <DATA> ;
my $conv = new HTML::TextToHTML();
my $html = $conv->txt2html(instring=>[$text]);
print OUT $html ;
}
__DATA__
'
,
undef,
{
removenode => 32,
compilechilds => 0,
}) ;
}
return $self ;
}
1;
__END__
=pod
=head1 NAME
Embperl::Syntax::TextToHTML - Text-To-HTML syntax module for Embperl
=head1 SYNOPSIS
Execute ({inputfile => 'file.txt', syntax => 'TextToHTML'}) ;
=head1 DESCRIPTION
This syntax cause Embperl to convert the whole file from plain text
to HTML using HTML::TextToHTML.
=head1 Author
Kathryn Andersen
perlkat AT katspace DOT org
=cut
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]