Example #1
0
        public XElement GenerateChapter(Chapter chapter)
        {
            XElement node = GetNode(Configuration.Parms.projectname + "_" + chapter.No, chapter.Title, Configuration.Parms.projectname + "_" + chapter.No + ".htm");

            StringBuilder c = new StringBuilder(File.ReadAllText(Configuration.Parms.helppage_html));
            Article preface = Data.Articles.Find(m => m.ID == chapter.Preface.ID);
            if (preface == null)
            {
                preface = new Article()
                {
                    ID = chapter.Preface.ID,
                    Text = "TODO: Article " + chapter.Preface.ID,
                    Title = "TODO: Article Caption " + chapter.Preface.ID
                };
            }
            c.Replace("$1$", chapter.Title.Replace("%", @"\%"));
            c.Replace("$1$", chapter.Title.Replace("%", @"\%"));
            c.Replace("$2$", ConvertMarkdown(preface.Text, "html"));
            File.WriteAllText(Configuration.Parms.output_path_helpserver + @"\" +
                Configuration.Parms.projectname + "_" + chapter.No + ".htm", c.ToString());
            foreach (var t in chapter.Topics)
            {
                XElement subnode = GenerateTopic(t);
                node.Add(subnode);
            }
            return node;
        }
Example #2
0
        public string GenerateChapter(Chapter chapter)
        {
            StringBuilder c = new StringBuilder(Templates.ChapterHead);

            Article preface = null;

            if (chapter.Preface.Type == "Article")
            {
                preface = Data.Articles.Find(m => m.ID == chapter.Preface.ID);
                if (preface == null)
                {
                    preface = new Article()
                    {
                        Text = "TODO: Article " + chapter.Preface.ID,
                        Title = "TODO: Article Caption " + chapter.Preface.ID
                    };
                }
            }
            if (chapter.Preface.Type == "File")
            {
                if (chapter.Preface.ID.Length > 3)
                {
                    preface = new Article()
                    {
                        Text = File.ReadAllText(Configuration.Parms.input_markdown_path + chapter.Preface.ID),
                        Title = chapter.Preface.FileTitle
                    };
                }
                else
                {
                    preface = new Article()
                    {
                        Text = "TODO: File",
                        Title = "TODO: File Caption (FileTitle)"
                    };
                }
            }
            c.Replace("$1$", chapter.Title.Replace("%", @"\%"));
            c.Replace("$2$", ConvertMarkdown(preface.Text, "latex"));
            foreach (var t in chapter.Topics)
            {
                c.Append(GenerateTopic(t));
                c.Append(Templates.ChapterBetweenTopics);
            }
            return c.ToString();
        }