From 85292633f844d17834973275f16a3ffee3cfc74b Mon Sep 17 00:00:00 2001 From: "akkana%netscape.com" Date: Fri, 1 Sep 2000 23:36:18 +0000 Subject: [PATCH] 36809: fix plaintext output of img tags. r=BenB --- htmlparser/src/nsHTMLToTXTSinkStream.cpp | 75 +++++++++---------- .../htmlparser/src/nsHTMLToTXTSinkStream.cpp | 75 +++++++++---------- 2 files changed, 74 insertions(+), 76 deletions(-) diff --git a/htmlparser/src/nsHTMLToTXTSinkStream.cpp b/htmlparser/src/nsHTMLToTXTSinkStream.cpp index c04596487f9..4334f9bcfe4 100644 --- a/htmlparser/src/nsHTMLToTXTSinkStream.cpp +++ b/htmlparser/src/nsHTMLToTXTSinkStream.cpp @@ -723,43 +723,6 @@ nsHTMLToTXTSinkStream::OpenContainer(const nsIParserNode& aNode) mIndent += gTabSize; // Check for some maximum value? } - else if (type == eHTMLTag_img) - { - /* Output (in decreasing order of preference) - alt, title or src (URI) attribute */ - // See - nsAutoString desc, temp; - if (NS_SUCCEEDED(GetValueOfAttribute(aNode, "alt", desc))) - { - if (!desc.IsEmpty()) - { - temp.AppendWithConversion(" ["); // Should we output chars at all here? - desc.StripChars("\""); - temp += desc; - temp.AppendWithConversion(" ]"); - } - // If the alt attribute has an empty value (|alt=""|), output nothing - } - else if (NS_SUCCEEDED(GetValueOfAttribute(aNode, "title", desc)) - && !desc.IsEmpty()) - { - temp.AppendWithConversion(" ["); - desc.StripChars("\""); - temp += desc; - temp.AppendWithConversion("] "); - } - else if (NS_SUCCEEDED(GetValueOfAttribute(aNode, "src", desc)) - && !desc.IsEmpty()) - { - temp.AppendWithConversion(" <"); - desc.StripChars("\""); - temp += desc; - temp.AppendWithConversion("> "); - } - if (!temp.IsEmpty()) - Write(temp); - } - else if (type == eHTMLTag_a && !IsConverted(aNode)) { nsAutoString url; @@ -1025,7 +988,43 @@ nsHTMLToTXTSinkStream::AddLeaf(const nsIParserNode& aNode) EnsureVerticalSpace(0); } - + else if (type == eHTMLTag_img) + { + /* Output (in decreasing order of preference) + alt, title or src (URI) attribute */ + // See + nsAutoString desc, temp; + if (NS_SUCCEEDED(GetValueOfAttribute(aNode, "alt", desc))) + { + if (!desc.IsEmpty()) + { + temp.AppendWithConversion(" ["); // Should we output chars at all here? + desc.StripChars("\""); + temp += desc; + temp.AppendWithConversion("]"); + } + // If the alt attribute has an empty value (|alt=""|), output nothing + } + else if (NS_SUCCEEDED(GetValueOfAttribute(aNode, "title", desc)) + && !desc.IsEmpty()) + { + temp.AppendWithConversion(" ["); + desc.StripChars("\""); + temp += desc; + temp.AppendWithConversion("] "); + } + else if (NS_SUCCEEDED(GetValueOfAttribute(aNode, "src", desc)) + && !desc.IsEmpty()) + { + temp.AppendWithConversion(" <"); + desc.StripChars("\""); + temp += desc; + temp.AppendWithConversion("> "); + } + if (!temp.IsEmpty()) + Write(temp); + } + return NS_OK; } diff --git a/parser/htmlparser/src/nsHTMLToTXTSinkStream.cpp b/parser/htmlparser/src/nsHTMLToTXTSinkStream.cpp index c04596487f9..4334f9bcfe4 100644 --- a/parser/htmlparser/src/nsHTMLToTXTSinkStream.cpp +++ b/parser/htmlparser/src/nsHTMLToTXTSinkStream.cpp @@ -723,43 +723,6 @@ nsHTMLToTXTSinkStream::OpenContainer(const nsIParserNode& aNode) mIndent += gTabSize; // Check for some maximum value? } - else if (type == eHTMLTag_img) - { - /* Output (in decreasing order of preference) - alt, title or src (URI) attribute */ - // See - nsAutoString desc, temp; - if (NS_SUCCEEDED(GetValueOfAttribute(aNode, "alt", desc))) - { - if (!desc.IsEmpty()) - { - temp.AppendWithConversion(" ["); // Should we output chars at all here? - desc.StripChars("\""); - temp += desc; - temp.AppendWithConversion(" ]"); - } - // If the alt attribute has an empty value (|alt=""|), output nothing - } - else if (NS_SUCCEEDED(GetValueOfAttribute(aNode, "title", desc)) - && !desc.IsEmpty()) - { - temp.AppendWithConversion(" ["); - desc.StripChars("\""); - temp += desc; - temp.AppendWithConversion("] "); - } - else if (NS_SUCCEEDED(GetValueOfAttribute(aNode, "src", desc)) - && !desc.IsEmpty()) - { - temp.AppendWithConversion(" <"); - desc.StripChars("\""); - temp += desc; - temp.AppendWithConversion("> "); - } - if (!temp.IsEmpty()) - Write(temp); - } - else if (type == eHTMLTag_a && !IsConverted(aNode)) { nsAutoString url; @@ -1025,7 +988,43 @@ nsHTMLToTXTSinkStream::AddLeaf(const nsIParserNode& aNode) EnsureVerticalSpace(0); } - + else if (type == eHTMLTag_img) + { + /* Output (in decreasing order of preference) + alt, title or src (URI) attribute */ + // See + nsAutoString desc, temp; + if (NS_SUCCEEDED(GetValueOfAttribute(aNode, "alt", desc))) + { + if (!desc.IsEmpty()) + { + temp.AppendWithConversion(" ["); // Should we output chars at all here? + desc.StripChars("\""); + temp += desc; + temp.AppendWithConversion("]"); + } + // If the alt attribute has an empty value (|alt=""|), output nothing + } + else if (NS_SUCCEEDED(GetValueOfAttribute(aNode, "title", desc)) + && !desc.IsEmpty()) + { + temp.AppendWithConversion(" ["); + desc.StripChars("\""); + temp += desc; + temp.AppendWithConversion("] "); + } + else if (NS_SUCCEEDED(GetValueOfAttribute(aNode, "src", desc)) + && !desc.IsEmpty()) + { + temp.AppendWithConversion(" <"); + desc.StripChars("\""); + temp += desc; + temp.AppendWithConversion("> "); + } + if (!temp.IsEmpty()) + Write(temp); + } + return NS_OK; }