/// <summary> /// Loads the content configuration. /// </summary> /// <param name="currentWiki">The wiki.</param> private void LoadContentConfig(string currentWiki) { string[] theme = Settings.GetTheme(currentWiki, null).Split(new char[] { '|' }); ThemeRootSelector.SelectedProvider = theme[0]; ThemeRootSelector.SelectedThemes = theme[1]; PopulateMainPages(Settings.GetDefaultPage(currentWiki)); txtDateTimeFormat.Text = Settings.GetDateTimeFormat(currentWiki); PopulateDateTimeFormats(); PopulateLanguages(Settings.GetDefaultLanguage(currentWiki)); PopulateTimeZones(Settings.GetDefaultTimezone(currentWiki)); txtMaxRecentChangesToDisplay.Text = Settings.GetMaxRecentChangesToDisplay(currentWiki).ToString(); lstRssFeedsMode.SelectedIndex = -1; switch (Settings.GetRssFeedsMode(currentWiki)) { case RssFeedsMode.FullText: lstRssFeedsMode.SelectedIndex = 0; break; case RssFeedsMode.Summary: lstRssFeedsMode.SelectedIndex = 1; break; case RssFeedsMode.Disabled: lstRssFeedsMode.SelectedIndex = 2; break; } chkEnableDoubleClickEditing.Checked = Settings.GetEnableDoubleClickEditing(currentWiki); chkEnableSectionEditing.Checked = Settings.GetEnableSectionEditing(currentWiki); chkEnableSectionAnchors.Checked = Settings.GetEnableSectionAnchors(currentWiki); chkEnablePageToolbar.Checked = Settings.GetEnablePageToolbar(currentWiki); chkEnableViewPageCode.Checked = Settings.GetEnableViewPageCodeFeature(currentWiki); chkEnablePageInfoDiv.Checked = Settings.GetEnablePageInfoDiv(currentWiki); chkEnableBreadcrumbsTrail.Checked = !Settings.GetDisableBreadcrumbsTrail(currentWiki); chkAutoGeneratePageNames.Checked = Settings.GetAutoGeneratePageNames(currentWiki); chkProcessSingleLineBreaks.Checked = Settings.GetProcessSingleLineBreaks(currentWiki); chkUseVisualEditorAsDefault.Checked = Settings.GetUseVisualEditorAsDefault(currentWiki); if (Settings.GetKeptBackupNumber(currentWiki) == -1) { txtKeptBackupNumber.Text = ""; } else { txtKeptBackupNumber.Text = Settings.GetKeptBackupNumber(currentWiki).ToString(); } chkDisplayGravatars.Checked = Settings.GetDisplayGravatars(currentWiki); txtListSize.Text = Settings.GetListSize(currentWiki).ToString(); }
private void ProcessChild(XmlNodeList nodes, StringBuilder sb) { foreach (XmlNode node in nodes) { bool anchor = false; if (node.NodeType == XmlNodeType.Text) { sb.Append(node.Value.TrimStart('\r').TrimStart('\n')); } else if (node.NodeType != XmlNodeType.Whitespace) { if (node.Attributes["pluginid"] != null) { ProcessPlugin(node, sb); continue; } switch (node.Name.ToLowerInvariant()) { case "html": ProcessChild(node.ChildNodes, sb); break; case "b": case "strong": if (node.HasChildNodes) { sb.Append("'''"); ProcessChild(node.ChildNodes, sb); sb.Append("'''"); } break; case "strike": case "s": if (node.HasChildNodes) { sb.Append("--"); ProcessChild(node.ChildNodes, sb); sb.Append("--"); } break; case "em": case "i": if (node.HasChildNodes) { sb.Append("''"); ProcessChild(node.ChildNodes, sb); sb.Append("''"); } break; case "u": if (node.HasChildNodes) { sb.Append("__"); ProcessChild(node.ChildNodes, sb); sb.Append("__"); } break; case "h1": if (node.HasChildNodes) { //if(node.FirstChild.NodeType == XmlNodeType.Whitespace) { if (String.IsNullOrWhiteSpace(node.FirstChild.InnerText)) { sb.Append("----\n"); ProcessChild(node.ChildNodes, sb); } else { if (!(sb.Length == 0 || sb.ToString().EndsWith("\n"))) { sb.Append("\n"); } sb.Append("=="); ProcessChild(node.ChildNodes, sb); sb.Append("==\n"); } } else { sb.Append("----\n"); } break; case "h2": if (!(sb.Length == 0 || sb.ToString().EndsWith("\n"))) { sb.Append("\n"); } sb.Append("==="); ProcessChild(node.ChildNodes, sb); sb.Append("===\n"); break; case "h3": if (!(sb.Length == 0 || sb.ToString().EndsWith("\n"))) { sb.Append("\n"); } sb.Append("===="); ProcessChild(node.ChildNodes, sb); sb.Append("====\n"); break; case "h4": if (!(sb.Length == 0 || sb.ToString().EndsWith("\n"))) { sb.Append("\n"); } sb.Append("====="); ProcessChild(node.ChildNodes, sb); sb.Append("=====\n"); break; case "pre": if (node.HasChildNodes) { sb.Append("@@" + node.InnerText + "@@"); } break; case "code": if (node.HasChildNodes) { sb.Append("{{"); ProcessChild(node.ChildNodes, sb); sb.Append("}}"); } break; case "hr": case "hr /": sb.Append("\n== ==\n"); ProcessChild(node.ChildNodes, sb); break; case "span": if (node.Attributes["style"] != null && node.Attributes["style"].Value.Replace(" ", "").ToLowerInvariant().Contains("font-weight:normal")) { ProcessChild(node.ChildNodes, sb); } else if (node.Attributes["style"] != null && node.Attributes["style"].Value.Replace(" ", "").ToLowerInvariant().Contains("white-space:pre")) { sb.Append(": "); } else { sb.Append(node.OuterXml); } break; case "br": ////sb.Append("{br}"); //sb.Append("\n"); if (node.PreviousSibling != null && node.PreviousSibling.Name == "br") { sb.Append("\n"); } else { ////sb.Append("\n"); // if (Settings.GetProcessSingleLineBreaks(_wiki)) { sb.Append("\n"); } else { sb.Append("\n\n"); } } break; case "table": string tableStyle = ""; if (node.Attributes["class"] != null && node.Attributes["class"].Value.Contains("imageauto")) { sb.Append("[imageauto|"); ProcessTableImage(node.ChildNodes, sb); sb.Append("]"); } else { foreach (XmlAttribute attName in node.Attributes) { tableStyle += attName.Name + "=\"" + attName.Value + "\" "; } sb.Append("{| " + tableStyle + "\n"); ProcessTable(node.ChildNodes, sb); sb.Append("|}\n"); } break; case "ol": /*After tags h1,h2,h3,h4,h5,h6 set the symbol /n, then them ignored*/ if (node.PreviousSibling != null && node.PreviousSibling.Name != "br" && !node.PreviousSibling.Name.StartsWith("h")) { sb.Append("\n"); } if (node.ParentNode != null) { // Experemental //if (node.ParentNode.Name != "td") ProcessList(node.ChildNodes, "#", sb); //else sb.Append(node.OuterXml); ProcessList(node.ChildNodes, "#", sb); } else { ProcessList(node.ChildNodes, "#", sb); } break; case "ul": /*After tags h1,h2,h3,h4,h5,h6 set the symbol /n, then them ignored*/ if (node.PreviousSibling != null && node.PreviousSibling.Name != "br" && !node.PreviousSibling.Name.StartsWith("h")) { sb.Append("\n"); } if (node.ParentNode != null) { // Experemental //if (node.ParentNode.Name != "td") ProcessList(node.ChildNodes, "*", sb); //else sb.Append(node.OuterXml); ProcessList(node.ChildNodes, "*", sb); } else { ProcessList(node.ChildNodes, "*", sb); } break; case "sup": sb.Append("<sup>"); ProcessChild(node.ChildNodes, sb); sb.Append("</sup>"); break; case "sub": sb.Append("<sub>"); ProcessChild(node.ChildNodes, sb); sb.Append("</sub>"); break; case "p": if (node.Attributes["class"] != null && node.Attributes["class"].Value.Contains("imagedescription")) { continue; } else { ProcessChild(node.ChildNodes, sb); sb.Append("\n"); //if(!Settings.GetProcessSingleLineBreaks(_wiki)) sb.Append("\n"); } break; case "div": if (node.Attributes["wikiid"] != null && node.Attributes["wikiid"].Value.Contains("gallery")) { ProcessGallery(node, sb); } else if (node.Attributes["class"] != null && node.Attributes["class"].Value.Contains("box")) { if (node.HasChildNodes) { sb.Append("((("); ProcessChild(node.ChildNodes, sb); sb.Append(")))"); } } //else if (node.Attributes["class"] != null && node.Attributes["class"].Value.Contains("image")) //{ // if (node.ChildNodes.Count > 0 && node.ChildNodes[0].Attributes["class"] != null && node.ChildNodes[0].Attributes["class"].Value.Contains("imagethumbinner")) // ProcessChildImageNew(node, sb); // else // { // if (node.Attributes["class"].Value.Contains("imageleft")) // sb.Append("[imageleft"); // else if (node.Attributes["class"].Value.Contains("imageright")) // sb.Append("[imageright"); // else if (node.Attributes["class"].Value.Contains("image")) // sb.Append("[image"); // ProcessChildImage(node.ChildNodes, sb); // sb.Append("]"); // } //} //else if(node.Attributes["class"] != null && node.Attributes["class"].Value.Contains("imageleft")) { // sb.Append("[imageleft"); // // was: ProcessChildImage(node.ChildNodes, sb); // // mc // ProcessChild(node.ChildNodes, sb); // // mc // sb.Append("]"); //} //else if(node.Attributes["class"] != null && node.Attributes["class"].Value.Contains("imageright")) { // sb.Append("[imageright"); // // was: ProcessChildImage(node.ChildNodes, sb); // // mc // ProcessChild(node.ChildNodes, sb); // // mc // sb.Append("]"); //} //else if(node.Attributes["class"] != null && node.Attributes["class"].Value.Contains("image")) { // sb.Append("[image"); // // was: ProcessChildImage(node.ChildNodes, sb); // // mc // ProcessChild(node.ChildNodes, sb); // // mc // sb.Append("]"); //} else if (node.Attributes["class"] != null && node.Attributes["class"].Value.Contains("indent")) { sb.Append(": "); ProcessChild(node.ChildNodes, sb); sb.Append("\n"); } else if (node.Attributes.Count > 0) { sb.Append(node.OuterXml); } else { sb.Append("\n"); //if(node.PreviousSibling != null && node.PreviousSibling.Name != "div") { // if(!Settings.GetProcessSingleLineBreaks(_wiki)) sb.Append("\n"); //} if (node.FirstChild != null && node.FirstChild.Name == "br") { node.RemoveChild(node.FirstChild); } if (node.HasChildNodes) { ProcessChild(node.ChildNodes, sb); sb.Append("\n"); // ////if(Settings.GetProcessSingleLineBreaks(_wiki)) sb.Append("\n"); ////else sb.Append("\n\n"); } } break; case "img": string description = String.Empty; string bbsize = null; string bbalign = null; string bbframe = null; string urlType = "wiki"; string src = String.Empty; string ilink = null; string alt = null; int sizeW = 0; int width = 0; int height = 0; if (node.Attributes.Count != 0) { foreach (XmlAttribute attrib in node.Attributes) { switch (attrib.Name) { case "data-wiki-type-size": bbsize = attrib.Value; break; case "data-wiki-align": bbalign = attrib.Value; break; case "data-wiki-border": bbframe = attrib.Value; break; case "data-wiki-size-width": int number; if (Int32.TryParse(attrib.Value, out number)) { sizeW = number; } break; case "data-wiki-url-type": urlType = attrib.Value; break; case "data-wiki-desc": description = attrib.Value; break; case "alt": alt = attrib.Value; break; case "data-wiki-link": ilink = attrib.Value; break; case "src": src = attrib.Value; break; case "style": var reg = new Regex(@"(\d{1,4})"); foreach (var s in attrib.Value.Split(';')) { if (s.Trim().StartsWith("width", true, CultureInfo.InvariantCulture)) { var match = reg.Match(s); if (!String.IsNullOrEmpty(match.Groups[0].Value)) { width = Convert.ToInt32(match.Groups[0].Value); } } if (s.Trim().StartsWith("height", true, CultureInfo.InvariantCulture)) { var match = reg.Match(s); if (!String.IsNullOrEmpty(match.Groups[0].Value)) { height = Convert.ToInt32(match.Groups[0].Value); } } } break; } } } sb.Append("[image:" + (urlType != "url" ? ProcessImage(node) : HttpUtility.UrlDecode(src))); if (!string.IsNullOrEmpty(ilink)) { sb.Append("|link=" + ilink); } if (bbsize == "small" || bbsize == "medium") { sb.Append("|" + bbsize); } if (bbalign != null && bbalign != "auto") { sb.Append("|" + bbalign); } if (bbframe != null && bbframe != "frame") { sb.Append("|" + bbframe); } if (bbsize == "customMax" && sizeW > 0 && urlType != "url") { sb.Append("|max" + sizeW.ToString()); } if (bbsize == "customWidth" && sizeW > 0 && urlType != "url") { sb.Append("|" + sizeW.ToString()); } if (width > 0 && height > 0 && urlType == "url") { sb.AppendFormat("|{0}x{1}", width, height); } if (!string.IsNullOrEmpty(alt)) { sb.AppendFormat("|alt={0}", alt); } if (!string.IsNullOrEmpty(description)) { sb.Append("|" + description); } sb.Append("]"); break; //string description = ""; //bool hasClass = false; //bool isLink = false; //if(node.ParentNode != null && node.ParentNode.Name.ToLowerInvariant() == "a") isLink = true; //if(node.Attributes.Count != 0) { // foreach(XmlAttribute attName in node.Attributes) { // if(attName.Name == "alt") description = attName.Value; // if(attName.Name == "class") hasClass = true; // } //} //if(!hasClass && !isLink) sb.Append("[image|" + description + "|" + ProcessImage(node) + "]\n"); //else if(!hasClass && isLink) sb.Append("[image|" + description + "|" + ProcessImage(node)); //else sb.Append(description + "|" + ProcessImage(node)); //break; case "a": string link = ""; string title = ""; if (node.Attributes.Count != 0 && node.Attributes["wikiid"] != null && node.Attributes["wikiid"].Value.ToLowerInvariant() == "file") { XmlAttributeCollection attributes = node.Attributes; foreach (XmlAttribute attName in attributes) { if (attName.Name != "id".ToLowerInvariant()) { if (attName.Name.ToLowerInvariant() == "href") { link += attName.Value.Replace("%20", " "); } if (attName.Name.ToLowerInvariant() == "title") { title += attName.Value; } } } sb.Append("[file:" + ProcessLink(link)); if (!string.IsNullOrEmpty(title)) { sb.Append("|" + title); } sb.Append("]"); break; } bool isTable = false; string target = ""; string formattedLink = ""; bool isSystemLink = false; bool childImg = 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) { XmlAttributeCollection attribute = node.Attributes; foreach (XmlAttribute attName in attribute) { if (attName.Name != "id".ToLowerInvariant()) { if (attName.Value.ToLowerInvariant() == "_blank") { target += "^"; } if (attName.Name.ToLowerInvariant() == "href") { link += attName.Value.Replace("%20", " "); } if (attName.Name.ToLowerInvariant() == "title") { title += attName.Value; } if (attName.Name.ToLowerInvariant() == "class" && attName.Value.ToLowerInvariant() == "systemlink") { isSystemLink = true; } if (attName.Name.ToLowerInvariant() == "class" && (attName.Value.ToLowerInvariant() == "unknownlink" || attName.Value.ToLowerInvariant() == "pagelink")) { pageLink = true; } } else { anchor = true; sb.Append("[anchor|#" + attName.Value + "]"); ProcessChild(node.ChildNodes, sb); break; } } if (isSystemLink) { string[] splittedLink = link.Split('='); if (splittedLink.Length == 2) { formattedLink = "c:" + splittedLink[1]; } else { formattedLink = link.LastIndexOf('/') > 0 ? link.Substring(link.LastIndexOf('/') + 1) : link; } } else if (pageLink) { formattedLink = link.LastIndexOf('/') > 0 ? link.Substring(link.LastIndexOf('/') + 1) : link; if (GlobalSettings.PageExtension.Length > 0) { var index = formattedLink.IndexOf(GlobalSettings.PageExtension); if (index >= 0) { formattedLink = formattedLink.Remove(formattedLink.IndexOf(GlobalSettings.PageExtension)); } } formattedLink = Uri.UnescapeDataString(formattedLink); } else { formattedLink = ProcessLink(link); } if (!anchor && !isTable && !childImg) { if (HttpUtility.HtmlDecode(title) != HttpUtility.HtmlDecode(link)) { sb.Append("[" + target + formattedLink + "|"); ProcessChild(node.ChildNodes, sb); sb.Append("]"); } else { sb.Append("[" + target + formattedLink + "]"); } } if (!anchor && !childImg && isTable) { sb.Append("[" + target + formattedLink + "|"); ProcessChild(node.ChildNodes, sb); sb.Append("]"); } if (!anchor && childImg && !isTable) { ProcessChild(node.ChildNodes, sb); sb.Append("|" + target + formattedLink + "]"); } } break; default: sb.Append(node.OuterXml); break; } } } }
private void ProcessChild(XmlNodeList nodes, StringBuilder sb) { foreach (XmlNode node in nodes) { bool anchor = false; if (node.NodeType == XmlNodeType.Text) { sb.Append(node.Value.TrimStart('\n')); } else if (node.NodeType != XmlNodeType.Whitespace) { switch (node.Name.ToLowerInvariant()) { case "html": ProcessChild(node.ChildNodes, sb); break; case "b": case "strong": if (node.HasChildNodes) { sb.Append("'''"); ProcessChild(node.ChildNodes, sb); sb.Append("'''"); } break; case "strike": case "s": if (node.HasChildNodes) { sb.Append("--"); ProcessChild(node.ChildNodes, sb); sb.Append("--"); } break; case "em": case "i": if (node.HasChildNodes) { sb.Append("''"); ProcessChild(node.ChildNodes, sb); sb.Append("''"); } break; case "u": if (node.HasChildNodes) { sb.Append("__"); ProcessChild(node.ChildNodes, sb); sb.Append("__"); } break; case "h1": if (node.HasChildNodes) { if (node.FirstChild.NodeType == XmlNodeType.Whitespace) { sb.Append("----\n"); ProcessChild(node.ChildNodes, sb); } else { if (!(sb.Length == 0 || sb.ToString().EndsWith("\n"))) { sb.Append("\n"); } sb.Append("=="); ProcessChild(node.ChildNodes, sb); sb.Append("==\n"); } } else { sb.Append("----\n"); } break; case "h2": if (!(sb.Length == 0 || sb.ToString().EndsWith("\n"))) { sb.Append("\n"); } sb.Append("==="); ProcessChild(node.ChildNodes, sb); sb.Append("===\n"); break; case "h3": if (!(sb.Length == 0 || sb.ToString().EndsWith("\n"))) { sb.Append("\n"); } sb.Append("===="); ProcessChild(node.ChildNodes, sb); sb.Append("====\n"); break; case "h4": if (!(sb.Length == 0 || sb.ToString().EndsWith("\n"))) { sb.Append("\n"); } sb.Append("====="); ProcessChild(node.ChildNodes, sb); sb.Append("=====\n"); break; case "pre": if (node.HasChildNodes) { sb.Append("@@" + node.InnerText + "@@"); } break; case "code": if (node.HasChildNodes) { sb.Append("{{"); ProcessChild(node.ChildNodes, sb); sb.Append("}}"); } break; case "hr": case "hr /": sb.Append("\n== ==\n"); ProcessChild(node.ChildNodes, sb); break; case "span": if (node.Attributes["style"] != null && node.Attributes["style"].Value.Replace(" ", "").ToLowerInvariant().Contains("font-weight:normal")) { ProcessChild(node.ChildNodes, sb); } else if (node.Attributes["style"] != null && node.Attributes["style"].Value.Replace(" ", "").ToLowerInvariant().Contains("white-space:pre")) { sb.Append(": "); } else { sb.Append(node.OuterXml); } break; case "br": if (node.PreviousSibling != null && node.PreviousSibling.Name == "br") { sb.Append("\n"); } else { if (Settings.GetProcessSingleLineBreaks(_wiki)) { sb.Append("\n"); } else { sb.Append("\n\n"); } } break; case "table": string tableStyle = ""; if (node.Attributes["class"] != null && node.Attributes["class"].Value.Contains("imageauto")) { sb.Append("[imageauto|"); ProcessTableImage(node.ChildNodes, sb); sb.Append("]"); } else { foreach (XmlAttribute attName in node.Attributes) { tableStyle += attName.Name + "=\"" + attName.Value + "\" "; } sb.Append("{| " + tableStyle + "\n"); ProcessTable(node.ChildNodes, sb); sb.Append("|}\n"); } break; case "ol": if (node.PreviousSibling != null && node.PreviousSibling.Name != "br") { sb.Append("\n"); } if (node.ParentNode != null) { if (node.ParentNode.Name != "td") { ProcessList(node.ChildNodes, "#", sb); } else { sb.Append(node.OuterXml); } } else { ProcessList(node.ChildNodes, "#", sb); } break; case "ul": if (node.PreviousSibling != null && node.PreviousSibling.Name != "br") { sb.Append("\n"); } if (node.ParentNode != null) { if (node.ParentNode.Name != "td") { ProcessList(node.ChildNodes, "*", sb); } else { sb.Append(node.OuterXml); } } else { ProcessList(node.ChildNodes, "*", sb); } break; case "sup": sb.Append("<sup>"); ProcessChild(node.ChildNodes, sb); sb.Append("</sup>"); break; case "sub": sb.Append("<sub>"); ProcessChild(node.ChildNodes, sb); sb.Append("</sub>"); break; case "p": if (node.Attributes["class"] != null && node.Attributes["class"].Value.Contains("imagedescription")) { continue; } else { ProcessChild(node.ChildNodes, sb); sb.Append("\n"); if (!Settings.GetProcessSingleLineBreaks(_wiki)) { sb.Append("\n"); } } break; case "div": if (node.Attributes["class"] != null && node.Attributes["class"].Value.Contains("box")) { if (node.HasChildNodes) { sb.Append("((("); ProcessChild(node.ChildNodes, sb); sb.Append(")))"); } } else if (node.Attributes["class"] != null && node.Attributes["class"].Value.Contains("imageleft")) { sb.Append("[imageleft"); ProcessChildImage(node.ChildNodes, sb); sb.Append("]"); } else if (node.Attributes["class"] != null && node.Attributes["class"].Value.Contains("imageright")) { sb.Append("[imageright"); ProcessChildImage(node.ChildNodes, sb); sb.Append("]"); } else if (node.Attributes["class"] != null && node.Attributes["class"].Value.Contains("image")) { sb.Append("[image"); ProcessChildImage(node.ChildNodes, sb); sb.Append("]"); } else if (node.Attributes["class"] != null && node.Attributes["class"].Value.Contains("indent")) { sb.Append(": "); ProcessChild(node.ChildNodes, sb); sb.Append("\n"); } else if (node.Attributes.Count > 0) { sb.Append(node.OuterXml); } else { sb.Append("\n"); if (node.PreviousSibling != null && node.PreviousSibling.Name != "div") { if (!Settings.GetProcessSingleLineBreaks(_wiki)) { sb.Append("\n"); } } if (node.FirstChild != null && node.FirstChild.Name == "br") { node.RemoveChild(node.FirstChild); } if (node.HasChildNodes) { ProcessChild(node.ChildNodes, sb); if (Settings.GetProcessSingleLineBreaks(_wiki)) { sb.Append("\n"); } else { sb.Append("\n\n"); } } } break; case "img": string description = ""; bool hasClass = false; bool isLink = false; if (node.ParentNode != null && node.ParentNode.Name.ToLowerInvariant() == "a") { isLink = true; } if (node.Attributes.Count != 0) { foreach (XmlAttribute attName in node.Attributes) { if (attName.Name == "alt") { description = attName.Value; } if (attName.Name == "class") { hasClass = true; } } } if (!hasClass && !isLink) { sb.Append("[image|" + description + "|" + ProcessImage(node) + "]\n"); } else if (!hasClass && isLink) { sb.Append("[image|" + description + "|" + ProcessImage(node)); } else { sb.Append(description + "|" + ProcessImage(node)); } break; case "a": bool isTable = false; string link = ""; string target = ""; string title = ""; string formattedLink = ""; bool isSystemLink = false; bool childImg = 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) { XmlAttributeCollection attribute = node.Attributes; foreach (XmlAttribute attName in attribute) { if (attName.Name != "id".ToLowerInvariant()) { if (attName.Value.ToLowerInvariant() == "_blank") { target += "^"; } if (attName.Name.ToLowerInvariant() == "href") { link += attName.Value.Replace("%20", " "); } if (attName.Name.ToLowerInvariant() == "title") { title += attName.Value; } if (attName.Name.ToLowerInvariant() == "class" && attName.Value.ToLowerInvariant() == "systemlink") { isSystemLink = true; } if (attName.Name.ToLowerInvariant() == "class" && (attName.Value.ToLowerInvariant() == "unknownlink" || attName.Value.ToLowerInvariant() == "pagelink")) { pageLink = true; } } else { anchor = true; sb.Append("[anchor|#" + attName.Value + "]"); ProcessChild(node.ChildNodes, sb); break; } } if (isSystemLink) { string[] splittedLink = link.Split('='); if (splittedLink.Length == 2) { formattedLink = "c:" + splittedLink[1]; } else { formattedLink = link.LastIndexOf('/') > 0 ? link.Substring(link.LastIndexOf('/') + 1) : link; } } else if (pageLink) { formattedLink = link.LastIndexOf('/') > 0 ? link.Substring(link.LastIndexOf('/') + 1) : link; if (GlobalSettings.PageExtension.Length > 0) { formattedLink = formattedLink.Remove(formattedLink.IndexOf(GlobalSettings.PageExtension)); } formattedLink = Uri.UnescapeDataString(formattedLink); } else { formattedLink = ProcessLink(link); } if (!anchor && !isTable && !childImg) { if (HttpUtility.HtmlDecode(title) != HttpUtility.HtmlDecode(link)) { sb.Append("[" + target + formattedLink + "|"); ProcessChild(node.ChildNodes, sb); sb.Append("]"); } else { sb.Append("[" + target + formattedLink + "]"); } } if (!anchor && !childImg && isTable) { sb.Append("[" + target + formattedLink + "|"); ProcessChild(node.ChildNodes, sb); sb.Append("]"); } if (!anchor && childImg && !isTable) { ProcessChild(node.ChildNodes, sb); sb.Append("|" + target + formattedLink + "]"); } } break; default: sb.Append(node.OuterXml); break; } } } }