// Parse chapter structure from a dita topic (leaf node) private List <DitaCollectionLinkJson> ParseChaptersFromTopic(DitaFileTopicAbstract topic, string navTitle = null) { List <DitaCollectionLinkJson> chapters = new List <DitaCollectionLinkJson>(); try { // Build a page for this topic DitaPageJson topicPage = new DitaPageJson(topic, Collection); Pages.Add(topicPage); // Add this chapter to the toc for this page DitaCollectionLinkJson chapter = new DitaCollectionLinkJson { FileName = topicPage.FileName, Title = navTitle ?? topicPage.Title }; chapters.Add(chapter); Trace.TraceInformation($"Found link to topic {chapter.FileName}."); } catch (Exception ex) { Trace.TraceError($"Error parsing topic {topic.FileName} - {ex}"); } return(chapters); }
// Does the given chapter link point to an empty page? private bool IsLinkToEmptyPage(DitaCollectionLinkJson link, out DitaPageJson pageJson) { pageJson = Pages.FirstOrDefault(o => o.FileName == link.FileName); // Is the page empty? return(pageJson?.IsEmpty ?? false); }