internal void ProcessMD(string md) { string name = Nav.SanitizeFilename(md); string html = raw_html; html = html.Replace("<!--REPLACE--OPT-->", optHtml); html = html.Replace("<!--REPLACE--NAV-->", navHtml); html = html.Replace("<!--REPLACE-SUPERNAV-->", MainNavHTML); #region Get Title string[] lines = File.ReadAllLines(md); if (lines.Length > 3) { for (int i = 1; i < 3; i++) { if (lines[i].Contains("title:")) { title = lines[i].Split(':')[1].Trim(); } } } if (string.IsNullOrEmpty(title.Trim())) { title = name.Replace("-", " "); } StringBuilder bread = new StringBuilder(); if (navs != null) { bread.AppendLine("<ol class=\"breadcrumb visible-md visible-lg\">"); bread.AppendLine( "<li class=\"breadcrumb-item\"><a href=\"/index.html\">Home</a></li>"); bread.AppendLine($"<li class=\"breadcrumb-item\"><a href=\"{BaseItem.Link}\">{BaseItem.Title}</a></li>"); if (navs.Items.Any(i => i.Items.Any(x => x.Title == title))) { bread.AppendLine( $"<li class=\"breadcrumb-item\">{navs.Items.First(i => i.Items.Any(x => x.Title == title))}</li>"); } bread.AppendLine($"<li class=\"breadcrumb-item active\">{title}</li>"); bread.AppendLine("</ol>"); } #endregion Get Title StringBuilder raw = new StringBuilder(); foreach (string s in lines.Skip(3)) { if (s.StartsWith("^")) { string include = $"{Nav.RootPath}\\source\\_includes\\{s.Replace("^", string.Empty)}.md"; if (File.Exists(include)) { raw.AppendLine(File.ReadAllText(include)); } } else { raw.AppendLine(ProcessLinks(s)); } } if (!md.ToLower().Contains("index.md")) { string doc = Markdown.ToPlainText(raw.ToString()); doc = Regex.Replace(doc.Substring(0, doc.Length >= 1200 ? 1200 : doc.Length), @"\{([^\}]+)\}", ""); doc = Regex.Replace(doc.Substring(0, doc.Length >= 1200 ? 1200 : doc.Length), @"\<([^\>]+)\>", ""); search.Add(new SearchObject { url = Nav.GetNavItem(md).Link, title = title, hive = BaseItem.Title, parent = navs.Items.Any(i => i.Items.Any(x => x.Title == title)) ? navs.Items.First(i => i.Items.Any(x => x.Title == title)).Title : "", text = doc }); } StringBuilder output = new StringBuilder(); output.AppendLine(Markdown.ToHtml(raw.ToString(), p)); if (ProcessProceduralFiles) { string @params = $"{Path.GetDirectoryName(md)}\\{Path.GetFileNameWithoutExtension(md)}.params.md"; //? PARAMETERS if (File.Exists(@params)) { output.AppendLine(ProcessParams(@params)); } } if (ProcessExampleFiles) { //! EXAMPLES output.AppendLine(ProcessExamples(md)); } if (ProcessTutorialFiles) { //! TUTORIALS output.AppendLine(ProcessTutorials(md)); } html = html.Replace("<!--REPLACE--BODY-->", $"{bread}<p class=\"faux-h1\">{title}</p>{output}"); html = html.Replace("%%TITLE%%", title); //html = html.Replace("<!--REPLACE--BREADCRUMBS-->", bread.ToString()); try { string subpath = Path.GetDirectoryName(md.Replace(Nav.RootPath, Nav.RootPath + dst)) .Replace("source\\", ""); if (subpath.Contains("Data")) { } if (!subpath.EndsWith("\\")) { subpath += "\\"; } subpath = Nav.ReplaceNumbers(subpath); Directory.CreateDirectory(subpath); //File.WriteAllText(subpath + name + ".html", html); File.WriteAllText(subpath + name + ".html", minifier.Minify(html).MinifiedContent); } catch (IOException) { Console.WriteLine("ERROR: " + Nav.RootPath + dst + name + ".html could not be written."); } //Console.Write("."); }