[completed: 599] Fixed internal pages (or not existing ones) link in reverse formatter.
This commit is contained in:
parent
35907234c3
commit
1b197cbc65
3 changed files with 9 additions and 5 deletions
|
@ -16,5 +16,5 @@ using System.Reflection;
|
|||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("3.0.4.570")]
|
||||
[assembly: AssemblyFileVersion("3.0.4.570")]
|
||||
[assembly: AssemblyVersion("3.0.4.571")]
|
||||
[assembly: AssemblyFileVersion("3.0.4.571")]
|
|
@ -60,6 +60,8 @@ namespace ScrewTurn.Wiki.Tests {
|
|||
[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]")]
|
||||
[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(@"<a class=""unknownlink"" href=""test.ashx"" title=""test"">test</a>", "[test|test]")]
|
||||
[TestCase(@"<a class=""pagelink"" href=""MainPage.ashx"" title=""Main Page"">Main Page</a>", "[MainPage|Main Page]")]
|
||||
public void PlainTest(string input, string output) {
|
||||
Assert.AreEqual(output, ReverseFormatter.ReverseFormat(input));
|
||||
}
|
||||
|
|
|
@ -361,7 +361,7 @@ namespace ScrewTurn.Wiki {
|
|||
string title = "";
|
||||
bool isInternalLink = false;
|
||||
bool childImg = false;
|
||||
bool isUnknowLink = false;
|
||||
bool pageLink = false;
|
||||
if(node.FirstChild != null && node.FirstChild.Name == "img") childImg = true;
|
||||
if(node.ParentNode.Name == "td") isTable = true;
|
||||
if(node.Attributes.Count != 0) {
|
||||
|
@ -372,7 +372,7 @@ namespace ScrewTurn.Wiki {
|
|||
if(attName.Name == "href") link += attName.Value.ToString();
|
||||
if(attName.Name == "title") title += attName.Value.ToString();
|
||||
if(attName.Value == "SystemLink".ToLowerInvariant()) isInternalLink = true;
|
||||
if(attName.Value == "unknownlink") isUnknowLink = true;
|
||||
if(attName.Value.ToLowerInvariant() == "unknownlink" || attName.Value.ToLowerInvariant() == "pagelink") pageLink = true;
|
||||
}
|
||||
else {
|
||||
anchor = true;
|
||||
|
@ -384,10 +384,12 @@ namespace ScrewTurn.Wiki {
|
|||
string[] splittedLink = link.Split('=');
|
||||
link = "c:" + splittedLink[1];
|
||||
}
|
||||
else if(pageLink) link = link.Remove(link.IndexOf(Settings.PageExtension));
|
||||
else link = ProcessLink(link);
|
||||
if(!anchor && !isTable && !childImg && !isUnknowLink)
|
||||
if(!anchor && !isTable && !childImg) {
|
||||
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 + "]";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue