예제 #1
0
        private string GenerateContent(Dictionary <string, MarkdownPage> pages, MarkdownPage page)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine(page.GenerateContent(pages));
            foreach (var nextPageId in page.NextPages)
            {
                var formattedNextPageId = nextPageId.LinkId();
                var nextPage            = pages.Values.FirstOrDefault(p => p.GetIdentifier() == formattedNextPageId);

                if (nextPage != null)
                {
                    sb.AppendLine(GenerateContent(pages, nextPage));
                }
                else
                {
                    sb.AppendLine($"FAILED TO FIND PAGE {nextPageId}");
                }
            }

            return(sb.ToString());
        }
예제 #2
0
        private List <MarkdownPage> LoadPage(MarkdownPage page)
        {
            List <MarkdownPage> pages = new List <MarkdownPage>();

            if (page == null)
            {
                return(pages);
            }

            pages.Add(page);
            var dir = Path.GetDirectoryName(page.FilePath);

            foreach (var nextPagePath in page.NextPages)
            {
                var file      = Path.Combine(dir, nextPagePath);
                var nextPage  = MarkdownPage.Generate(file);
                var nextPages = LoadPage(nextPage);
                pages.AddRange(nextPages);
            }

            return(pages);
        }
예제 #3
0
        public static MarkdownPage Generate(string path)
        {
            if (!File.Exists(path))
            {
                return(null);
            }

            var fileName = Path.GetFileName(path);

            var page = new MarkdownPage()
            {
                FilePath = path,
                FileName = fileName
            };

            var lines = File.ReadAllLines(path);

            foreach (var line in lines)
            {
                ProcessLine(line, page);
            }
            return(page);
        }