mhonarc-dev

Re: [Bug #2080] Redundant substitution

2002-12-29 09:43:44
On December 29, 2002 at 00:21, Gunnar Hjalmarsson wrote:

    $chunk =~ s/\n/<br\n>/g;

This is not a bug.  The substitution exists to deal with
subtle formatting characteristics of browsers.  Although
it looks redundant, it generates output that properly
reflects the formatting of the orginal data

I don't know which browsers you have in mind, but according to my tests, 
Mozilla, NS7 and Opera seem not to be affected, while rendering by MSIE 
and NS4 does *not* reflect the original properly: All blank lines are 
ignored.

I use Galeon, which uses the Mozilla Gecko rendering engine.
Without the substitution, some line breaks are "lost" due to the
inherent rendering characteristics of the browser (i.e. line breaks
after a start (<pre>) tag and before a close (<pre>) tag are typically
ignored).

At the end of this message is the test mesasge text I test against.
I used it for testing the flowed and fanyquote.  When testing for
fancyquote, I use the following resource setting to disable flowed
processing since the message headers of the test message
specify flowed formatting:

  <MIMEArgs>
  m2h_text_plain::filter; fancyquote disableflowed maxwidth=80
  </MIMEArgs>

If you comment out, or delete, the s/// operator, you will see that
some line breaks get "lost", mainly between two quoted chunks.  The
difference may be subtle and not apparent with most mail messages.

Here is the test data (ignore the "flowed" comments in the text
when testing fancyquote since they only indicate what should happen
if flowed formatting is used):

---begin test data---
This is a test of flowed text. 
This is only a test. 

Level 1 text.  Level 1 text.  Level 1 text.  Level 1 text. 
Level 1 text.  Level 1 text.  Level 1 text.  Level 1 text.
Hello there.  Hello there.  Hello there.  Hello there.  Hello there. 
Hello there.  Hello there.  Hello there.  Hello there.  Hello there. 
Hello there.  Hello there.

This text should be not be flowed.
Up to this line.
This line is at the same quote depth, but should be flowed. 
With this line.
No leading space before this line and this line right after previous.

0123456789012345678901234567890123456789012345678901234567890123456789 
0123456789
0123456789012345678901234567890123456789012345678901234567890123456789
90123456789012345678901234567890123456789012345678901234567890123456789
90123456789012345678901234567890123456789012345678901234567890123456789
890123456789012345678901234567890123456789012345678901234567890123456789
890123456789012345678901234567890123456789012345678901234567890123456789
67890123456789012345678901234567890123456789012345678901234567890123456789
67890123456789012345678901234567890123456789012345678901234567890123456789

This text should not be flowed since there
is no extra spaces at the end of the lines
in this paragraph.  However we will just have
to see if the filter does the correct thing.

This row ends with [^ ]\r\n, and is converted to a fixed font.
This row ends with [^ ]\r\n, and is converted to a fixed font.
This row ends with [^ ]\r\n, and is converted to a fixed font.

But the rows below should be displayed in a fixed 
font, since it is a separate para and lines end with [^ ]\r\n:

    for (split (/[&;]/, $in)) {
        ($name, $value) = split(/=/);
        $value =~ s/%(..)/pack("c",hex($1))/ge;
        $in{$name} = $value;
    }

Typically, when you post a code fragment, you want it to be viewed 
with a fixed font, don't you?

This is another flowed paragraph.  I want to see if a proper line 
break exists between this paragraph and the preceding one.  Also this 
para has complete nothing to say.



Here is another flowed.  This one has a few line breaks before it. 
Do they get compressed or are they presevered.  Well, we'll just have to 
find out.

This is a short paragraph.

Here is some quoted text 
that should be flowed.

Here is another short paragraph.

This is a really long line. This is a really long line. This is a really long 
line. This is a really long line. This is a really long line. This is a 
really long line. This is a really long line. This is a really long line. 
Where this line should be flowed with the previous.

This is a really long line. This is a really long line. This is a really long 
line. This is a really long line. This is a really long line. This is a really 
long line. This is a really long line. This is a really long line, that should 
be rendered pre-formatted.
Since this paragraph EOLs are just newlines.

The following block should be flowed:



The following block should be pre-formatted:




This is a test of flowed text. 
This is only a test.  In this test, there is a blank line 
at the end, but it is quoted at the same level of this test. 

Level 1 text.  Level 1 text.  Level 1 text.  Level 1 text. 
Level 1 text.  Level 1 text.  Level 1 text.  Level 1 text.

A short quoted paragraph. 

The End.

--ewh
-- 
Earl Hood, <earl(_at_)earlhood(_dot_)com>
Web: <http://www.earlhood.com/>
PGP Public Key: <http://www.earlhood.com/gpgpubkey.txt>
---end test data---

---------------------------------------------------------------------
To sign-off this list, send email to majordomo(_at_)mhonarc(_dot_)org with the
message text UNSUBSCRIBE MHONARC-DEV