I'm not used with perl but had the need to add a couple of features, I wish I can adopt a more perl-ish coding.
Any help is welcome.
This is to add style classes to paragraphs if strarting with !
, ?
and a clear: both
with %
Original:
foreach (@grafs) {
unless (defined( $g_html_blocks{$_} )) {
$_ = _RunSpanGamut($_);
s/^([ \t]*)/<p>/;
$_ .= "</p>";
}
}
Modded:
foreach (@grafs) {
unless (defined( $g_html_blocks{$_} )) {
$_ = _RunSpanGamut($_);
if ( m/^[ \t]*\?/ ){
s/^([ \t]*\?[ \t]*)/<p class="Introduction">/;
} elsif ( m/^[ \t]*\!/ ){
s/^([ \t]*\![ \t]*)/<p class="Important">/;
} elsif ( m/^[ \t]*%/ ){
s/^([ \t]*%[ \t]*)/<p style="clear: both;">/;
} else {
s/^([ \t]*)/<p>/;
}
$_ .= "</p>";
}
}
This is to add float to images like: !<[alt](url)
to get a float right (and form this the %
above to clear)
if (defined($align)) {
if ($align eq "<") {
$result .= " style=\"float: left; margin: 0 ${padding}px ${padding}px 0;\"";
} else {
$result .= " style=\"float: right; margin: 0 0 ${padding}px ${padding}px;\"";
}
}