예제 #1
0
        private ProcessOutput TransformMarkdownFile(
            string inputRoot,
            string inputContent,
            IReadOnlyList <string> templates,
            ImmutableDictionary <string, object> environment
            )
        {
            if (!string.IsNullOrWhiteSpace(inputContent) || templates.Count == 0)
            {
                var markdownContent = markdown.Convert(inputContent, environment);
                return(new ProcessOutput(markdownContent, environment));
            }

            inputContent = templater.Convert(inputRoot, templates.First(), environment, out var iterationExports);
            environment  = environment.SetItems(iterationExports);
            return(TransformMarkdownFile(inputRoot, inputContent, templates.Skip(1).ToArray(), environment));
        }
예제 #2
0
        public void Convert_GivenMarkdown_OutputsHtml()
        {
            var processor = new MarkdownProcessor("pandoc");

            var result = processor.Convert("# Hello World", Settings.Default);

            AssertHelper.AreEqualIgnoringNewLines("<h1 id=\"hello-world\">Hello World</h1>\r\n", result);
        }
예제 #3
0
        public void Convert_BulletedList_OutputsCorrectHtml()
        {
            var markdown = new MarkdownProcessor();
            var result   = markdown.Convert("- I'm a list item.\n- I'm another one.", Settings.Default);

            AssertHelper.AreEqualIgnoringNewLines(
                "<ul>\r\n<li>I’m a list item.</li>\r\n<li>I’m another one.</li>\r\n</ul>\r\n",
                result);
        }
예제 #4
0
        public void Convert_ExecutableNotFound_ThrowsNiceError()
        {
            string executable = Guid.NewGuid().ToString();
            var    processor  = new MarkdownProcessor(executable);

            var ex = Assert.ThrowsException <ErrorMessageException>(() =>
                                                                    processor.Convert("# Hello World", Settings.Default)
                                                                    );

            StringAssert.Contains(ex.Message, $"Could not find {executable} on the path. Is it installed?");
        }