in reply to Re: Formatting in thread Formatting
Hey,
First of all, thanks to all who replied!
John, I like you sample script because, like you said, its flexible. I've tried it out and it works all well except one thing, after a </li>, when it has to start with another <li>, it does it all in the same line. I've tried adding a \n to the close string, but it isn't working, its getting outputted instead of interpreted.
Like I said before, I'm new in Perl and this is probably really easy to fix.
Thanks again! I really appreciate it :)
Marcos
Re^3: Formatting
by wfsp (Abbot) on Jul 10, 2004 at 14:15 UTC
|
Glad you liked it. I've put another condition in the if block:
if ( $tag->{ $style }->{ block } and ! $block_flag ){
$output = join( '',
$output,
$tag->{ $style }->{ block_open },
$line_out );
$block_flag = $style;
}
elsif ( ! $tag->{ $style }->{ block } and $block_flag ){
$output = join( '',
$output,
$tag->{ $block_flag }->{ block_close },
"\n",
$line_out,
"\n" );
$block_flag = '';
}
elsif ( ! $tag->{ $style }->{ block } ){
$output = join( '',
$output,
$line_out,
"\n" );
}
else{
$output = join( '',
$output,
$line_out );
}
| [reply] [d/l] |
|
Thanks again!
Just got 2 questions that have arisen and should be easy to do now that you have kindly provided me with this script.
First, the simplest, how do I add the '#' as one of the first characters to check? I have tried adding another one of those blocks, but as you know Perl's comment character is #. Adding "\#" didn't help either. How can I express this in a way that will work without Perl interpreting it as a comment?
And lastly, how can I make the "K" statements be separated as "Perl,%Monks,%Is,%Cool"? I've experimented with adding a ",". For example:
my $tag = { K => { open => ',%',
close => '',
block => 1,
block_open => '<p>',
block_close => '</p>'
But as you probably realized, this has a nasty habit of adding an extra "," even to the first statement, as in ,%Perl,%Monks,%Is,%Cool .
I want you to know that I really appreciate the help you have provided so far, since I'm very close to having this finished and saving me tons of future hours :)
Best Regards,
Marcos
| [reply] |
|
Important: read the health warning below.
Does a # in the data indicate a comment? If it does the code below skips lines begining with a #. If I have not understood you correctly, please give an example of the data.
The code also adds a comma to each 'inline' style.
I've added a variable to help make the code clearer.
Health warning
There is more than one way to do this! This is how I do it and it is heavily influenced by the fact that my main experience in coding is vb which makes most people around here shudder! For example, in Programing Perl, a long list of elsifs is frowned on. I tell myself that as I'm using the less well known 'baby idiom' (to be polite) it is ok. Until, at least, I learn a better way.
Also my main motive for helping is to hone my own skills (which badly need honing).
| [reply] [d/l] |
|
|
|
|
|