Hey.
I'm still doing some work on my Tk::HyperText module, but there's a little thing I'm having trouble with on it: converting multiple line breaks into a single space.
For example, in this HTML code...
The page should display "The quick brown fox jumps over the lazy dog." in a real web browser, because the line break gets converted into a space.
However, when I try to run a regexp like this:
It converts every Lf into a space. So that, with this HTML code:
The page displays with 5 or 6 spaces on the top line, then the <h1> code. At most it should only have 1 space on the top line.
Here's my relevant bit of code:
Help would be appreciated.
-------------
Cuvou.com | My personal homepage
Project Fearless | My web blog
I'm still doing some work on my Tk::HyperText module, but there's a little thing I'm having trouble with on it: converting multiple line breaks into a single space.
For example, in this HTML code...
Code:
<b>The quick brown fox
jumps over the lazy dog.</b>
The page should display "The quick brown fox jumps over the lazy dog." in a real web browser, because the line break gets converted into a space.
However, when I try to run a regexp like this:
Code:
$sector =~ s/\x0a+/ /ig;
It converts every Lf into a space. So that, with this HTML code:
Code:
<html>
<head>
<title>HyperText Demonstration</title>
</head>
<body bgcolor="#EEEEFF" link="#0000FF" vlink="#FF00FF" alink="#FF0000" text="#000000">
<h1>Tk::HyperText Demonstration</h1>
The page displays with 5 or 6 spaces on the top line, then the <h1> code. At most it should only have 1 space on the top line.
Here's my relevant bit of code:
Code:
# If this was preformatted text, preserve the line endings and spacing.
if ($style{pre} == 1) {
# Leave it alone.
}
else {
$sector =~ s/\x0d//smg;
$sector =~ s/\x0a+//smg;
$sector =~ s/\s+/ /sg;
}
Help would be appreciated.
-------------
Cuvou.com | My personal homepage
Project Fearless | My web blog