Esempio n. 1
0
        // 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);
        }
Esempio n. 2
0
        // Build the internal structure based on a map
        private void ParseMap()
        {
            try
            {
                // Read the title
                BookTitle.Add("mainbooktitle", RootMap.Title);

                // Read the metadata
                ParseMapMeta();

                if (!BookMeta.ContainsKey("document title"))
                {
                    BookMeta.Add("document title", RootMap.Title);
                }

                // Add the chapters
                Chapters.AddRange(ParseChaptersFromFile(RootMap));

                // Removes any blank topics and replaces them with links to their first populate child
                RemoveBlankPages();
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex);
            }
        }
Esempio n. 3
0
 // Parse the metadata from the given element?
 private void ParseMetaCategories(DitaElement parentElement)
 {
     try
     {
         List <DitaElement> categoriesData = parentElement?.FindChildren("category");
         if (categoriesData != null)
         {
             foreach (DitaElement categoryData in categoriesData)
             {
                 foreach (DitaElement data in categoryData.Children)
                 {
                     if (data?.Attributes.ContainsKey("name") ?? false)
                     {
                         if (BookMeta.ContainsKey(data?.Attributes["name"]))
                         {
                             Trace.TraceWarning($"BookMeta already contains a value for {data?.Attributes["name"]}");
                         }
                         else
                         {
                             BookMeta.Add(data?.Attributes["name"], data?.Attributes["value"]);
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Trace.TraceError(ex);
     }
 }
Esempio n. 4
0
        // Build the internal structure based on the bookmap
        private void ParseBookMap()
        {
            // Find the booktitle element
            try
            {
                // Read the title
                ParseBookMapTitle();

                // Read the metadata
                ParseBookMapBookMeta();

                // Read the front matter
                // IGNORE

                // Read the chapters
                ParseBookMapChapters();

                // Read the back matter
                // IGNORE

                // Removes any blank topics and replaces them with links to their first populate child
                RemoveBlankPages();
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex);
            }
        }