Skip to content

Commit

Permalink
roffit: roffit: Handle \fB .. \fR and multiple close tags </span>
Browse files Browse the repository at this point in the history
  • Loading branch information
jaalto authored and bagder committed Jun 7, 2010
1 parent 94e0670 commit ab62edb
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions roffit
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,33 @@ sub linkfile {
return @new;
}

sub handle_italic_bold ($) {
local $_ = shift;

while ( m,^(.*?)(\\f[IB].*?\\fR)(.*), ) {
my ($before, $match, $after) = ($1, $2, $3);

my $counter = 0;

while ( $match =~ s/\\fI/<span class=\"emphasis\">/ ) {
$counter++;
}

while ( $match =~ s/\\fB/<span class=\"bold\">/ ) {
$counter++;
}

my $tag = '</span>';
my $end = $tag x $counter;

$match =~ s/\\f[PR]/$end/;

$_ = $before . $match . $after;
}

$_;
}

sub parsefile {
my $lineno;
while(<$InFH>) {
Expand Down Expand Up @@ -442,9 +469,8 @@ sub parsefile {
$txt =~ s/\\ /&nbsp\;/g;
$txt =~ s/\\\'/&acute\;/g;
$txt =~ s/\\\(co/&copy\;/g;
$txt =~ s/\\fI/<span class=\"emphasis\">/g;
$txt =~ s/\\fB/<span class=\"bold\">/g;
$txt =~ s/\\f[PR]/<\/span>/g;

$_ = handle_italic_bold $_;

# replace backslash [something] with just [something]
$txt =~ s/\\(.)/$1/g;
Expand Down

0 comments on commit ab62edb

Please sign in to comment.