Added table formattation
This commit is contained in:
parent
55b1cfcc27
commit
228acd32df
2 changed files with 59 additions and 10 deletions
|
@ -858,16 +858,14 @@ namespace ScrewTurn.Wiki {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!bareBones) {
|
match = TableRegex.Match(sb.ToString());
|
||||||
match = TableRegex.Match(sb.ToString());
|
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);
|
sb.Insert(match.Index, BuildTable(match.Value));
|
||||||
sb.Insert(match.Index, BuildTable(match.Value));
|
|
||||||
}
|
|
||||||
ComputeNoWiki(sb.ToString(), ref noWikiBegin, ref noWikiEnd);
|
|
||||||
match = TableRegex.Match(sb.ToString(), end);
|
|
||||||
}
|
}
|
||||||
|
ComputeNoWiki(sb.ToString(), ref noWikiBegin, ref noWikiEnd);
|
||||||
|
match = TableRegex.Match(sb.ToString(), end);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Strip out all comments
|
// Strip out all comments
|
||||||
|
|
|
@ -112,11 +112,53 @@ namespace ScrewTurn.Wiki {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static string processCode(string text) {
|
private static string processCode(string text) {
|
||||||
string result = "";
|
string result = "";
|
||||||
result = text;
|
result = text;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Processes the table.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="nodes">The nodes.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private static string processTable(XmlNodeList nodes) {
|
||||||
|
string result = "";
|
||||||
|
bool isLast = false;
|
||||||
|
foreach(XmlNode node in nodes) {
|
||||||
|
if(node == node.ParentNode.LastChild) isLast = true;
|
||||||
|
switch (node.Name.ToLowerInvariant()){
|
||||||
|
case "thead":
|
||||||
|
result += processTable(node.ChildNodes) + "|-\r\n";
|
||||||
|
break;
|
||||||
|
case "th":
|
||||||
|
result += "! " + processChild(node.ChildNodes) + "\r\n";
|
||||||
|
break;
|
||||||
|
case "caption":
|
||||||
|
result += "|+ "+ processChild(node.ChildNodes);
|
||||||
|
break;
|
||||||
|
case "tbody":
|
||||||
|
result += processTable(node.ChildNodes) + "";
|
||||||
|
break;
|
||||||
|
case "tr":
|
||||||
|
string style = "";
|
||||||
|
foreach(XmlAttribute attr in node.Attributes) {
|
||||||
|
if(attr.Name.ToLowerInvariant() == "style") style += "style=\"" + attr.Value.ToString() + "\" ";
|
||||||
|
}
|
||||||
|
if(!isLast) result += processTable(node.ChildNodes) + "|-" + style + "\r\n";
|
||||||
|
else result += processTable(node.ChildNodes);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case "td":
|
||||||
|
result += "| " + processChild(node.ChildNodes) + "\r\n";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Processes the child.
|
/// Processes the child.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -199,18 +241,27 @@ namespace ScrewTurn.Wiki {
|
||||||
case "table":
|
case "table":
|
||||||
bool isImage = false;
|
bool isImage = false;
|
||||||
string image = "";
|
string image = "";
|
||||||
|
string border = "";
|
||||||
|
string background = "";
|
||||||
|
string cellspacing = "";
|
||||||
|
string cellpadding = "";
|
||||||
|
|
||||||
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;
|
||||||
image += "[imageauto|" + processChild(node.ChildNodes) + "]\r\n";
|
image += "[imageauto|" + processChild(node.ChildNodes) + "]\r\n";
|
||||||
}
|
}
|
||||||
|
if(attName.Name.ToLowerInvariant() == "border") border += "border=\""+ attName.Value.ToString() + "\" ";
|
||||||
|
if(attName.Name.ToLowerInvariant() == "bgcolor") background += "bgcolor=\"" + attName.Value.ToString() + "\" ";
|
||||||
|
if(attName.Name.ToLowerInvariant() == "cellspacing") cellpadding += "cellpadding=\"" + attName.Value.ToString() + "\" ";
|
||||||
|
if(attName.Name.ToLowerInvariant() == "cellspacing") cellspacing += "cellspacing=\"" + attName.Value.ToString() + "\" ";
|
||||||
}
|
}
|
||||||
if(isImage) {
|
if(isImage) {
|
||||||
result += image;
|
result += image;
|
||||||
isImage = false;
|
isImage = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else result += processChild(node.ChildNodes);
|
else result += "{| " + border + background + cellpadding + cellspacing + "\r\n" + processTable(node.ChildNodes) + "|}";
|
||||||
break;
|
break;
|
||||||
case "tbody":
|
case "tbody":
|
||||||
result += processChild(node.ChildNodes);
|
result += processChild(node.ChildNodes);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue