Fixed \r\n in reverse formatter.

This commit is contained in:
Matteo Tomasini 2011-04-01 16:29:35 +02:00
parent 7c14f9f49e
commit 0cbcd0918b
2 changed files with 55 additions and 55 deletions

View file

@ -13,48 +13,48 @@ namespace ScrewTurn.Wiki.Tests {
[TestCase("<b>text</b>", "'''text'''")] [TestCase("<b>text</b>", "'''text'''")]
[TestCase("<strong>text</strong>", "'''text'''")] [TestCase("<strong>text</strong>", "'''text'''")]
[TestCase("<i>text</i>", "''text''")] [TestCase("<i>text</i>", "''text''")]
[TestCase("<ul><li>prova <b>pippo</b></li><li>riga2</li></ul>", "* prova '''pippo'''\r\n* riga2\r\n")] [TestCase("<ul><li>prova <b>pippo</b></li><li>riga2</li></ul>", "* prova '''pippo'''\n* riga2\n")]
[TestCase("<em>text</em>", "''text''")] [TestCase("<em>text</em>", "''text''")]
[TestCase("<u>text</u>", "__text__")] [TestCase("<u>text</u>", "__text__")]
[TestCase("<s>text</s>", "--text--")] [TestCase("<s>text</s>", "--text--")]
[TestCase("<html><table border=\"1\" bgcolor=\"LightBlue\"><thead><tr><th>Cells x.1</th><th>Cells x.2</th></tr></thead><tbody><tr><td>Cell 1.1</td><td>Cell 1.2</td></tr><tr><td>Cell 2.1</td><td>Cell 2.2</td></tr></tbody></table></html>", "{| border=\"1\" bgcolor=\"LightBlue\" \r\n|- \r\n! Cells x.1\r\n! Cells x.2\r\n|- \r\n| Cell 1.1\r\n| Cell 1.2\r\n|- \r\n| Cell 2.1\r\n| Cell 2.2\r\n|}\r\n")] [TestCase("<html><table border=\"1\" bgcolor=\"LightBlue\"><thead><tr><th>Cells x.1</th><th>Cells x.2</th></tr></thead><tbody><tr><td>Cell 1.1</td><td>Cell 1.2</td></tr><tr><td>Cell 2.1</td><td>Cell 2.2</td></tr></tbody></table></html>", "{| border=\"1\" bgcolor=\"LightBlue\" \n|- \n! Cells x.1\n! Cells x.2\n|- \n| Cell 1.1\n| Cell 1.2\n|- \n| Cell 2.1\n| Cell 2.2\n|}\n")]
[TestCase("<ol><li><a class=\"internallink\" target=\"_blank\" href=\"www.try.com\" title=\"try\">try</a></li><li><a class=\"internallink\" target=\"_blank\" href=\"www.secondtry.com\" title=\"www.secondtry.com\">www.secondtry.com</a><br></li></ol>","# [^www.try.com|try]\r\n# [^www.secondtry.com|www.secondtry.com]\r\n")] [TestCase("<ol><li><a class=\"internallink\" target=\"_blank\" href=\"www.try.com\" title=\"try\">try</a></li><li><a class=\"internallink\" target=\"_blank\" href=\"www.secondtry.com\" title=\"www.secondtry.com\">www.secondtry.com</a><br></li></ol>","# [^www.try.com|try]\n# [^www.secondtry.com|www.secondtry.com]\n")]
[TestCase("<table><tbody><tr><td bgcolor=\"Blue\">Styled Cell</td><td>Normal cell</td></tr><tr><td>Normal cell</td><td bgcolor=\"Yellow\">Styled cell</td></tr></tbody></table>", "{| \r\n|- \r\n| bgcolor=\"Blue\" | Styled Cell\r\n| Normal cell\r\n|- \r\n| Normal cell\r\n| bgcolor=\"Yellow\" | Styled cell\r\n|}\r\n")] [TestCase("<table><tbody><tr><td bgcolor=\"Blue\">Styled Cell</td><td>Normal cell</td></tr><tr><td>Normal cell</td><td bgcolor=\"Yellow\">Styled cell</td></tr></tbody></table>", "{| \n|- \n| bgcolor=\"Blue\" | Styled Cell\n| Normal cell\n|- \n| Normal cell\n| bgcolor=\"Yellow\" | Styled cell\n|}\n")]
[TestCase("<h1>text</h1>", "==text==\r\n")] [TestCase("<h1>text</h1>", "==text==\n")]
[TestCase("<h2>text</h2>", "===text===\r\n")] [TestCase("<h2>text</h2>", "===text===\n")]
[TestCase("<h3>text</h3>", "====text====\r\n")] [TestCase("<h3>text</h3>", "====text====\n")]
[TestCase("<h4>text</s>", "=====text=====\r\n")] [TestCase("<h4>text</s>", "=====text=====\n")]
[TestCase("<code>inline code - monospace font</code>", "{{inline code - monospace font}}")] [TestCase("<code>inline code - monospace font</code>", "{{inline code - monospace font}}")]
[TestCase("<h1></h1>", "----\r\n")] [TestCase("<h1></h1>", "----\n")]
[TestCase("<h1> </h1>", "----\r\n")] [TestCase("<h1> </h1>", "----\n")]
[TestCase("<sup>text</sup>", "<sup>text</sup>")] [TestCase("<sup>text</sup>", "<sup>text</sup>")]
[TestCase("<sub>text</sub>", "<sub>text</sub>")] [TestCase("<sub>text</sub>", "<sub>text</sub>")]
[TestCase("<pre><b>text</b></pre>", "@@text@@")] [TestCase("<pre><b>text</b></pre>", "@@text@@")]
[TestCase("<div class=\"indent\" style=\"margin: 0px; padding: 0px; padding-left: 15px\">text</div>", ": text\r\n")] [TestCase("<div class=\"indent\" style=\"margin: 0px; padding: 0px; padding-left: 15px\">text</div>", ": text\n")]
[TestCase("<a href=\"Help.AllPages.aspx?Cat=Help.Wiki\" class=\"systemlink\" title=\"Help.Wiki\">Help.Wiki</a>", "[c:Help.Wiki|Help.Wiki]")] [TestCase("<a href=\"Help.AllPages.aspx?Cat=Help.Wiki\" class=\"systemlink\" title=\"Help.Wiki\">Help.Wiki</a>", "[c:Help.Wiki|Help.Wiki]")]
[TestCase("<code><b>text</b></code>", "{{'''text'''}}")] [TestCase("<code><b>text</b></code>", "{{'''text'''}}")]
[TestCase("<div class=\"box\">text</div>", "(((text)))\r\n")] [TestCase("<div class=\"box\">text</div>", "(((text)))\n")]
[TestCase("<div>text</div>", "text\r\n")] [TestCase("<div>text</div>", "text\n")]
[TestCase("<html>riga1\r\n<b>riga2</b>\r\nriga3</html>", "riga1\r\n'''riga2'''\r\nriga3")] [TestCase("<html>riga1\n<b>riga2</b>\nriga3</html>", "riga1\n'''riga2'''\nriga3")]
[TestCase("<html><ol><li>1</li><li>2</li><li>3<ol><li>3.1</li><li>3.2<ol><li>3.2.1</li></ol></li><li>3.3</li></ol></li><li>4 ciao</li></ol><br /></html>", "# 1\r\n# 2\r\n# 3\r\n## 3.1\r\n## 3.2\r\n### 3.2.1\r\n## 3.3\r\n# 4 ciao\r\n\r\n")] [TestCase("<html><ol><li>1</li><li>2</li><li>3<ol><li>3.1</li><li>3.2<ol><li>3.2.1</li></ol></li><li>3.3</li></ol></li><li>4 ciao</li></ol><br /></html>", "# 1\n# 2\n# 3\n## 3.1\n## 3.2\n### 3.2.1\n## 3.3\n# 4 ciao\n\n")]
[TestCase("<ol><li>1</li><li>2</li></ol>", "# 1\r\n# 2\r\n")] [TestCase("<ol><li>1</li><li>2</li></ol>", "# 1\n# 2\n")]
[TestCase("<ul><li><img src=\"GetFile.aspx?File=/AmanuensMicro.png\" alt=\"Image\"></li><li><div class=\"imageleft\"><img class=\"image\" src=\"GetFile.aspx?File=/DownloadButton.png\" alt=\"Image\"></div></li><li><div class=\"imageright\"><a target=\"_blank\" href=\"www.tututu.tu\" title=\"guihojk\"><img class=\"image\" src=\"GetFile.aspx?File=/Checked.png\" alt=\"guihojk\"></a><p class=\"imagedescription\">guihojk</p></div></li><li><table class=\"imageauto\" cellpadding=\"0\" cellspacing=\"0\"><tbody><tr><td><img class=\"image\" src=\"GetFile.aspx?File=/Alert.png\" alt=\"auto\"><p class=\"imagedescription\">auto</p></td></tr></tbody></table><br></li></ul>", "* [image|Image|{UP}/AmanuensMicro.png]\r\n* [imageleft||{UP}/DownloadButton.png]\r\n* [imageright|guihojk|{UP}/Checked.png|^www.tututu.tu]\r\n* [imageauto|auto|{UP}/Alert.png]\r\n\r\n")] [TestCase("<ul><li><img src=\"GetFile.aspx?File=/AmanuensMicro.png\" alt=\"Image\"></li><li><div class=\"imageleft\"><img class=\"image\" src=\"GetFile.aspx?File=/DownloadButton.png\" alt=\"Image\"></div></li><li><div class=\"imageright\"><a target=\"_blank\" href=\"www.tututu.tu\" title=\"guihojk\"><img class=\"image\" src=\"GetFile.aspx?File=/Checked.png\" alt=\"guihojk\"></a><p class=\"imagedescription\">guihojk</p></div></li><li><table class=\"imageauto\" cellpadding=\"0\" cellspacing=\"0\"><tbody><tr><td><img class=\"image\" src=\"GetFile.aspx?File=/Alert.png\" alt=\"auto\"><p class=\"imagedescription\">auto</p></td></tr></tbody></table><br></li></ul>", "* [image|Image|{UP}/AmanuensMicro.png]\n* [imageleft||{UP}/DownloadButton.png]\n* [imageright|guihojk|{UP}/Checked.png|^www.tututu.tu]\n* [imageauto|auto|{UP}/Alert.png]\n\n")]
[TestCase("<ul><li>1</li><li>2</li></ul>", "* 1\r\n* 2\r\n")] [TestCase("<ul><li>1</li><li>2</li></ul>", "* 1\n* 2\n")]
[TestCase("<div class=\"imageright\"><img class=\"image\" src=\"GetFile.aspx?File=/Help/Desktop/image.png\"><p class=\"imagedescription\">description</p></div>", "[imageright|description|{UP}/Help/Desktop/image.png]\r\n")] [TestCase("<div class=\"imageright\"><img class=\"image\" src=\"GetFile.aspx?File=/Help/Desktop/image.png\"><p class=\"imagedescription\">description</p></div>", "[imageright|description|{UP}/Help/Desktop/image.png]\n")]
[TestCase("<html><ul><li>Punto 1</li><li>Punto 2</li><li>Punto 3</li><li>Punto 4</li><li>Punto 5</li></ul></html>", "* Punto 1\r\n* Punto 2\r\n* Punto 3\r\n* Punto 4\r\n* Punto 5\r\n")] [TestCase("<html><ul><li>Punto 1</li><li>Punto 2</li><li>Punto 3</li><li>Punto 4</li><li>Punto 5</li></ul></html>", "* Punto 1\n* Punto 2\n* Punto 3\n* Punto 4\n* Punto 5\n")]
[TestCase("<ul><li>it 1<ul><li>1.1</li><li>1.2</li></ul></li><li>it2</li></ul>", "* it 1\r\n** 1.1\r\n** 1.2\r\n* it2\r\n")] [TestCase("<ul><li>it 1<ul><li>1.1</li><li>1.2</li></ul></li><li>it2</li></ul>", "* it 1\n** 1.1\n** 1.2\n* it2\n")]
[TestCase("<ul><li>it 1<ol><li>1.1</li><li>1.2</li></ol></li><li>it2</li></ul>", "* it 1\r\n*# 1.1\r\n*# 1.2\r\n* it2\r\n")] [TestCase("<ul><li>it 1<ol><li>1.1</li><li>1.2</li></ol></li><li>it2</li></ul>", "* it 1\n*# 1.1\n*# 1.2\n* it2\n")]
[TestCase("<ul><li><b>1</b></li><li>2</li></ul>", "* '''1'''\r\n* 2\r\n")] [TestCase("<ul><li><b>1</b></li><li>2</li></ul>", "* '''1'''\n* 2\n")]
[TestCase("<html><a id=\"Init\" />I'm an anchor</html>", "[anchor|#init]I'm an anchor")] [TestCase("<html><a id=\"Init\" />I'm an anchor</html>", "[anchor|#init]I'm an anchor")]
[TestCase("<html><a class=\"internallink\" href=\"#init\" title=\"This recall an anchor\">This recall an anchor</a></html>", "[#init|This recall an anchor]")] [TestCase("<html><a class=\"internallink\" href=\"#init\" title=\"This recall an anchor\">This recall an anchor</a></html>", "[#init|This recall an anchor]")]
[TestCase("<html><a class=\"externallink\" href=\"google.com\" title=\"BIG TITLE\" target=\"_blank\">BIG TITLE</a></html>", "[^google.com|BIG TITLE]")] [TestCase("<html><a class=\"externallink\" href=\"google.com\" title=\"BIG TITLE\" target=\"_blank\">BIG TITLE</a></html>", "[^google.com|BIG TITLE]")]
[TestCase("<esc>try to esc tag</esc>", "<esc>try to esc tag</esc>")] [TestCase("<esc>try to esc tag</esc>", "<esc>try to esc tag</esc>")]
[TestCase("<div class=\"imageleft\"><a target=\"_blank\" href=\"www.link.com\" title=\"left Align\"><img class=\"image\" src=\"GetFile.aspx?Page=MainPage&File=image.png\" alt=\"left Align\" /></a><p class=\"imagedescription\">leftalign</p></div>", "[imageleft|leftalign|{UP(MainPage)}image.png|^www.link.com]\r\n")] [TestCase("<div class=\"imageleft\"><a target=\"_blank\" href=\"www.link.com\" title=\"left Align\"><img class=\"image\" src=\"GetFile.aspx?Page=MainPage&File=image.png\" alt=\"left Align\" /></a><p class=\"imagedescription\">leftalign</p></div>", "[imageleft|leftalign|{UP(MainPage)}image.png|^www.link.com]\n")]
[TestCase("<img src=\"GetFile.aspx?Page=MainPage&File=image.png\" alt=\"inlineimage\" />", "[image|inlineimage|{UP(MainPage)}image.png]\r\n")] [TestCase("<img src=\"GetFile.aspx?Page=MainPage&File=image.png\" alt=\"inlineimage\" />", "[image|inlineimage|{UP(MainPage)}image.png]\n")]
[TestCase("<a target=\"_blank\" href=\"www.google.it\" title=\"description\"><img src=\"GetFile.aspx?Page=MainPage&File=image.png\" alt=\"description\" /></a>", "[image|description|{UP(MainPage)}image.png|^www.google.it]\r\n")] [TestCase("<a target=\"_blank\" href=\"www.google.it\" title=\"description\"><img src=\"GetFile.aspx?Page=MainPage&File=image.png\" alt=\"description\" /></a>", "[image|description|{UP(MainPage)}image.png|^www.google.it]\n")]
[TestCase("<table class=\"imageauto\" cellpadding=\"0\" cellspacing=\"0\"><tbody><tr><td><img class=\"image\" src=\"GetFile.aspx?Page=MainPage&File=image.png\" alt=\"autoalign\" /><p class=\"imagedescription\">autoalign</p></td></tr></tbody></table>", "[imageauto|autoalign|{UP(MainPage)}image.png]\r\n")] [TestCase("<table class=\"imageauto\" cellpadding=\"0\" cellspacing=\"0\"><tbody><tr><td><img class=\"image\" src=\"GetFile.aspx?Page=MainPage&File=image.png\" alt=\"autoalign\" /><p class=\"imagedescription\">autoalign</p></td></tr></tbody></table>", "[imageauto|autoalign|{UP(MainPage)}image.png]\n")]
[TestCase("<table class=\"imageauto\" cellpadding=\"0\" cellspacing=\"0\"><tbody><tr><td><a href=\"www.link.com\" title=\"Auto align\"><img class=\"image\" src=\"GetFile.aspx?Page=MainPage&File=image.png\" alt=\"Auto align\" /></a><p class=\"imagedescription\">Auto align</p></td></tr></tbody></table>", "[imageauto|Auto align|{UP(MainPage)}image.png|www.link.com]\r\n")] [TestCase("<table class=\"imageauto\" cellpadding=\"0\" cellspacing=\"0\"><tbody><tr><td><a href=\"www.link.com\" title=\"Auto align\"><img class=\"image\" src=\"GetFile.aspx?Page=MainPage&File=image.png\" alt=\"Auto align\" /></a><p class=\"imagedescription\">Auto align</p></td></tr></tbody></table>", "[imageauto|Auto align|{UP(MainPage)}image.png|www.link.com]\n")]
[TestCase("<table cellspacing=\"0\" cellpadding=\"2\" style=\"background-color: #EEEEEE; margin: 0px auto;\"><caption>Styled Table</caption><tbody><tr style=\"background-color: #990000; color: #FFFFFF;\"><td>This is a cell</td><td>This is a cell</td><td>This is a cell</td></tr><tr><td style=\"background-color: #000000; color: #CCCCCC;\">Styled cell</td><td style=\"border: solid 1px #FF0000;\">Styled cell</td><td><b>Normal cell</b></td></tr><tr><td>Normal</td><td>Normal</td><td><a class=\"internallink\" href=\"Download.ashx\" title=\"Download\">Download</a></td></tr></tbody></table>","{| cellspacing=\"0\" cellpadding=\"2\" style=\"background-color: #EEEEEE; margin: 0px auto;\" \r\n|+ Styled Table\r\n|- style=\"background-color: #990000; color: #FFFFFF;\" \r\n| This is a cell\r\n| This is a cell\r\n| This is a cell\r\n|- \r\n| style=\"background-color: #000000; color: #CCCCCC;\" | Styled cell\r\n| style=\"border: solid 1px #FF0000;\" | Styled cell\r\n| '''Normal cell'''\r\n|- \r\n| Normal\r\n| Normal\r\n| [Download.ashx|Download]\r\n|}\r\n")] [TestCase("<table cellspacing=\"0\" cellpadding=\"2\" style=\"background-color: #EEEEEE; margin: 0px auto;\"><caption>Styled Table</caption><tbody><tr style=\"background-color: #990000; color: #FFFFFF;\"><td>This is a cell</td><td>This is a cell</td><td>This is a cell</td></tr><tr><td style=\"background-color: #000000; color: #CCCCCC;\">Styled cell</td><td style=\"border: solid 1px #FF0000;\">Styled cell</td><td><b>Normal cell</b></td></tr><tr><td>Normal</td><td>Normal</td><td><a class=\"internallink\" href=\"Download.ashx\" title=\"Download\">Download</a></td></tr></tbody></table>","{| cellspacing=\"0\" cellpadding=\"2\" style=\"background-color: #EEEEEE; margin: 0px auto;\" \n|+ Styled Table\n|- style=\"background-color: #990000; color: #FFFFFF;\" \n| This is a cell\n| This is a cell\n| This is a cell\n|- \n| style=\"background-color: #000000; color: #CCCCCC;\" | Styled cell\n| style=\"border: solid 1px #FF0000;\" | Styled cell\n| '''Normal cell'''\n|- \n| Normal\n| Normal\n| [Download.ashx|Download]\n|}\n")]
[TestCase("<pre>block code - [WikiMarkup] is ignored</pre>", "@@block code - [WikiMarkup] is ignored@@")] [TestCase("<pre>block code - [WikiMarkup] is ignored</pre>", "@@block code - [WikiMarkup] is ignored@@")]
public void PlainTest(string input, string output) { public void PlainTest(string input, string output) {
Assert.AreEqual(output, ReverseFormatter.ReverseFormat(input)); Assert.AreEqual(output, ReverseFormatter.ReverseFormat(input));

View file

@ -30,7 +30,7 @@ namespace ScrewTurn.Wiki {
} }
} }
result += marker + " " + text; result += marker + " " + text;
if(!result.EndsWith("\r\n")) result += "\r\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.ToString() == "ol") result += ProcessList(child.ChildNodes, marker + ol);
if(child.Name.ToString() == "ul") result += ProcessList(child.ChildNodes, marker + ul); if(child.Name.ToString() == "ul") result += ProcessList(child.ChildNodes, marker + ul);
@ -157,10 +157,10 @@ namespace ScrewTurn.Wiki {
result += ProcessTable(node.ChildNodes); result += ProcessTable(node.ChildNodes);
break; break;
case "th": case "th":
result += "! " + ProcessChild(node.ChildNodes) + "\r\n"; result += "! " + ProcessChild(node.ChildNodes) + "\n";
break; break;
case "caption": case "caption":
result += "|+ " + ProcessChild(node.ChildNodes) + "\r\n"; result += "|+ " + ProcessChild(node.ChildNodes) + "\n";
break; break;
case "tbody": case "tbody":
result += ProcessTable(node.ChildNodes) + ""; result += ProcessTable(node.ChildNodes) + "";
@ -170,7 +170,7 @@ namespace ScrewTurn.Wiki {
foreach(XmlAttribute attr in node.Attributes) { foreach(XmlAttribute attr in node.Attributes) {
if(attr.Name.ToLowerInvariant() == "style") style += "style=\"" + attr.Value.ToString() + "\" "; if(attr.Name.ToLowerInvariant() == "style") style += "style=\"" + attr.Value.ToString() + "\" ";
} }
result += "|- " + style + "\r\n" + ProcessTable(node.ChildNodes); result += "|- " + style + "\n" + ProcessTable(node.ChildNodes);
break; break;
case "td": case "td":
string styleTd = ""; string styleTd = "";
@ -178,9 +178,9 @@ namespace ScrewTurn.Wiki {
foreach(XmlAttribute attr in node.Attributes) { foreach(XmlAttribute attr in node.Attributes) {
styleTd += " " + attr.Name + "=\"" + attr.Value.ToString() + "\" "; styleTd += " " + attr.Name + "=\"" + attr.Value.ToString() + "\" ";
} }
result += "| " + styleTd + " | " + ProcessChild(node.ChildNodes) + "\r\n"; result += "| " + styleTd + " | " + ProcessChild(node.ChildNodes) + "\n";
} }
else result += "| " + ProcessChild(node.ChildNodes) + "\r\n"; else result += "| " + ProcessChild(node.ChildNodes) + "\n";
break; break;
} }
} }
@ -214,19 +214,19 @@ namespace ScrewTurn.Wiki {
break; break;
case "h1": case "h1":
if(node.HasChildNodes) { if(node.HasChildNodes) {
if(node.FirstChild.NodeType == XmlNodeType.Whitespace) result += "----\r\n" + ProcessChild(node.ChildNodes); if(node.FirstChild.NodeType == XmlNodeType.Whitespace) result += "----\n" + ProcessChild(node.ChildNodes);
else result += "==" + ProcessChild(node.ChildNodes) + "==\r\n"; else result += "==" + ProcessChild(node.ChildNodes) + "==\n";
} }
else result += "----\r\n"; else result += "----\n";
break; break;
case "h2": case "h2":
result += "===" + ProcessChild(node.ChildNodes) + "===\r\n"; result += "===" + ProcessChild(node.ChildNodes) + "===\n";
break; break;
case "h3": case "h3":
result += "====" + ProcessChild(node.ChildNodes) + "====\r\n"; result += "====" + ProcessChild(node.ChildNodes) + "====\n";
break; break;
case "h4": case "h4":
result += "=====" + ProcessChild(node.ChildNodes) + "=====\r\n"; result += "=====" + ProcessChild(node.ChildNodes) + "=====\n";
break; break;
case "pre": case "pre":
result += "@@" + node.InnerText.ToString() + "@@"; result += "@@" + node.InnerText.ToString() + "@@";
@ -236,7 +236,7 @@ namespace ScrewTurn.Wiki {
break; break;
case "hr": case "hr":
case "hr /": case "hr /":
result += "\r\n== ==\r\n" + ProcessChild(node.ChildNodes); result += "\n== ==\n" + ProcessChild(node.ChildNodes);
break; break;
case "span": case "span":
if(node.Attributes.Count != 0) { if(node.Attributes.Count != 0) {
@ -247,7 +247,7 @@ namespace ScrewTurn.Wiki {
} }
break; break;
case "br": case "br":
result += "\r\n" + ProcessChild(node.ChildNodes); result += "\n" + ProcessChild(node.ChildNodes);
break; break;
case "table": case "table":
bool isImage = false; bool isImage = false;
@ -257,7 +257,7 @@ namespace ScrewTurn.Wiki {
foreach(XmlAttribute attName in node.Attributes) { foreach(XmlAttribute attName in node.Attributes) {
if(attName.Value.ToString() == "imageauto") { if(attName.Value.ToString() == "imageauto") {
isImage = true; isImage = true;
image += "[imageauto|" + ProcessTableImage(node.ChildNodes) + "]\r\n"; image += "[imageauto|" + ProcessTableImage(node.ChildNodes) + "]\n";
} }
else tableStyle += attName.Name + "=\"" + attName.Value.ToString() + "\" "; else tableStyle += attName.Name + "=\"" + attName.Value.ToString() + "\" ";
} }
@ -266,7 +266,7 @@ namespace ScrewTurn.Wiki {
isImage = false; isImage = false;
break; break;
} }
else result += "{| " + tableStyle + "\r\n" + ProcessTable(node.ChildNodes) + "|}\r\n"; else result += "{| " + tableStyle + "\n" + ProcessTable(node.ChildNodes) + "|}\n";
break; break;
case "ol": case "ol":
if(node.ParentNode != null) { if(node.ParentNode != null) {
@ -295,20 +295,20 @@ namespace ScrewTurn.Wiki {
if(attName.Value.ToString() == "imagedescription") result += ""; if(attName.Value.ToString() == "imagedescription") result += "";
} }
} }
else result += ProcessChild(node.ChildNodes) + "{BR}\r\n"; else result += ProcessChild(node.ChildNodes) + "{BR}\n";
break; break;
case "div": case "div":
if(node.Attributes.Count != 0) { if(node.Attributes.Count != 0) {
XmlAttributeCollection attribute = node.Attributes; XmlAttributeCollection attribute = node.Attributes;
foreach(XmlAttribute attName in attribute) { foreach(XmlAttribute attName in attribute) {
if(attName.Value.ToString() == "box") result += "(((" + ProcessChild(node.ChildNodes) + ")))\r\n"; if(attName.Value.ToString() == "box") result += "(((" + ProcessChild(node.ChildNodes) + ")))\n";
if(attName.Value.ToString() == "imageleft") result += "[imageleft" + ProcessChildImage(node.ChildNodes) + "]\r\n"; if(attName.Value.ToString() == "imageleft") result += "[imageleft" + ProcessChildImage(node.ChildNodes) + "]\n";
if(attName.Value.ToString() == "imageright") result += "[imageright" + ProcessChildImage(node.ChildNodes) + "]\r\n"; if(attName.Value.ToString() == "imageright") result += "[imageright" + ProcessChildImage(node.ChildNodes) + "]\n";
if(attName.Value.ToString() == "image") result += "[image" + ProcessChildImage(node.ChildNodes) + "]\r\n"; if(attName.Value.ToString() == "image") result += "[image" + ProcessChildImage(node.ChildNodes) + "]\n";
if(attName.Value.ToString() == "indent") result += ": " + ProcessChild(node.ChildNodes) + "\r\n"; if(attName.Value.ToString() == "indent") result += ": " + ProcessChild(node.ChildNodes) + "\n";
} }
} }
else result += (ProcessChild(node.ChildNodes) + "\r\n"); else result += (ProcessChild(node.ChildNodes) + "\n");
break; break;
case "img": case "img":
string description = ""; string description = "";
@ -321,7 +321,7 @@ namespace ScrewTurn.Wiki {
if(attName.Name.ToString() == "class") hasClass = true; if(attName.Name.ToString() == "class") hasClass = true;
} }
} }
if(!hasClass && !isLink) result += "[image|" + description + "|" + ProcessImage(node) + "]\r\n"; if(!hasClass && !isLink) result += "[image|" + description + "|" + ProcessImage(node) + "]\n";
else if(!hasClass && isLink) result += "[image|" + description + "|" + ProcessImage(node); else if(!hasClass && isLink) result += "[image|" + description + "|" + ProcessImage(node);
else result += description + "|" + ProcessImage(node); else result += description + "|" + ProcessImage(node);
break; break;
@ -360,11 +360,11 @@ namespace ScrewTurn.Wiki {
if(title != link) result += "[" + target + link + "|" + ProcessChild(node.ChildNodes) + "]"; if(title != link) result += "[" + target + link + "|" + ProcessChild(node.ChildNodes) + "]";
else result += "[" + target + link + "|" + ProcessChild(node.ChildNodes) + "]"; else result += "[" + target + link + "|" + ProcessChild(node.ChildNodes) + "]";
if(!anchor && !childImg && isTable) result += "[" + target + link + "|" + ProcessChild(node.ChildNodes) + "]"; if(!anchor && !childImg && isTable) result += "[" + target + link + "|" + ProcessChild(node.ChildNodes) + "]";
if(!anchor && childImg && !isTable) result += ProcessChild(node.ChildNodes) + "|" + target + link + "]\r\n"; if(!anchor && childImg && !isTable) result += ProcessChild(node.ChildNodes) + "|" + target + link + "]\n";
} }
break; break;
default: default:
result += (node.OuterXml); result += node.OuterXml;
break; break;
} }
} }