Closed Bug 17871 Opened 25 years ago Closed 25 years ago

nsHTMLToTXTSinkStream: last line of quote has no "> "

Categories

(Core :: DOM: Serializers, defect, P3)

defect

Tracking

()

VERIFIED FIXED

People

(Reporter: BenB, Assigned: akkzilla)

Details

(Whiteboard: Patch attached)

Attachments

(1 file)

Reproduce:
Debug|Composer with test page
Output HTML

Actual Result:
> Reruns
>
> Reruns are about as much fun,
> as your dad taking all your mun,
> and giving it to a nun,
as a contribution.

Expected Result:
> Reruns
>
> Reruns are about as much fun,
> as your dad taking all your mun,
> and giving it to a nun,
> as a contribution.

Output HTML gives:
<blockquote class="poem" type="cite">
<h4>Reruns</h4>
Reruns are about as much fun,<br>
as your dad taking all your mun,<br>
and giving it to a nun,<br>
as a contribution.
</blockquote>

Output XIF gives:
<container isa="blockquote"><attr name="class" value="poem"/>
<attr name="type" value="cite"/>
<content>
</content>
<container isa="h4"><content>Reruns</content>
</container><!--h4-->
<content>
Reruns are about as much fun,</content>
<leaf isa="br">
</leaf><!--br-->
<content>
as your dad taking all your mun,</content>
<leaf isa="br">
</leaf><!--br-->
<content>
and giving it to a nun,</content>
<leaf isa="br">
</leaf><!--br-->
<content>
as a contribution.
</content>
</container><!--blockquote-->
Correction:
Reproduce:
Debug|Composer with test page
Output Text
Yes, agreed.  The quoting code gets confused if the text being quoted doesn't
end with a <br> or similar.
Status: NEW → ASSIGNED
Target Milestone: M12
The "mailquote" automated output test has been changed to include this case (and
won't pass the auto test until this bug is fixed).
This special case was cauesed by the quotelevel count being decreased before the
line is emitted. Could be fixed by a fast hack, but maybe there is a smarter
solution. Will think about it.
By the way, the quote is missing from Flushline too.

Patch:
diff -u -r3.34 nsHTMLToTXTSinkStream.cpp
--- nsHTMLToTXTSinkStream.cpp   1999/11/03 02:44:36     3.34
+++ nsHTMLToTXTSinkStream.cpp   1999/11/03 18:19:47
@@ -757,8 +757,14 @@
 void
 nsHTMLToTXTSinkStream::FlushLine()
 {
-  WriteSimple(mCurrentLine);
-  mCurrentLine.SetString("");
+  if(mCurrentLine.Length()>0) {
+    if(0 == mColPos)
+      WriteQuotesAndIndent();
+
+    WriteSimple(mCurrentLine);
+    mColPos += mCurrentLine.Length();
+    mCurrentLine.SetString("");
+  }
 }
Whiteboard: Patch attached
Now I've thought about it. A good patch that solves the problem is:

diff -u -r3.34 nsHTMLToTXTSinkStream.cpp
--- nsHTMLToTXTSinkStream.cpp   1999/11/03 02:44:36     3.34
+++ nsHTMLToTXTSinkStream.cpp   1999/11/03 23:07:12
@@ -549,10 +549,13 @@
   if (mTagStackIndex > 0)
     --mTagStackIndex;

-  if (type == eHTMLTag_ol)
+  if (type == eHTMLTag_ol) {
+    FlushLine(); // Doing this after decreasing OLStackIndex would be wrong.
     --mOLStackIndex;
+  }
   else if (type == eHTMLTag_blockquote)
   {
+    FlushLine(); // Doing this after decreasing quotelevel would be wrong.
     if (mCiteQuoteLevel>0)
       mCiteQuoteLevel--;
     else if(mIndent >= gTabSize)
@@ -757,8 +760,14 @@
 void
 nsHTMLToTXTSinkStream::FlushLine()
 {
-  WriteSimple(mCurrentLine);
-  mCurrentLine.SetString("");
+  if(mCurrentLine.Length()>0) {
+    if(0 == mColPos)
+      WriteQuotesAndIndent();
+
+    WriteSimple(mCurrentLine);
+    mColPos += mCurrentLine.Length();
+    mCurrentLine.SetString("");
+  }
 }
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Daniel's patch has been checked in; this problem should be fixed now.
Status: RESOLVED → VERIFIED
verified in 11/29 build.
Bulk move of all "Output" component bugs to new "DOM to Test Conversion" 
component.  Output will be deleted as a component.
Component: Output → DOM to Text Conversion
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: