예제 #1
0
        private void SaveForChmNode(TextWriter tw, Dictionary <Preprocessor.TopicPreprocessor, string> outputTopicFilenames, TopicListParser.TopicListNode node)
        {
            tw.WriteLine("<ul>");

            while (node != null)
            {
                if (node.Topic == null)
                {
                    _mergeFiles.Add(TopicListParser.GetLinkToChm(node.Title));
                }

                else
                {
                    tw.WriteLine("<li><object type=\"text/sitemap\">");
                    tw.WriteLine("<param name=\"Name\" value=\"{0}\"/>", node.Title);
                    tw.WriteLine("<param name=\"Name\" value=\"{0}\"/>", node.Topic.Title);
                    tw.WriteLine("<param name=\"Local\" value=\"{0}\"/>", outputTopicFilenames[node.Topic]);
                    tw.WriteLine("</object></li>");
                }

                if (node.ChildNode != null)
                {
                    SaveForChmNode(tw, outputTopicFilenames, node.ChildNode);
                }

                node = node.SiblingNode;
            }

            tw.WriteLine("</ul>");
        }
예제 #2
0
        public TableOfContents(string projectPath)
        {
            string projectName = new DirectoryInfo(projectPath).Name;

            _tableOfContentsFilename = Path.Combine(projectPath, projectName + Constants.TableOfContentsFileExtension);

            if (!File.Exists(_tableOfContentsFilename))
            {
                File.WriteAllText(_tableOfContentsFilename, "", Encoding.UTF8);
            }

            _tableOfContentsParser = new TopicListParser(false);
        }
예제 #3
0
        public Index(string projectPath)
        {
            string projectName = new DirectoryInfo(projectPath).Name;

            _indexFilename = Path.Combine(projectPath, projectName + Constants.IndexFileExtension);

            if (!File.Exists(_indexFilename))
            {
                File.WriteAllText(_indexFilename, "", Encoding.UTF8);
            }

            _indexParser = new TopicListParser(true);
        }
예제 #4
0
        private void GetOrderedTopicsForPdfNode(List <TopicListParser.TopicListNode> topics, TopicListParser.TopicListNode node)
        {
            while (node != null)
            {
                if (TopicListParser.GetLinkToChm(node.Title) == null)  // ignore links to other help files
                {
                    topics.Add(node);

                    if (node.Topic == null)  // a chapter
                    {
                        GetOrderedTopicsForPdfNode(topics, node.ChildNode);
                    }
                }

                node = node.SiblingNode;
            }
        }
예제 #5
0
        private void GenerateForWebsiteNode(StringBuilder sb, Preprocessor.TopicPreprocessor preprocessedTopic, TopicListParser.TopicListNode node)
        {
            while (node != null)
            {
                string linkedChmFilename = TopicListParser.GetLinkToChm(node.Title);

                if (linkedChmFilename != null)  // a link to another help file
                {
                    linkedChmFilename = Path.GetFileNameWithoutExtension(linkedChmFilename);
                    sb.AppendLine(String.Format("<li class=\"toc_li_chapter\"><a href=\"../{0}/\">&lt;Helps for {0}&gt;</a></li>", linkedChmFilename));
                }

                else if (node.Topic == null)  // a chapter
                {
                    bool continueDownTree = NodeContainsTopic(preprocessedTopic, node.ChildNode);

                    sb.AppendLine(String.Format("<li class=\"{0}\"><a href=\"{1}\">{2}</a>",
                                                continueDownTree ? "toc_li_chapter_current" : "toc_li_chapter",
                                                GenerateForWebsiteLink(node), node.Title));

                    if (continueDownTree)
                    {
                        sb.AppendLine("<ul class=\"toc_ul\">");
                        GenerateForWebsiteNode(sb, preprocessedTopic, node.ChildNode);
                        sb.AppendLine("</ul>");
                    }

                    sb.AppendLine("</li>");
                }

                else // a topic
                {
                    sb.AppendLine(String.Format("<li class=\"{0}\"><a href=\"{1}\">{2}</a></li>",
                                                (node.Topic == preprocessedTopic) ? "toc_li_topic_current" : "toc_li_topic", GenerateForWebsiteLink(node), node.Title));
                }

                node = node.SiblingNode;
            }
        }
예제 #6
0
        private void SaveForChmNode(TextWriter tw, Dictionary <Preprocessor.TopicPreprocessor, string> outputTopicFilenames, TopicListParser.TopicListNode node)
        {
            bool ulStartWritten = false;

            while (node != null)
            {
                string linkedChmFilename  = TopicListParser.GetLinkToChm(node.Title);
                string textAfterRecursion = null;

                if (linkedChmFilename != null)  // a link to another help file
                {
                    if (_processedFirstTopicChapter)
                    {
                        _processedLastTopicChapter = true;
                    }

                    if (ulStartWritten)
                    {
                        tw.WriteLine("</ul>");
                        ulStartWritten = false;
                    }

                    linkedChmFilename = Path.GetFileNameWithoutExtension(linkedChmFilename);

                    tw.WriteLine("<object type=\"text/sitemap\">");
                    tw.WriteLine("<param name=\"Name\" value=\"{0}.chm::/{0}.hhc\"/>", linkedChmFilename);
                    tw.WriteLine("<param name=\"Merge\" value=\"{0}.chm::/{0}.hhc\"/>", linkedChmFilename);
                    tw.WriteLine("</object>");
                }

                else // a chapter or topic
                {
                    _processedFirstTopicChapter = true;

                    if (!ulStartWritten)
                    {
                        tw.WriteLine("<ul>");
                        ulStartWritten = true;
                    }

                    tw.WriteLine("<li><object type=\"text/sitemap\">");

                    if (_processedLastTopicChapter)
                    {
                        throw new Exception("Linked help files must come before or after all chapters and topics.");
                    }

                    tw.WriteLine("<param name=\"Name\" value=\"{0}\"/>", node.Title);

                    if (node.Topic != null)
                    {
                        tw.WriteLine("<param name=\"Local\" value=\"{0}\"/>", outputTopicFilenames[node.Topic]);
                    }

                    tw.WriteLine("</object>");

                    textAfterRecursion = "</li>";
                }


                if (node.ChildNode != null)
                {
                    SaveForChmNode(tw, outputTopicFilenames, node.ChildNode);
                }

                if (textAfterRecursion != null)
                {
                    tw.WriteLine(textAfterRecursion);
                }

                node = node.SiblingNode;
            }

            if (ulStartWritten)
            {
                tw.WriteLine("</ul>");
            }
        }
예제 #7
0
 public string Format(string[] lines, Preprocessor preprocessor)
 {
     Compile(lines, preprocessor);
     return(TopicListParser.Format(_tableOfContentsRootNode, false));
 }
예제 #8
0
 public string Format(string[] lines, Preprocessor preprocessor)
 {
     Compile(lines, preprocessor);
     return(TopicListParser.Format(_indexRootNode, true));
 }