diff --git a/Core-Tests/ReverseFormatterTests.cs b/Core-Tests/ReverseFormatterTests.cs
index 9ea2da6..cd2cda4 100644
--- a/Core-Tests/ReverseFormatterTests.cs
+++ b/Core-Tests/ReverseFormatterTests.cs
@@ -13,48 +13,48 @@ namespace ScrewTurn.Wiki.Tests {
[TestCase("text", "'''text'''")]
[TestCase("text", "'''text'''")]
[TestCase("text", "''text''")]
- [TestCase("
", "* prova '''pippo'''\r\n* riga2\r\n")]
+ [TestCase("", "* prova '''pippo'''\n* riga2\n")]
[TestCase("text", "''text''")]
[TestCase("text", "__text__")]
[TestCase("text", "--text--")]
- [TestCase("Cells x.1 | Cells x.2 |
---|
Cell 1.1 | Cell 1.2 |
Cell 2.1 | Cell 2.2 |
", "{| 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("- try
- www.secondtry.com
","# [^www.try.com|try]\r\n# [^www.secondtry.com|www.secondtry.com]\r\n")]
- [TestCase("Styled Cell | Normal cell |
Normal cell | Styled cell |
", "{| \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("text
", "==text==\r\n")]
- [TestCase("text
", "===text===\r\n")]
- [TestCase("text
", "====text====\r\n")]
- [TestCase("text", "=====text=====\r\n")]
+ [TestCase("
Cells x.1 | Cells x.2 |
---|
Cell 1.1 | Cell 1.2 |
Cell 2.1 | Cell 2.2 |
", "{| 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("- try
- www.secondtry.com
","# [^www.try.com|try]\n# [^www.secondtry.com|www.secondtry.com]\n")]
+ [TestCase("Styled Cell | Normal cell |
Normal cell | Styled cell |
", "{| \n|- \n| bgcolor=\"Blue\" | Styled Cell\n| Normal cell\n|- \n| Normal cell\n| bgcolor=\"Yellow\" | Styled cell\n|}\n")]
+ [TestCase("text
", "==text==\n")]
+ [TestCase("text
", "===text===\n")]
+ [TestCase("text
", "====text====\n")]
+ [TestCase("text", "=====text=====\n")]
[TestCase("inline code - monospace font
", "{{inline code - monospace font}}")]
- [TestCase("", "----\r\n")]
- [TestCase("
", "----\r\n")]
+ [TestCase("", "----\n")]
+ [TestCase("
", "----\n")]
[TestCase("text", "text")]
[TestCase("text", "text")]
[TestCase("text
", "@@text@@")]
- [TestCase("
text
", ": text\r\n")]
+ [TestCase("text
", ": text\n")]
[TestCase("Help.Wiki", "[c:Help.Wiki|Help.Wiki]")]
[TestCase("text
", "{{'''text'''}}")]
- [TestCase("text
", "(((text)))\r\n")]
- [TestCase("text
", "text\r\n")]
- [TestCase("riga1\r\nriga2\r\nriga3", "riga1\r\n'''riga2'''\r\nriga3")]
- [TestCase("- 1
- 2
- 3
- 3.1
- 3.2
- 3.2.1
- 3.3
- 4 ciao
", "# 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("- 1
- 2
", "# 1\r\n# 2\r\n")]
- [TestCase("", "* [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("", "* 1\r\n* 2\r\n")]
- [TestCase("
description
", "[imageright|description|{UP}/Help/Desktop/image.png]\r\n")]
- [TestCase("- Punto 1
- Punto 2
- Punto 3
- Punto 4
- Punto 5
", "* Punto 1\r\n* Punto 2\r\n* Punto 3\r\n* Punto 4\r\n* Punto 5\r\n")]
- [TestCase("", "* it 1\r\n** 1.1\r\n** 1.2\r\n* it2\r\n")]
- [TestCase("", "* it 1\r\n*# 1.1\r\n*# 1.2\r\n* it2\r\n")]
- [TestCase("", "* '''1'''\r\n* 2\r\n")]
+ [TestCase("text
", "(((text)))\n")]
+ [TestCase("text
", "text\n")]
+ [TestCase("riga1\nriga2\nriga3", "riga1\n'''riga2'''\nriga3")]
+ [TestCase("- 1
- 2
- 3
- 3.1
- 3.2
- 3.2.1
- 3.3
- 4 ciao
", "# 1\n# 2\n# 3\n## 3.1\n## 3.2\n### 3.2.1\n## 3.3\n# 4 ciao\n\n")]
+ [TestCase("- 1
- 2
", "# 1\n# 2\n")]
+ [TestCase("", "* [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("", "* 1\n* 2\n")]
+ [TestCase("
description
", "[imageright|description|{UP}/Help/Desktop/image.png]\n")]
+ [TestCase("- Punto 1
- Punto 2
- Punto 3
- Punto 4
- Punto 5
", "* Punto 1\n* Punto 2\n* Punto 3\n* Punto 4\n* Punto 5\n")]
+ [TestCase("", "* it 1\n** 1.1\n** 1.2\n* it2\n")]
+ [TestCase("", "* it 1\n*# 1.1\n*# 1.2\n* it2\n")]
+ [TestCase("", "* '''1'''\n* 2\n")]
[TestCase("I'm an anchor", "[anchor|#init]I'm an anchor")]
[TestCase("This recall an anchor", "[#init|This recall an anchor]")]
[TestCase("BIG TITLE", "[^google.com|BIG TITLE]")]
[TestCase("try to esc tag", "try to esc tag")]
- [TestCase("
leftalign
", "[imageleft|leftalign|{UP(MainPage)}image.png|^www.link.com]\r\n")]
- [TestCase("
", "[image|inlineimage|{UP(MainPage)}image.png]\r\n")]
- [TestCase("
", "[image|description|{UP(MainPage)}image.png|^www.google.it]\r\n")]
- [TestCase(" autoalign |
", "[imageauto|autoalign|{UP(MainPage)}image.png]\r\n")]
- [TestCase(" Auto align |
", "[imageauto|Auto align|{UP(MainPage)}image.png|www.link.com]\r\n")]
- [TestCase("Styled TableThis is a cell | This is a cell | This is a cell |
Styled cell | Styled cell | Normal cell |
Normal | Normal | Download |
","{| 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("
leftalign
", "[imageleft|leftalign|{UP(MainPage)}image.png|^www.link.com]\n")]
+ [TestCase("
", "[image|inlineimage|{UP(MainPage)}image.png]\n")]
+ [TestCase("
", "[image|description|{UP(MainPage)}image.png|^www.google.it]\n")]
+ [TestCase(" autoalign |
", "[imageauto|autoalign|{UP(MainPage)}image.png]\n")]
+ [TestCase(" Auto align |
", "[imageauto|Auto align|{UP(MainPage)}image.png|www.link.com]\n")]
+ [TestCase("Styled TableThis is a cell | This is a cell | This is a cell |
Styled cell | Styled cell | Normal cell |
Normal | Normal | Download |
","{| 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("block code - [WikiMarkup] is ignored
", "@@block code - [WikiMarkup] is ignored@@")]
public void PlainTest(string input, string output) {
Assert.AreEqual(output, ReverseFormatter.ReverseFormat(input));
diff --git a/Core/ReverseFormatter.cs b/Core/ReverseFormatter.cs
index ab647fc..a15267c 100644
--- a/Core/ReverseFormatter.cs
+++ b/Core/ReverseFormatter.cs
@@ -30,7 +30,7 @@ namespace ScrewTurn.Wiki {
}
}
result += marker + " " + text;
- if(!result.EndsWith("\r\n")) result += "\r\n";
+ if(!result.EndsWith("\n")) result += "\n";
foreach(XmlNode child in node.ChildNodes) {
if(child.Name.ToString() == "ol") result += ProcessList(child.ChildNodes, marker + ol);
if(child.Name.ToString() == "ul") result += ProcessList(child.ChildNodes, marker + ul);
@@ -157,10 +157,10 @@ namespace ScrewTurn.Wiki {
result += ProcessTable(node.ChildNodes);
break;
case "th":
- result += "! " + ProcessChild(node.ChildNodes) + "\r\n";
+ result += "! " + ProcessChild(node.ChildNodes) + "\n";
break;
case "caption":
- result += "|+ " + ProcessChild(node.ChildNodes) + "\r\n";
+ result += "|+ " + ProcessChild(node.ChildNodes) + "\n";
break;
case "tbody":
result += ProcessTable(node.ChildNodes) + "";
@@ -170,7 +170,7 @@ namespace ScrewTurn.Wiki {
foreach(XmlAttribute attr in node.Attributes) {
if(attr.Name.ToLowerInvariant() == "style") style += "style=\"" + attr.Value.ToString() + "\" ";
}
- result += "|- " + style + "\r\n" + ProcessTable(node.ChildNodes);
+ result += "|- " + style + "\n" + ProcessTable(node.ChildNodes);
break;
case "td":
string styleTd = "";
@@ -178,9 +178,9 @@ namespace ScrewTurn.Wiki {
foreach(XmlAttribute attr in node.Attributes) {
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;
}
}
@@ -214,19 +214,19 @@ namespace ScrewTurn.Wiki {
break;
case "h1":
if(node.HasChildNodes) {
- if(node.FirstChild.NodeType == XmlNodeType.Whitespace) result += "----\r\n" + ProcessChild(node.ChildNodes);
- else result += "==" + ProcessChild(node.ChildNodes) + "==\r\n";
+ if(node.FirstChild.NodeType == XmlNodeType.Whitespace) result += "----\n" + ProcessChild(node.ChildNodes);
+ else result += "==" + ProcessChild(node.ChildNodes) + "==\n";
}
- else result += "----\r\n";
+ else result += "----\n";
break;
case "h2":
- result += "===" + ProcessChild(node.ChildNodes) + "===\r\n";
+ result += "===" + ProcessChild(node.ChildNodes) + "===\n";
break;
case "h3":
- result += "====" + ProcessChild(node.ChildNodes) + "====\r\n";
+ result += "====" + ProcessChild(node.ChildNodes) + "====\n";
break;
case "h4":
- result += "=====" + ProcessChild(node.ChildNodes) + "=====\r\n";
+ result += "=====" + ProcessChild(node.ChildNodes) + "=====\n";
break;
case "pre":
result += "@@" + node.InnerText.ToString() + "@@";
@@ -236,7 +236,7 @@ namespace ScrewTurn.Wiki {
break;
case "hr":
case "hr /":
- result += "\r\n== ==\r\n" + ProcessChild(node.ChildNodes);
+ result += "\n== ==\n" + ProcessChild(node.ChildNodes);
break;
case "span":
if(node.Attributes.Count != 0) {
@@ -247,7 +247,7 @@ namespace ScrewTurn.Wiki {
}
break;
case "br":
- result += "\r\n" + ProcessChild(node.ChildNodes);
+ result += "\n" + ProcessChild(node.ChildNodes);
break;
case "table":
bool isImage = false;
@@ -257,7 +257,7 @@ namespace ScrewTurn.Wiki {
foreach(XmlAttribute attName in node.Attributes) {
if(attName.Value.ToString() == "imageauto") {
isImage = true;
- image += "[imageauto|" + ProcessTableImage(node.ChildNodes) + "]\r\n";
+ image += "[imageauto|" + ProcessTableImage(node.ChildNodes) + "]\n";
}
else tableStyle += attName.Name + "=\"" + attName.Value.ToString() + "\" ";
}
@@ -266,7 +266,7 @@ namespace ScrewTurn.Wiki {
isImage = false;
break;
}
- else result += "{| " + tableStyle + "\r\n" + ProcessTable(node.ChildNodes) + "|}\r\n";
+ else result += "{| " + tableStyle + "\n" + ProcessTable(node.ChildNodes) + "|}\n";
break;
case "ol":
if(node.ParentNode != null) {
@@ -295,20 +295,20 @@ namespace ScrewTurn.Wiki {
if(attName.Value.ToString() == "imagedescription") result += "";
}
}
- else result += ProcessChild(node.ChildNodes) + "{BR}\r\n";
+ else result += ProcessChild(node.ChildNodes) + "{BR}\n";
break;
case "div":
if(node.Attributes.Count != 0) {
XmlAttributeCollection attribute = node.Attributes;
foreach(XmlAttribute attName in attribute) {
- if(attName.Value.ToString() == "box") result += "(((" + ProcessChild(node.ChildNodes) + ")))\r\n";
- if(attName.Value.ToString() == "imageleft") result += "[imageleft" + ProcessChildImage(node.ChildNodes) + "]\r\n";
- if(attName.Value.ToString() == "imageright") result += "[imageright" + ProcessChildImage(node.ChildNodes) + "]\r\n";
- if(attName.Value.ToString() == "image") result += "[image" + ProcessChildImage(node.ChildNodes) + "]\r\n";
- if(attName.Value.ToString() == "indent") 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) + "]\n";
+ if(attName.Value.ToString() == "imageright") result += "[imageright" + ProcessChildImage(node.ChildNodes) + "]\n";
+ if(attName.Value.ToString() == "image") result += "[image" + ProcessChildImage(node.ChildNodes) + "]\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;
case "img":
string description = "";
@@ -321,7 +321,7 @@ namespace ScrewTurn.Wiki {
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 result += description + "|" + ProcessImage(node);
break;
@@ -360,11 +360,11 @@ namespace ScrewTurn.Wiki {
if(title != link) 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 += ProcessChild(node.ChildNodes) + "|" + target + link + "]\r\n";
+ if(!anchor && childImg && !isTable) result += ProcessChild(node.ChildNodes) + "|" + target + link + "]\n";
}
break;
default:
- result += (node.OuterXml);
+ result += node.OuterXml;
break;
}
}