tags 584459 + patch pending
retitle 584459 roffit: [PATCH] unbalanced </span> for roff font changes
forwarded 584459 <dan...@haxx.se>
thanks

markus schnalke <mei...@marmaro.de> writes:

> Package: roffit
> Version: 0.6+cvs20090507-1
> Severity: normal
> Tags: upstream
>
> Roffit represents \f font changes with
>
>     <span class="...">text</span>
>
> This leads to unbalanced <span> tags for valid nroff input like:
>
>     normal\fBbold\fIitalic\fRnormal
>
> This is commonly used in the synopsis section of man pages to specify
> options and arguments to them. E.g. from Heirloom tar:
>
>     \fB\-C\fI dir\fR
>
> The result is:
>
>     <span class="bold">-C<span Class="emphasis"> dir</span>

Patch below for this. Daniel, would you apply to CVS.

[We'll clone the rest for another bug]

Jari

>From fb7fd1560736d82fde4558bbea8f2ca69750f84a Mon Sep 17 00:00:00 2001
From: Jari Aalto <jari.aa...@cante.net>
Date: Fri, 4 Jun 2010 11:50:36 +0300
Subject: [PATCH] roffit: Handle \fB .. \fR and multiple close tags </span>
Organization: Private
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit


Signed-off-by: Jari Aalto <jari.aa...@cante.net>
---
 roffit |   32 +++++++++++++++++++++++++++++---
 1 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/roffit b/roffit
index 3149f37..c32270f 100755
--- a/roffit
+++ b/roffit
@@ -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>) {
@@ -404,9 +431,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;
-- 
1.7.1

Reply via email to