private void ResolveKeywords(DitaElement parentElement, DitaCollection collection) { if (parentElement != null) { if (parentElement.Type == "keyword") { string keyref = parentElement.AttributeValueOrDefault("keyref", String.Empty); if (!string.IsNullOrWhiteSpace(keyref)) { // Try to find the referred to file DitaKeyDef keyDef = collection.GetKeyDefByKey(keyref); if (keyDef != null) { if (!string.IsNullOrWhiteSpace(keyDef.Keywords)) { parentElement.SetInnerText(keyDef.Keywords); } } } } else { // Check the child elements if (parentElement.Children != null) { foreach (DitaElement childElement in parentElement.Children) { ResolveKeywords(childElement, collection); } } } } }
// Converts a single dita tag attribute to an html attribute private (string newKey, string newValue) ConvertDitaTagAttributeToHtmlTagAttribute(string key, string value, DitaElement element) { switch (element.Type) { case "a": return(key, value); case "colspec": if (key == "colname") { FixUpTableColumnSpecs(); _tableColumnSpecs[TableColumnIndex].Name = value; } if (key == "colwidth") { FixUpTableColumnSpecs(); _tableColumnSpecs[TableColumnIndex].Width = value; } if (key == "colnum") { if (int.TryParse(value, out int colnum)) { FixUpTableColumnSpecs(); _tableColumnSpecs[TableColumnIndex].Number = colnum; } } break; case "entry": if (key == "morerows") { if (int.TryParse(value, out int rowspan)) { return("rowspan", $"{rowspan + 1}"); } } if (key == "valign") { return(key, value); } break; case "image": if (key == "href") { if (IsImageElementSvg(element)) { return("data", ImageUrlFromHref(value)); } return("src", ImageUrlFromHref(value)); } break; case "section": if (key == "id") { CurrentSection = new DitaPageSectionJson { Anchor = value }; return(key, value); } break; case "tgroup": if (key == "cols") { if (int.TryParse(value, out int columns)) { _tableColumnSpecs = new DitaTableColumnSpec[columns]; } } break; case "xref": if (key == "href") { string url = UrlFromXref(element, out string title); // If we encounter an empty xref, we want to try to generate link text, based on what it links too if (string.IsNullOrWhiteSpace(element.ToString())) { element.SetInnerText(title); } return(key, url); } break; } return("", ""); }