You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Kathryn Andersen <ka...@katspace.homelinux.org> on 2005/12/20 02:50:08 UTC
Text to HTML recipe making
Hello, I'm new to Embperl (though it seems to be a case of love at first
sight).
I'm trying to get a handle on Recipes and Providers. I gather that
in order for something to be able to be Provided, it needs to have
a Syntax module for it, in order for a Recipe to be able to use it.
What I want to be able to do, is for Embperl to be able to read in
plain text files and convert them to HTML. But I don't want to reinvent
the wheel, since there are perfectly good perl modules which have
already been written to do that (such as HTML::TextToHTML).
But the impression I get from the manuals is that one can't use another
module, that you have to reinvent the wheel and write a Syntax module
in order to parse a plain-text file. Which is Not Good.
Of course, I know that one could sort of do it in a quick-and-dirty
way by reading in the desired plain-text file into a scalar, processing
it with HTML::TextToHTML and then doing whatever you want to it,
but I would like to do it the proper Embperl 2.x way, with Recipes
and Providers, so that it could be reusable and passed on to other
people to use.
Kathryn Andersen
-=-=-=-=-=-=-=-=-
A box without hinges, key, or lid,
Yet golden treasure inside is hid.
-- J.R.R. Tolkien
--
_--_|\ | 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
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
RE: Text to HTML recipe making
Posted by Gerald Richter <ri...@ecos.de>.
> >
> > Unfortunately there are a few lines of C code missing to get this
> > done. It was always my intention to make such a usage
> possible, but I
> > didn't got around until now to implement the last piece :-(
>
> Ah. Does this mean that you have now done it? (Sorry, I
> notice that German-speakers tend to have problems with using
> the word "until"
> correctly)
>
No it's not done.
Just to make it right the next time, what would be the correct word instead
of "until" in this case?
> > to AddInitCode you would pass some code like:
> >
> > q{
> >
> > use HTML::TextToHTML ;
> >
> > {
> > local $/ = undef ;
> > my $text = <DATA> ;
> >
> > my $html = HTML::TextToHTML::<whatever you want to do> ($text) ;
> > print OUT $html ; }
> >
> > __DATA__
> >
> > }
>
> Ah, so this would make the rest-of-the-file the __DATA__ to
> be read and processed.
Yes
> Interesting! I'm not entirely sure
> whether this would work, since HTML::TextToHTML already makes
> use of the DATA handle to read in its own configuration -- I
> can't remember what happens with multiple __DATA__ sections
> in different files.
>
There should be no problem, since Perl can handle multiple __DATA__ in
different files
Gerald
** Virus checked by BB-5000 Mailfilter **
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: Text to HTML recipe making
Posted by 'Kathryn Andersen' <ka...@katspace.homelinux.org>.
On Tue, Dec 20, 2005 at 09:48:15PM +0100, Gerald Richter wrote:
> >
> > What I want to be able to do, is for Embperl to be able to
> > read in plain text files and convert them to HTML. But I
> > don't want to reinvent the wheel, since there are perfectly
> > good perl modules which have already been written to do that
> > (such as HTML::TextToHTML).
> >
>
> Unfortunately there are a few lines of C code missing to get this done. It
> was always my intention to make such a usage possible, but I didn't got
> around until now to implement the last piece :-(
Ah. Does this mean that you have now done it? (Sorry, I notice that
German-speakers tend to have problems with using the word "until"
correctly)
> So one possiblilty is that somebody writes this C code.
Ah, so you haven't done it yet.
> 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:
>
> q{
>
> use HTML::TextToHTML ;
>
> {
> local $/ = undef ;
> my $text = <DATA> ;
>
> my $html = HTML::TextToHTML::<whatever you want to do> ($text) ;
> print OUT $html ;
> }
>
> __DATA__
>
> }
Ah, so this would make the rest-of-the-file the __DATA__ to be read
and processed. Interesting! I'm not entirely sure whether this would
work, since HTML::TextToHTML already makes use of the DATA handle to
read in its own configuration -- I can't remember what happens with
multiple __DATA__ sections in different files.
Still, it certainly can't hurt to try.
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
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: Text to HTML recipe making
Posted by 'Kathryn Andersen' <ka...@katspace.homelinux.org>.
On Tue, Mar 28, 2006 at 05:28:46AM +0200, Gerald Richter wrote:
>
> >
> > Maybe there's something about Embperl which doesn't like
> > __DATA__ sections?
> >
>
> I can't think of any reason why it shouldn't work. I will give it a try when
> I habe some more spare time, but at the moment I am releaseing some critical
> applications for our company, which must be done first, sorry!
Don't worry about it, I found the mistake, it was my mistake: I had a
local $/ in the wrong scope, which messed everything up.
Not a good idea to program on not enough sleep...
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
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
RE: Text to HTML recipe making
Posted by Gerald Richter <ri...@ecos.de>.
>
> Maybe there's something about Embperl which doesn't like
> __DATA__ sections?
>
I can't think of any reason why it shouldn't work. I will give it a try when
I habe some more spare time, but at the moment I am releaseing some critical
applications for our company, which must be done first, sorry!
Gerald
** Virus checked by BB-5000 Mailfilter **
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: Text to HTML recipe making
Posted by 'Kathryn Andersen' <ka...@katspace.homelinux.org>.
On Tue, Mar 28, 2006 at 06:36:13AM +1000, 'Kathryn Andersen' wrote:
> On Mon, Mar 27, 2006 at 08:59:31PM +0200, Gerald Richter wrote:
> > >
> > > Well, I have now actually gotten around to trying to
> > > implement it, and I can't get it to work. I am completely stumped!
[snip]
Never mind.
1) I found the log. I couldn't see anything wrong with the code there
either.
2) I have given up trying to get Embperl::Syntax::TextToHTML working, in
favour of a workaround. In my base.epl file, I check to see if the
desired file is a plain text file, and if so, read it in, convert it,
and then pass the string result to Execute as an input=> string.
It mostly works, though HTML::TextToHTML doesn't appear to be reading
its __DATA__ handle (which it needs for some of the conversions, which
do not work).
Maybe there's something about Embperl which doesn't like __DATA__
sections?
Kathryn Andersen
-=-=-=-=-=-=-=-=-
"Oh, that's marvelous. We're not sure where we are, but if they
were sure they wouldn't know where it was anyway."
-- Vila Restal (Blake's 7: The Web [A5])
--
_--_|\ | 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
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
RE: Text to HTML recipe making
Posted by Gerald Richter <ri...@ecos.de>.
>
> I can't get the debug to work.
>
> I give
>
> Embperl_Debug 0x8000000
>
Embperl tries to write it to /tmp/embperl.log, you can set the path with
Embperl_Log
Gerald
** Virus checked by BB-5000 Mailfilter **
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: Text to HTML recipe making
Posted by 'Kathryn Andersen' <ka...@katspace.homelinux.org>.
On Mon, Mar 27, 2006 at 08:59:31PM +0200, Gerald Richter wrote:
> >
> > 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:
>
> Basicly it seems to be ok. The best is to set Embperl_Debug to dbgCompile =
> 0x8000000 (or set it to 0x7ffffff, which will output a lot of debug
> informations). That would show you the Perl code Embperl generates and you
> should be able to find the missing bracket.
(tears out hair)
I can't get the debug to work.
I give
Embperl_Debug 0x8000000
in my Apache configuration file, and I get zero debug information. Not
in my error logs, not in the page displayed.
Even if I go
Embperl_Debug 0xfffffff
I get absolutely NOTHING in the way of debug information, just the same
error message that I got before. (Yes, I'm not dumb, I did restart Apache).
This is with Embperl 2.1.0 and Apache 2.0.55
(sigh)
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
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
RE: Text to HTML recipe making
Posted by Gerald Richter <ri...@ecos.de>.
>
> 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:
>
Basicly it seems to be ok. The best is to set Embperl_Debug to dbgCompile =
0x8000000 (or set it to 0x7ffffff, which will output a lot of debug
informations). That would show you the Perl code Embperl generates and you
should be able to find the missing bracket.
Gerald
** Virus checked by BB-5000 Mailfilter **
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: Text to HTML recipe making
Posted by 'Kathryn Andersen' <ka...@katspace.homelinux.org>.
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
RE: Text to HTML recipe making
Posted by Gerald Richter <ri...@ecos.de>.
>
> What I want to be able to do, is for Embperl to be able to
> read in plain text files and convert them to HTML. But I
> don't want to reinvent the wheel, since there are perfectly
> good perl modules which have already been written to do that
> (such as HTML::TextToHTML).
>
Unfortunately there are a few lines of C code missing to get this done. It
was always my intention to make such a usage possible, but I didn't got
around until now to implement the last piece :-(
So one possiblilty is that somebody writes this C code.
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:
q{
use HTML::TextToHTML ;
{
local $/ = undef ;
my $text = <DATA> ;
my $html = HTML::TextToHTML::<whatever you want to do> ($text) ;
print OUT $html ;
}
__DATA__
}
Gerald
** Virus checked by BB-5000 Mailfilter **
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org