Added ProcessSingleLineBreaks support.
This commit is contained in:
parent
5a657dda65
commit
4bc3d9eb7a
1 changed files with 18 additions and 4 deletions
|
@ -203,7 +203,7 @@ namespace ScrewTurn.Wiki {
|
||||||
string result = "";
|
string result = "";
|
||||||
foreach(XmlNode node in nodes) {
|
foreach(XmlNode node in nodes) {
|
||||||
bool anchor = false;
|
bool anchor = false;
|
||||||
if(node.NodeType == XmlNodeType.Text) result += node.Value;
|
if(node.NodeType == XmlNodeType.Text) result += node.Value.TrimStart('\n');
|
||||||
else if(node.NodeType != XmlNodeType.Whitespace) {
|
else if(node.NodeType != XmlNodeType.Whitespace) {
|
||||||
switch(node.Name.ToLowerInvariant()) {
|
switch(node.Name.ToLowerInvariant()) {
|
||||||
case "html":
|
case "html":
|
||||||
|
@ -264,7 +264,12 @@ namespace ScrewTurn.Wiki {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "br":
|
case "br":
|
||||||
result += "\n" + ProcessChild(node.ChildNodes);
|
if(node.PreviousSibling != null && node.PreviousSibling.Name == "br") {
|
||||||
|
result += "\n";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result += Settings.ProcessSingleLineBreaks ? "\n" : "\n\n";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "table":
|
case "table":
|
||||||
bool isImage = false;
|
bool isImage = false;
|
||||||
|
@ -310,7 +315,7 @@ namespace ScrewTurn.Wiki {
|
||||||
break;
|
break;
|
||||||
case "p":
|
case "p":
|
||||||
if(node.Attributes["class"] != null && node.Attributes["class"].Value.Contains("imagedescription")) continue;
|
if(node.Attributes["class"] != null && node.Attributes["class"].Value.Contains("imagedescription")) continue;
|
||||||
else result += ProcessChild(node.ChildNodes) + "\n\n";
|
else result += ProcessChild(node.ChildNodes) + "\n" + (Settings.ProcessSingleLineBreaks ? "" : "\n");
|
||||||
break;
|
break;
|
||||||
case "div":
|
case "div":
|
||||||
if(node.Attributes["class"] != null) {
|
if(node.Attributes["class"] != null) {
|
||||||
|
@ -321,7 +326,16 @@ namespace ScrewTurn.Wiki {
|
||||||
if(node.Attributes["class"].Value.Contains("indent")) result += ": " + ProcessChild(node.ChildNodes) + "\n";
|
if(node.Attributes["class"].Value.Contains("indent")) result += ": " + ProcessChild(node.ChildNodes) + "\n";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result += ProcessChild(node.ChildNodes) + "\n";
|
if(node.PreviousSibling != null && node.PreviousSibling.Name != "div") {
|
||||||
|
result += Settings.ProcessSingleLineBreaks ? "\n" : "\n\n";
|
||||||
|
}
|
||||||
|
if(node.FirstChild != null && node.FirstChild.Name == "br") {
|
||||||
|
node.RemoveChild(node.FirstChild);
|
||||||
|
}
|
||||||
|
if(node.HasChildNodes) {
|
||||||
|
result += ProcessChild(node.ChildNodes);
|
||||||
|
result += Settings.ProcessSingleLineBreaks ? "\n" : "\n\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "img":
|
case "img":
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue