public bool GenerateAllContentAsHtml() { XDocument TOC = XDocument.Load(Configuration.Parms.input_toc); XElement root = (from xml2 in TOC.Descendants("Node") where xml2.Attribute("Name").Value == Configuration.Parms.projectname select xml2).FirstOrDefault(); if (root == null) { root = GetNode(Configuration.Parms.projectname, Data.manual.Title, Configuration.Parms.projectname + ".htm"); TOC.Element("Node").Nodes().FirstOrDefault().AddAfterSelf(root); } root.Nodes().Remove(); StringBuilder ChapterList = new StringBuilder(); foreach (var chapter in Data.manual.Chapters) { root.Add(GenerateChapter(chapter)); string str = "<a href=\"" + Configuration.Parms.projectname + "_" + chapter.No + ".htm\" xmlns=\"http://ddue.schemas.microsoft.com/authoring/2003/5\">"; str += chapter.Title + "</a><br>"; ChapterList.Append(str); } Article preface = Data.Articles.Find(m => m.ID == Data.manual.Preface.ID); if (preface == null) { preface = new Article() { ID = Data.manual.Preface.ID, Text = "TODO: Article " + Data.manual.Preface.ID, Title = "TODO: Article Caption " + Data.manual.Preface.ID }; } StringBuilder topic = new StringBuilder(File.ReadAllText(Configuration.Parms.helppage_html)); topic.Replace("$1$", preface.Title); topic.Replace("$1$", preface.Title); topic.Replace("$2$", ConvertMarkdown(preface.Text, "html") + ChapterList); File.WriteAllText( Configuration.Parms.output_path_helpserver + @"\" + Configuration.Parms.projectname + ".htm", topic.ToString()); TOC.Save(Configuration.Parms.output_toc); return false; }
private XElement GenerateArticle(Topic t) { Article article = Data.Articles.Find(m => m.ID == t.ID); if (article == null) { // Create placeholder article = new Article(); article.Title = "TODO: Needs an article about " + t.ID; article.Text = "TODO: Needs text in article " + t.ID; } XElement node = GetNode(Configuration.Parms.projectname + "_" + t.ID, article.Title, Configuration.Parms.projectname + "_" + t.ID + ".htm"); StringBuilder topic = new StringBuilder(File.ReadAllText(Configuration.Parms.helppage_html)); topic.Replace("$1$", article.Title); topic.Replace("$1$", article.Title); topic.Replace("$2$", ConvertMarkdown(article.Text, "html")); File.WriteAllText(Configuration.Parms.output_path_helpserver + @"\" + Configuration.Parms.projectname + "_" + t.ID + ".htm", topic.ToString()); GenerateSubTopics(t,node); return node; }
private string GenerateArticle(string ID,string SectionType) { Article article = Data.Articles.Find(m => m.ID == ID); if (article == null) { // Create placeholder article = new Article(); article.Title = "TODO: Needs an article about " + ID; article.Text = "TODO: Needs text in article " + ID; } StringBuilder topic = new StringBuilder(); topic.Append(Templates.ArticleTopicHead); topic.Replace("$2$", SectionType); topic.Replace("$1$", article.Title); topic.Append(Templates.ArticleTopicText); topic.Replace("$1$", ConvertMarkdown(article.Text, "latex")); return topic.ToString(); }
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; }
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(); }