I've had the problem that entries in FAQ Manager
documents do not preserve their line spacing. I want
the new lines inserted to be retained because otherwise
the textfield box shows all of the answer "smashed
together" into a single line. Not only are \n\n no
longer turned into <P>, but new lines inserted are
lost. Actually, they are saved into the document, but
are obliterated by the quotemeta() in html-lib.pl.
What we need to see in the javascript is "\n", and it
takes a little fiddling to stop the quotemeta from
wrecking new lines.
To deal with these problems, I've made these changes.
In html-lib.pl, around 512, we need to make sure that
"\n" in the document is not "destroyed" by the quotemeta:
for (my $j=0; $j < @{ $data[$i]->{'attr1'} }; $j++ ) {
#PJ 2004-04-25
my $new_attr2 = quotemeta($data[$i]->{'attr2'}->[$j]);
$new\_attr2 =~ s/\n/ \\\n\\\\\n/gs;
$js_code .= "Root[$i][1][$j] = '" .
quotemeta($data[$i]->{'attr1'}->[$j]) . "';\n";
$js_code .= "Root[$i][2][$j] = '" . $new_attr2 .
"';\n";
}
Now, to restore the translation of \n\n into <p> in
input, I had to put some things back that used to be in
faq_manager.pl. It is needed in the "add" and "update"
methods.
In the "add logic" section, around line 729: The first
two lines are in the
current sourcecode:
# strip ^M tags (windoze users)
$attr2 =~ s/\cM//sg;
#2004-04-25 PJ INSERTS:
$attr2 =~ s/\n\n/\n<P>/gs;
And in the "update" section, around line 883, the first
two lines are in the source code:
# make paragraphs from the input based on \n\n
$attr2 =~ s/\cM//gs;
# PJ 2004-04-25 pj INSERTEd to preserve paragraphs!
$attr2 =~ s/\n\n/\n<P>/gs;
Note the first line is erroneous. The \n\n code was
replaced by the line that deletes Control-M.
I'm hoping these changes can go into faq_manager.