public string Convert(string markdown, string inputFile)
        {
            if (string.IsNullOrEmpty(markdown))
            {
                return(markdown);
            }

            try
            {
                var _renderer = new MarkdigMarkdownRenderer(new Stack <IMarkdownToken>(), _workingFolder, _useLegacyMode);
                if (_renderer.CompareMarkupResult(markdown, GetReletivcePath(inputFile, _workingFolder)))
                {
                    return(markdown);
                }
            }
            catch { }

            var normalized = TrimNewlineBeforeYamlHeader(markdown);

            if (_rule.HasFlag(MigrationRule.Html))
            {
                normalized = RenderHTMLBlock(normalized, inputFile);
            }

            var engine = _builder.CreateDfmEngine(new MarkdigMarkdownRendererProxy(_workingFolder, _useLegacyMode, normalized.Split('\n').Count(), _rule));

            var result = engine.Markup(normalized, GetRelativePath(inputFile));

            if (_rule.HasFlag(MigrationRule.Normalize))
            {
                result = RevertNormalizedPart(result, markdown);
            }

            return(result);
        }
Example #2
0
 public MarkdigMarkdownRendererProxy(string basePath = ".", bool useLegacyMode = true, int totalLines = 0, MigrationRule rule = MigrationRule.All)
 {
     _processedBlockTokens = new Stack <IMarkdownToken>();
     _renderer             = new MarkdigMarkdownRenderer(_processedBlockTokens, basePath, useLegacyMode, rule);
     _totalLines           = totalLines;
     _rule = rule;
 }