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); }
private bool NeedMigration(IMarkdownToken token) { var file = token.SourceInfo.File; var markdown = token.SourceInfo.Markdown; if (token is MarkdownTableBlockToken t && NeedMigrationTable(t)) { return(true); } // remvoe end newlines in code block if (token is MarkdownCodeBlockToken) { return(true); } if (token is DfmNoteBlockToken) { return(true); } if (token is DfmIncludeBlockToken || token is DfmIncludeInlineToken || token is DfmFencesBlockToken) { return(true); } if (HasLinkTokenToMigrate(token)) { return(true); } return(!_renderer.CompareMarkupResult(markdown, file)); }