diff --git a/Core-Tests/ReverseFormatterTests.cs b/Core-Tests/ReverseFormatterTests.cs index 6369576..a1079d9 100644 --- a/Core-Tests/ReverseFormatterTests.cs +++ b/Core-Tests/ReverseFormatterTests.cs @@ -39,10 +39,10 @@ namespace ScrewTurn.Wiki.Tests { [TestCase("BIG TITLE", "[^google.com|BIG TITLE]")] [TestCase("try to esc tag", "try to esc tag")] [TestCase("
\"left

leftalign

", "\r\n[imageleft|leftalign|{UP(MainPage)}image.png|^www.link.com]\r\n")] - [TestCase("\"inlineimage\"", "[image||{UP(MainPage)}image.png]\r\n")] - [TestCase("\"description\"", "[image||{UP(MainPage)}image.png|^www.google.it]\r\n")] + [TestCase("\"inlineimage\"", "[image|inlineimage|{UP(MainPage)}image.png]\r\n")] + [TestCase("\"description\"", "[image|description|{UP(MainPage)}image.png|^www.google.it]\r\n")] [TestCase("
\"autoalign\"

autoalign

", "[imageauto|autoalign|{UP(MainPage)}image.png]\r\n")] - [TestCase("
\"Auto

Auto align

", "[imageauto||{UP(MainPage)}image.png|www.link.com]\r\n")] + [TestCase("
\"Auto

Auto align

", "[imageauto|Auto align|{UP(MainPage)}image.png|www.link.com]\r\n")] public void PlainTest(string input, string output) { Assert.AreEqual(output, ReverseFormatter.ReverseFormat(input)); } diff --git a/Core/ReverseFormatter.cs b/Core/ReverseFormatter.cs index 0eefe9f..bc8232f 100644 --- a/Core/ReverseFormatter.cs +++ b/Core/ReverseFormatter.cs @@ -16,24 +16,6 @@ namespace ScrewTurn.Wiki { public static class ReverseFormatter { - /// - /// Searches the description. - /// - /// The nodes. - /// - private static string searchDescription (XmlNodeList nodes){ - string description = ""; - foreach (XmlNode n in nodes){ - if(n.Name.ToLowerInvariant() == "p") { - foreach(XmlAttribute att in n.Attributes) { - if(att.Value.ToLowerInvariant().ToString() == "imagedescription") - description += processChild(n.ChildNodes); - } - } - } - return description; - } - /// /// Processes order or unorder lists and sublists. /// @@ -148,7 +130,6 @@ namespace ScrewTurn.Wiki { /// The corrispondent WikiMarkup Text private static string processChild(XmlNodeList nodes) { string result = ""; - bool isImage = false; foreach(XmlNode node in nodes) { bool anchor = false; if(node.NodeType == XmlNodeType.Text) { @@ -222,6 +203,7 @@ namespace ScrewTurn.Wiki { result += ("\r\n" + processChild(node.ChildNodes)); break; case "table": + bool isImage = false; string image = ""; foreach(XmlAttribute attName in node.Attributes) { if(attName.Value.ToString() == "imageauto") { @@ -243,10 +225,6 @@ namespace ScrewTurn.Wiki { result += processChild(node.ChildNodes); break; case "td": - if(isImage) { - result += processChildImage(node.ChildNodes); - } - else result += processChild(node.ChildNodes); break; case "ol": @@ -304,7 +282,7 @@ namespace ScrewTurn.Wiki { if(node.Attributes.Count != 0) { foreach(XmlAttribute attName in node.Attributes) { if(attName.Name.ToString() == "alt") - description = searchDescription(node.ParentNode.ChildNodes); + description = attName.Value.ToString(); //description = attName.Value.ToString(); if(attName.Name.ToString() == "class") hasClass = true;