public void Given_known_markdown_input_generates_desired_html(string filename) { var markdown = File.ReadAllText($"TestFiles\\Inputs\\{filename}.md"); var parser = MarkdownParserBuilder.GetParserWithAllEvaluators(); var nodes = parser.Parse(markdown); var htmlGenerator = new NodeTreeWalker(); htmlGenerator.LoadTree(nodes); var html = htmlGenerator.ToHtml(Theme.Dark); var expected = File.ReadAllText($"TestFiles\\Outputs\\{filename}.html"); Assert.That(html, Is.EqualTo(expected)); }
private static void Parse(Options options) { var markdown = File.ReadAllText(options.InputFile); var parser = MarkdownParserBuilder.GetParserWithAllEvaluators(); var nodeTree = parser.Parse(markdown); var htmlBuilder = new NodeTreeWalker(); htmlBuilder.LoadTree(nodeTree); var theme = Theme.Dark; if (!string.IsNullOrWhiteSpace(options.Theme)) { theme = (Theme)Enum.Parse(typeof(Theme), options.Theme); } var html = htmlBuilder.ToHtml(theme, options.CustomTheme); string outputFile; if (!string.IsNullOrWhiteSpace(options.OutputFile)) { outputFile = options.OutputFile; } else { outputFile = options.InputFile.EndsWith(".md", StringComparison.InvariantCultureIgnoreCase) ? Regex.Replace(options.InputFile, ".md", ".html", RegexOptions.IgnoreCase) : $"{options.InputFile}.html"; } File.WriteAllText(outputFile, html); }
public void Builder_passes_all_evaluators_to_parser() { var parser = (MarkdownParser)MarkdownParserBuilder.GetParserWithAllEvaluators(); Assert.That(parser.Evaluators.Count, Is.EqualTo(19)); }
public void SetUp() { _parser = MarkdownParserBuilder.GetParserWithAllEvaluators(); }