diff --git a/Core-Tests/ReverseFormatterTests.cs b/Core-Tests/ReverseFormatterTests.cs index 4acc7a9..37267d8 100644 --- a/Core-Tests/ReverseFormatterTests.cs +++ b/Core-Tests/ReverseFormatterTests.cs @@ -26,7 +26,7 @@ namespace ScrewTurn.Wiki.Tests { [TestCase("text", "{{'''text'''}}")] [TestCase("
text
", "(((text)))\r\n")] [TestCase("
text
", "text\r\n")] - [TestCase("
  1. 1
  2. 2
  3. 3
    1. 3.1
    2. 3.2
      1. 3.2.1
    3. 3.3
  4. 4

", "# 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\r\n# \r\n\r\n\r\n\r\n")] + [TestCase("
  1. 1
  2. 2
  3. 3
    1. 3.1
    2. 3.2
      1. 3.2.1
    3. 3.3
  4. 4

", "# 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\r\n# {BR}\r\n\r\n\r\n{BR}\r\n")] [TestCase("
  1. 1
  2. 2
", "# 1\r\n# 2\r\n\r\n")] [TestCase("", "* 1\r\n* 2\r\n\r\n")] [TestCase("", "* Punto 1\r\n* Punto 2\r\n* Punto 3\r\n* Punto 4\r\n* Punto 5\r\n\r\n")] diff --git a/Core/ReverseFormatter.cs b/Core/ReverseFormatter.cs index 91a9fa8..f2c7ade 100644 --- a/Core/ReverseFormatter.cs +++ b/Core/ReverseFormatter.cs @@ -57,7 +57,7 @@ namespace ScrewTurn.Wiki { string result = ""; if(node.Attributes.Count != 0) { foreach(XmlAttribute attName in node.Attributes) { - if(attName.Name.ToString() == "src") { + if((attName.Name.ToString() == "src") || (attName.Value.ToString().ToLowerInvariant() == "Image")) { string[] path = attName.Value.ToString().Split('='); result += "{" + "UP(" + path[1].Split('&')[0] + ")}" + path[2]; } @@ -114,9 +114,8 @@ namespace ScrewTurn.Wiki { bool anchor = false; if(node.NodeType == XmlNodeType.Text) { result += node.Value; - //string result = ""; } - else { + else if (node.NodeType != XmlNodeType.Whitespace){ switch(node.Name.ToLowerInvariant()) { case "html": result += processChild(node.ChildNodes); @@ -176,9 +175,8 @@ namespace ScrewTurn.Wiki { } } break; - case "\n": case "br": - result += ("\r\n" + processChild(node.ChildNodes)); + result += ("{BR}\r\n" + processChild(node.ChildNodes)); break; case "table": string image = ""; @@ -227,6 +225,7 @@ namespace ScrewTurn.Wiki { result += ""; } } + else result += processChild(node.ChildNodes) + "{BR}\r\n"; break; case "div": if(node.Attributes.Count != 0) {