Fixed autoimage description, now work correctly;
Added test for wikititle in formatterTests
This commit is contained in:
parent
bfd17496ef
commit
087f015b79
3 changed files with 15 additions and 9 deletions
|
@ -29,7 +29,7 @@ second line";
|
||||||
private MockRepository mocks;
|
private MockRepository mocks;
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
//[TestCase("{wikititle}","Title")]
|
[TestCase("{wikititle}","Title\n")]
|
||||||
[TestCase("@@rigatesto1\r\nriga2@@","<pre>rigatesto1\r\nriga2</pre>\n")]
|
[TestCase("@@rigatesto1\r\nriga2@@","<pre>rigatesto1\r\nriga2</pre>\n")]
|
||||||
[TestCase(Input,ExpectedOutput)]
|
[TestCase(Input,ExpectedOutput)]
|
||||||
public void Format(string input, string output) {
|
public void Format(string input, string output) {
|
||||||
|
@ -51,6 +51,7 @@ second line";
|
||||||
|
|
||||||
ISettingsStorageProviderV30 settingsProvider = mocks.StrictMock<ISettingsStorageProviderV30>();
|
ISettingsStorageProviderV30 settingsProvider = mocks.StrictMock<ISettingsStorageProviderV30>();
|
||||||
Expect.Call(settingsProvider.GetSetting("ProcessSingleLineBreaks")).Return("false").Repeat.Any();
|
Expect.Call(settingsProvider.GetSetting("ProcessSingleLineBreaks")).Return("false").Repeat.Any();
|
||||||
|
Expect.Call(settingsProvider.GetSetting("WikiTitle")).Return("Title").Repeat.Any();
|
||||||
|
|
||||||
Collectors.SettingsProvider = settingsProvider;
|
Collectors.SettingsProvider = settingsProvider;
|
||||||
|
|
||||||
|
|
|
@ -38,8 +38,8 @@ namespace ScrewTurn.Wiki {
|
||||||
private static readonly Regex PreRegex = new Regex(@"\{\{\{\{.+?\}\}\}\}", RegexOptions.Compiled | RegexOptions.Singleline);
|
private static readonly Regex PreRegex = new Regex(@"\{\{\{\{.+?\}\}\}\}", RegexOptions.Compiled | RegexOptions.Singleline);
|
||||||
private static readonly Regex BoxRegex = new Regex(@"\(\(\(.+?\)\)\)", RegexOptions.Compiled | RegexOptions.Singleline);
|
private static readonly Regex BoxRegex = new Regex(@"\(\(\(.+?\)\)\)", RegexOptions.Compiled | RegexOptions.Singleline);
|
||||||
private static readonly Regex ExtendedUpRegex = new Regex(@"\{up((\:|\().+?)?\}", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
private static readonly Regex ExtendedUpRegex = new Regex(@"\{up((\:|\().+?)?\}", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||||
private static readonly Regex SpecialTagRegex = new Regex(@"\{(wikititle|wikiversion|mainurl|rsspage|themepath|clear|br|top|searchbox|pagecount|pagecount\(\*\)|categories|cloud|orphans|wanted|namespacelist)\}", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
|
private static readonly Regex SpecialTagRegex = new Regex(@"\{(wikititle|wikiversion|mainurl|rsspage|themepath|clear|top|searchbox|pagecount|pagecount\(\*\)|categories|cloud|orphans|wanted|namespacelist)\}", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
|
||||||
private static readonly Regex SpecialTagBR = new Regex(@"\{(br)\}", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
|
private static readonly Regex SpecialTagBRRegex = new Regex(@"\{(br)\}", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
|
||||||
private static readonly Regex Phase3SpecialTagRegex = new Regex(@"\{(username|pagename|loginlogout|namespace|namespacedropdown|incoming|outgoing)\}", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
|
private static readonly Regex Phase3SpecialTagRegex = new Regex(@"\{(username|pagename|loginlogout|namespace|namespacedropdown|incoming|outgoing)\}", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
|
||||||
private static readonly Regex RecentChangesRegex = new Regex(@"\{recentchanges(\(\*\))?\}", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
|
private static readonly Regex RecentChangesRegex = new Regex(@"\{recentchanges(\(\*\))?\}", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
|
||||||
private static readonly Regex ListRegex = new Regex(@"(?<=(\n|^))((\*|\#)+(\ )?.+?\n)+((?=\n)|\z)", RegexOptions.Compiled | RegexOptions.Singleline); // Singleline to matche list elements on multiple lines
|
private static readonly Regex ListRegex = new Regex(@"(?<=(\n|^))((\*|\#)+(\ )?.+?\n)+((?=\n)|\z)", RegexOptions.Compiled | RegexOptions.Singleline); // Singleline to matche list elements on multiple lines
|
||||||
|
@ -265,7 +265,7 @@ namespace ScrewTurn.Wiki {
|
||||||
match = ExtendedUpRegex.Match(sb.ToString(), end);
|
match = ExtendedUpRegex.Match(sb.ToString(), end);
|
||||||
}
|
}
|
||||||
|
|
||||||
match = SpecialTagBR.Match(sb.ToString()); // solved by introducing a new regex call SpecialTagBR
|
match = SpecialTagBRRegex.Match(sb.ToString()); // solved by introducing a new regex call SpecialTagBR
|
||||||
while(match.Success) {
|
while(match.Success) {
|
||||||
if(!IsNoWikied(match.Index, noWikiBegin, noWikiEnd, out end)) {
|
if(!IsNoWikied(match.Index, noWikiBegin, noWikiEnd, out end)) {
|
||||||
sb.Remove(match.Index, match.Length);
|
sb.Remove(match.Index, match.Length);
|
||||||
|
@ -278,7 +278,7 @@ namespace ScrewTurn.Wiki {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ComputeNoWiki(sb.ToString(), ref noWikiBegin, ref noWikiEnd);
|
ComputeNoWiki(sb.ToString(), ref noWikiBegin, ref noWikiEnd);
|
||||||
match = SpecialTagRegex.Match(sb.ToString(), end);
|
match = SpecialTagBRRegex.Match(sb.ToString(), end);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!bareBones) {
|
if(!bareBones) {
|
||||||
|
|
|
@ -148,6 +148,7 @@ namespace ScrewTurn.Wiki {
|
||||||
/// <returns>The corrispondent WikiMarkup Text</returns>
|
/// <returns>The corrispondent WikiMarkup Text</returns>
|
||||||
private static string processChild(XmlNodeList nodes) {
|
private static string processChild(XmlNodeList nodes) {
|
||||||
string result = "";
|
string result = "";
|
||||||
|
bool isImage = false;
|
||||||
foreach(XmlNode node in nodes) {
|
foreach(XmlNode node in nodes) {
|
||||||
bool anchor = false;
|
bool anchor = false;
|
||||||
if(node.NodeType == XmlNodeType.Text) {
|
if(node.NodeType == XmlNodeType.Text) {
|
||||||
|
@ -222,7 +223,6 @@ namespace ScrewTurn.Wiki {
|
||||||
break;
|
break;
|
||||||
case "table":
|
case "table":
|
||||||
string image = "";
|
string image = "";
|
||||||
bool isImage = false;
|
|
||||||
foreach(XmlAttribute attName in node.Attributes) {
|
foreach(XmlAttribute attName in node.Attributes) {
|
||||||
if(attName.Value.ToString() == "imageauto") {
|
if(attName.Value.ToString() == "imageauto") {
|
||||||
isImage = true;
|
isImage = true;
|
||||||
|
@ -231,6 +231,7 @@ namespace ScrewTurn.Wiki {
|
||||||
}
|
}
|
||||||
if(isImage) {
|
if(isImage) {
|
||||||
result += image;
|
result += image;
|
||||||
|
isImage = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else result += processChild(node.ChildNodes);
|
else result += processChild(node.ChildNodes);
|
||||||
|
@ -242,6 +243,10 @@ namespace ScrewTurn.Wiki {
|
||||||
result += processChild(node.ChildNodes);
|
result += processChild(node.ChildNodes);
|
||||||
break;
|
break;
|
||||||
case "td":
|
case "td":
|
||||||
|
if(isImage) {
|
||||||
|
result += processChildImage(node.ChildNodes);
|
||||||
|
}
|
||||||
|
else
|
||||||
result += processChild(node.ChildNodes);
|
result += processChild(node.ChildNodes);
|
||||||
break;
|
break;
|
||||||
case "ol":
|
case "ol":
|
||||||
|
@ -281,8 +286,8 @@ namespace ScrewTurn.Wiki {
|
||||||
}
|
}
|
||||||
if(attName.Value.ToString() == "imageright")
|
if(attName.Value.ToString() == "imageright")
|
||||||
result += "\r\n" + "[imageright" + processChildImage(node.ChildNodes) + "]\r\n";
|
result += "\r\n" + "[imageright" + processChildImage(node.ChildNodes) + "]\r\n";
|
||||||
if(attName.Value.ToString() == "imageauto")
|
if(attName.Value.ToString() == "image")
|
||||||
result += "\r\n" + "[imageauto" + processChildImage(node.ChildNodes) + "]\r\n";
|
result += "\r\n" + "[image" + processChildImage(node.ChildNodes) + "]\r\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue