Contribution from mozilla@bucksch.org to improve anchor and img tags

in formatted mode (r=akkana).
Also some minor improvements to handling of blank lines in pre tags,
to get rid of extra blank lines in plaintext mail (r=mcafee).


git-svn-id: svn://10.0.0.236/trunk@53891 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
akkana%netscape.com
1999-11-18 19:39:47 +00:00
parent 42d0b173ba
commit 0a7d0ef76e
2 changed files with 30 additions and 14 deletions

View File

@@ -17,7 +17,11 @@
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Contributor(s):
* Greg Kostello (original structure)
* Akkana Peck <akkana@netscape.com>
* Daniel Brattell <bratell@lysator.liu.se>
* Ben Bucksch <mozilla@bucksch.org>
*/
/**
@@ -478,7 +482,9 @@ nsHTMLToTXTSinkStream::OpenContainer(const nsIParserNode& aNode)
if (NS_SUCCEEDED(err))
{
SetWrapColumn((PRUint32)col);
#ifdef DEBUG_akkana
printf("Set wrap column to %d based on style\n", mWrapColumn);
#endif
}
}
} else {
@@ -558,23 +564,23 @@ nsHTMLToTXTSinkStream::OpenContainer(const nsIParserNode& aNode)
}
else if (type == eHTMLTag_pre)
{
EnsureVerticalSpace(0);
EnsureVerticalSpace(1);
}
else if (type == eHTMLTag_a)
{
nsAutoString url;
if (NS_SUCCEEDED(GetValueOfAttribute(aNode, "href", url)))
if (NS_SUCCEEDED(GetValueOfAttribute(aNode, "href", url))
&& !url.IsEmpty())
mURL = url;
else
mURL.Truncate();
}
else if (type == eHTMLTag_img)
{
nsAutoString url;
if (NS_SUCCEEDED(GetValueOfAttribute(aNode, "src", url)))
if (NS_SUCCEEDED(GetValueOfAttribute(aNode, "src", url)) && !url.IsEmpty())
{
nsAutoString temp, desc;
if (NS_SUCCEEDED(GetValueOfAttribute(aNode, "alt", desc)))
if (NS_SUCCEEDED(GetValueOfAttribute(aNode, "alt", desc))
&& !desc.IsEmpty())
{
temp += " (";
temp += desc;
@@ -633,6 +639,7 @@ nsHTMLToTXTSinkStream::CloseContainer(const nsIParserNode& aNode)
EnsureVerticalSpace(0);
} else if ((type == eHTMLTag_tr) ||
(type == eHTMLTag_li) ||
(type == eHTMLTag_pre) ||
(type == eHTMLTag_blockquote)) {
EnsureVerticalSpace(0);
} else {
@@ -694,6 +701,7 @@ nsHTMLToTXTSinkStream::CloseContainer(const nsIParserNode& aNode)
temp += mURL;
temp += ">";
Write(temp);
mURL.Truncate();
}
}
else if (type == eHTMLTag_sup)