Fixed br in li.

This commit is contained in:
Matteo Tomasini 2011-04-05 16:33:01 +02:00
parent f366519f7a
commit fdb2809c50

View file

@ -23,7 +23,10 @@ namespace ScrewTurn.Wiki {
string text = ""; string text = "";
if(node.Name == "li") { if(node.Name == "li") {
foreach(XmlNode child in node.ChildNodes) { foreach(XmlNode child in node.ChildNodes) {
if(child.Name != "ol" && child.Name != "ul") { if(child.Name == "br") {
text += "\n";
}
else if(child.Name != "ol" && child.Name != "ul") {
TextReader reader = new StringReader(child.OuterXml); TextReader reader = new StringReader(child.OuterXml);
XmlDocument n = FromHTML(reader); XmlDocument n = FromHTML(reader);
text += ProcessChild(n.ChildNodes); text += ProcessChild(n.ChildNodes);
@ -44,8 +47,8 @@ namespace ScrewTurn.Wiki {
result += marker + " " + text; result += marker + " " + text;
if(!result.EndsWith("\n")) result += "\n"; if(!result.EndsWith("\n")) result += "\n";
foreach(XmlNode child in node.ChildNodes) { foreach(XmlNode child in node.ChildNodes) {
if(child.Name.ToString() == "ol") result += ProcessList(child.ChildNodes, marker + ol); if(child.Name == "ol") result += ProcessList(child.ChildNodes, marker + ol);
if(child.Name.ToString() == "ul") result += ProcessList(child.ChildNodes, marker + ul); if(child.Name == "ul") result += ProcessList(child.ChildNodes, marker + ul);
} }
} }
} }
@ -285,21 +288,21 @@ namespace ScrewTurn.Wiki {
} }
break; break;
case "ol": case "ol":
if(node.PreviousSibling != null) { if(node.PreviousSibling != null && node.PreviousSibling.Name != "br") {
result += "\n"; result += "\n";
} }
if(node.ParentNode != null) { if(node.ParentNode != null) {
if(node.ParentNode.Name.ToLowerInvariant() != "td") result += ProcessList(node.ChildNodes, "#"); if(node.ParentNode.Name != "td") result += ProcessList(node.ChildNodes, "#");
else result += node.OuterXml.ToString(); else result += node.OuterXml.ToString();
} }
else result += ProcessList(node.ChildNodes, "#"); else result += ProcessList(node.ChildNodes, "#");
break; break;
case "ul": case "ul":
if(node.PreviousSibling != null) { if(node.PreviousSibling != null && node.PreviousSibling.Name != "br") {
result += "\n"; result += "\n";
} }
if(node.ParentNode != null) { if(node.ParentNode != null) {
if(node.ParentNode.Name.ToLowerInvariant() != "td") result += ProcessList(node.ChildNodes, "*"); if(node.ParentNode.Name != "td") result += ProcessList(node.ChildNodes, "*");
else result += node.OuterXml.ToString(); else result += node.OuterXml.ToString();
} }
else result += ProcessList(node.ChildNodes, "*"); else result += ProcessList(node.ChildNodes, "*");
@ -323,8 +326,9 @@ namespace ScrewTurn.Wiki {
else if(node.Attributes["class"].Value.Contains("indent")) result += ": " + ProcessChild(node.ChildNodes) + "\n"; else if(node.Attributes["class"].Value.Contains("indent")) result += ": " + ProcessChild(node.ChildNodes) + "\n";
} }
else { else {
result += "\n";
if(node.PreviousSibling != null && node.PreviousSibling.Name != "div") { if(node.PreviousSibling != null && node.PreviousSibling.Name != "div") {
result += Settings.ProcessSingleLineBreaks ? "\n" : "\n\n"; result += Settings.ProcessSingleLineBreaks ? "" : "\n";
} }
if(node.FirstChild != null && node.FirstChild.Name == "br") { if(node.FirstChild != null && node.FirstChild.Name == "br") {
node.RemoveChild(node.FirstChild); node.RemoveChild(node.FirstChild);