36809: fix plaintext output of img tags. r=BenB

git-svn-id: svn://10.0.0.236/trunk@77958 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
akkana%netscape.com
2000-09-01 23:36:18 +00:00
parent ed7b7032ff
commit 4f8a9c4d2f
2 changed files with 74 additions and 76 deletions

View File

@@ -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 <http://www.w3.org/TR/REC-html40/struct/objects.html#edef-IMG>
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 <http://www.w3.org/TR/REC-html40/struct/objects.html#edef-IMG>
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;
}