Fixed extra <BR /> at the end of lists

Fixed image path from folder
This commit is contained in:
Cristian Trapattoni 2011-03-02 14:28:34 +01:00
parent a39315a3cd
commit 55b1cfcc27
2 changed files with 8 additions and 7 deletions

View file

@ -28,9 +28,10 @@ namespace ScrewTurn.Wiki.Tests {
[TestCase("<div class=\"box\">text</div>", "\r\n(((text)))\r\n")]
[TestCase("<div>text</div>", "\r\ntext\r\n")]
[TestCase("<html>riga1\r\n<b>riga2</b>\r\nriga3</html>", "riga1\r\n'''riga2'''\r\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<br />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\r\nciao\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\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("<ol><li>1</li><li>2</li></ol>", "# 1\r\n# 2\r\n")]
[TestCase("<ul><li>1</li><li>2</li></ul>", "* 1\r\n* 2\r\n")]
[TestCase("<div class=\"imageright\"><img class=\"image\" src=\"GetFile.aspx?File=/Help/Desktop/image.png\"><p class=\"imagedescription\">description</p></div>", "\r\n[imageright|description|{UP}/Help/Desktop/image.png]\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\r\n* Punto 2\r\n* Punto 3\r\n* Punto 4\r\n* Punto 5\r\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<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")]

View file

@ -36,7 +36,8 @@ namespace ScrewTurn.Wiki {
text += processChild(n.ChildNodes);
}
}
result += marker + " " + text + "\r\n";
result += marker + " " + text;
if(!result.EndsWith("\r\n")) result += "\r\n";
foreach(XmlNode child in node.ChildNodes) {
if(child.Name.ToString() == "ol"){
result += processList(child.ChildNodes, marker + ol);
@ -59,9 +60,11 @@ namespace ScrewTurn.Wiki {
string result = "";
if(node.Attributes.Count != 0) {
foreach(XmlAttribute attName in node.Attributes) {
if((attName.Name.ToString() == "src") || (attName.Value.ToString().ToLowerInvariant() == "Image")) {
if((attName.Name == "src") || (attName.Value.ToString() == "Image")) {
string[] path = attName.Value.ToString().Split('=');
result += "{" + "UP(" + path[1].Split('&')[0] + ")}" + path[path.Length-1];
if(path.Length > 2)
result += "{" + "UP(" + path[1].Split('&')[0] + ")}" + path[2];
else result += "{UP}" + path[path.Length - 1];
}
}
}
@ -224,9 +227,6 @@ namespace ScrewTurn.Wiki {
case "ul":
result += processList(node.ChildNodes, "*");
break;
case "li":
result += processChild(node.ChildNodes);
break;
case "sup":
result += ("<sup>" + processChild(node.ChildNodes) + "</sup>");
break;