/** * Converts all children of the given XML node * * @param Node Xml node we want to parse all children into Markdown * @param Writer Output for markdown text * @param ResolveLink Delegate to call to resolve doxygen id's into link paths. may be null. */ static void ConvertNodeContents(XmlNode Node, MarkdownWriter Writer, ResolveLinkDelegate ResolveLink) { if (Node.HasChildNodes) { foreach (XmlNode ChildNode in Node.ChildNodes) { ConvertNode(ChildNode, Writer, ResolveLink); } } else { Writer.Write(EscapeXmlText(Node.InnerText)); } }
/** * Parses markdown text out of an XML node * * @param child xml node we want to parse into Markdown * @param Indent indenting prefix for each newline of text in the converted markdown * @param Output storage for the output string * @param ResolveLink delegate to call to resolve doxygen id's into link paths. may be null. */ static void ConvertNode(XmlNode Node, MarkdownWriter Writer, ResolveLinkDelegate ResolveLink) { switch (Node.Name) { case "ulink": string LinkText = Node.InnerText; string LinkUrl = Node.Attributes.GetNamedItem("url").InnerText; const string WebPrefix = "docs.unrealengine.com/latest/INT/"; int WebPrefixIdx = LinkUrl.IndexOf(WebPrefix); if (WebPrefixIdx != -1 && LinkText.Contains("docs.unrealengine.com")) { LinkText = ""; LinkUrl = LinkUrl.Substring(WebPrefixIdx + WebPrefix.Length); int AnchorIdx = LinkUrl.LastIndexOf('#'); if (AnchorIdx == -1) { LinkUrl = RemoveDefaultPageName(LinkUrl); } else { LinkUrl = RemoveDefaultPageName(LinkUrl.Substring(0, AnchorIdx)) + LinkUrl.Substring(AnchorIdx); } } Writer.WriteLink(LinkText, LinkUrl); break; case "ref": XmlAttribute RefAttribute = Node.Attributes["refid"]; if (RefAttribute != null && ResolveLink != null) { string LinkPath = ResolveLink(RefAttribute.Value); if (LinkPath != null) { Writer.WriteLink(Node.InnerText, LinkPath); break; } } Writer.Write(Node.InnerText); break; case "bold": Writer.Write("**"); ConvertNodeContents(Node, Writer, ResolveLink); Writer.Write("**"); break; case "emphasis": Writer.Write("_"); ConvertNodeContents(Node, Writer, ResolveLink); Writer.Write("_"); break; case "computeroutput": Writer.Write("`"); ConvertNodeContents(Node, Writer, ResolveLink); Writer.Write("_"); break; case "parameterlist": break; case "parameteritem": break; case "parameternamelist": break; case "parameterdescription": ConvertNodeContents(Node, Writer, ResolveLink); break; case "xrefsect": break; case "simplesect": XmlAttribute KindAttribute = Node.Attributes["kind"]; if (KindAttribute == null || KindAttribute.Value != "see") { ConvertNodeContents(Node, Writer, ResolveLink); } break; case "para": Writer.WriteParagraph(); ConvertNodeContents(Node, Writer, ResolveLink); break; case "itemizedlist": Writer.WriteLine(); foreach (XmlNode ListItemNode in Node.SelectNodes("listitem")) { XmlNodeList ParaNodes = ListItemNode.SelectNodes("para"); if (ParaNodes.Count > 0) { // Write the first node Writer.Write("* "); Writer.AddIndent(" "); ConvertNodeContents(ParaNodes[0], Writer, ResolveLink); // Write anything else as an actual paragraph for (int Idx = 1; Idx < ParaNodes.Count; Idx++) { Writer.WriteLine(); ConvertNodeContents(ParaNodes[Idx], Writer, ResolveLink); } // Finish the line Writer.RemoveIndent(); Writer.WriteLine(); } } break; default: ConvertNodeContents(Node, Writer, ResolveLink); break; } }
/** * Parses markdown text out of an XML node * * @param child xml node we want to parse into Markdown * @param Indent indenting prefix for each newline of text in the converted markdown * @param Output storage for the output string * @param ResolveLink delegate to call to resolve doxygen id's into link paths. may be null. */ static void ConvertNode(XmlNode Node, MarkdownWriter Writer, ResolveLinkDelegate ResolveLink) { switch (Node.Name) { case "ulink": string LinkText = Node.InnerText; string LinkUrl = Node.Attributes.GetNamedItem("url").InnerText; const string WebPrefix = "docs.unrealengine.com/latest/INT/"; int WebPrefixIdx = LinkUrl.IndexOf(WebPrefix); if (WebPrefixIdx != -1 && LinkText.Contains("docs.unrealengine.com")) { LinkText = ""; LinkUrl = LinkUrl.Substring(WebPrefixIdx + WebPrefix.Length); int AnchorIdx = LinkUrl.LastIndexOf('#'); if(AnchorIdx == -1) { LinkUrl = RemoveDefaultPageName(LinkUrl); } else { LinkUrl = RemoveDefaultPageName(LinkUrl.Substring(0, AnchorIdx)) + LinkUrl.Substring(AnchorIdx); } } Writer.WriteLink(LinkText, LinkUrl); break; case "ref": XmlAttribute RefAttribute = Node.Attributes["refid"]; if (RefAttribute != null && ResolveLink != null) { string LinkPath = ResolveLink(RefAttribute.Value); if (LinkPath != null) { Writer.WriteLink(Node.InnerText, LinkPath); break; } } Writer.Write(Node.InnerText); break; case "bold": Writer.Write("**"); ConvertNodeContents(Node, Writer, ResolveLink); Writer.Write("**"); break; case "emphasis": Writer.Write("_"); ConvertNodeContents(Node, Writer, ResolveLink); Writer.Write("_"); break; case "computeroutput": Writer.Write("`"); ConvertNodeContents(Node, Writer, ResolveLink); Writer.Write("_"); break; case "parameterlist": break; case "parameteritem": break; case "parameternamelist": break; case "parameterdescription": ConvertNodeContents(Node, Writer, ResolveLink); break; case "xrefsect": break; case "simplesect": XmlAttribute KindAttribute = Node.Attributes["kind"]; if (KindAttribute == null || KindAttribute.Value != "see") { ConvertNodeContents(Node, Writer, ResolveLink); } break; case "para": Writer.WriteParagraph(); ConvertNodeContents(Node, Writer, ResolveLink); break; case "itemizedlist": Writer.WriteLine(); foreach (XmlNode ListItemNode in Node.SelectNodes("listitem")) { XmlNodeList ParaNodes = ListItemNode.SelectNodes("para"); if (ParaNodes.Count > 0) { // Write the first node Writer.Write("* "); Writer.AddIndent(" "); ConvertNodeContents(ParaNodes[0], Writer, ResolveLink); // Write anything else as an actual paragraph for (int Idx = 1; Idx < ParaNodes.Count; Idx++) { Writer.WriteLine(); ConvertNodeContents(ParaNodes[Idx], Writer, ResolveLink); } // Finish the line Writer.RemoveIndent(); Writer.WriteLine(); } } break; default: ConvertNodeContents(Node, Writer, ResolveLink); break; } }