public DfmEngineBuilder(Options options) : base(options) { var inlineRules = InlineRules.ToList(); var index = inlineRules.FindLastIndex(s => s is MarkdownLinkInlineRule); if (index < 0) throw new ArgumentException("MarkdownLinkInlineRule should exist!"); inlineRules.Insert(index + 1, new DfmXrefInlineRule()); inlineRules.Insert(index, new DfmIncludeInlineRule()); index = inlineRules.FindIndex(s => s is MarkdownTextInlineRule); inlineRules[index] = new DfmTextInlineRule(); var blockRules = BlockRules.ToList(); index = blockRules.FindLastIndex(s => s is MarkdownNewLineBlockRule); if (index < 0) throw new ArgumentException("MarkdownNewLineBlockRule should exist!"); blockRules.Insert(index + 1, new DfmIncludeBlockRule()); blockRules.Insert(index + 2, new DfmYamlHeaderBlockRule()); blockRules.Insert(index + 3, new DfmSectionBeginBlockRule()); blockRules.Insert(index + 4, new DfmFencesBlockRule()); blockRules.Insert(index + 5, new DfmNoteBlockRule()); blockRules.Insert(index + 6, new DfmSectionEndBlockRule()); var gfmIndex = blockRules.FindIndex(item => item is GfmParagraphBlockRule); blockRules[gfmIndex] = new DfmParagraphBlockRule(); var markdownBlockQuoteIndex = blockRules.FindIndex(item => item is MarkdownBlockquoteBlockRule); blockRules[markdownBlockQuoteIndex] = new DfmBlockquoteBlockRule(); InlineRules = inlineRules.ToImmutableList(); BlockRules = blockRules.ToImmutableList(); }
public DfmEngineBuilder(Options options, CompositionHost host = null) : base(options) { var inlineRules = InlineRules.ToList(); var index = inlineRules.FindLastIndex(s => s is MarkdownLinkInlineRule); if (index < 0) { throw new ArgumentException("MarkdownLinkInlineRule should exist!"); } inlineRules.Insert(index + 1, new DfmXrefInlineRule()); inlineRules.Insert(index + 1, new DfmEmailInlineRule()); inlineRules.Insert(index, new DfmIncludeInlineRule()); index = inlineRules.FindIndex(s => s is MarkdownTextInlineRule); inlineRules[index] = new DfmTextInlineRule(); var blockRules = BlockRules.ToList(); index = blockRules.FindLastIndex(s => s is MarkdownNewLineBlockRule); if (index < 0) { throw new ArgumentException("MarkdownNewLineBlockRule should exist!"); } blockRules.Insert(index + 1, new DfmIncludeBlockRule()); blockRules.Insert(index + 2, new DfmYamlHeaderBlockRule()); blockRules.Insert(index + 3, new DfmSectionBlockRule()); blockRules.Insert(index + 4, new DfmFencesBlockRule()); blockRules.Insert(index + 5, new DfmNoteBlockRule()); var gfmIndex = blockRules.FindIndex(item => item is GfmParagraphBlockRule); blockRules[gfmIndex] = new DfmParagraphBlockRule(); var markdownBlockQuoteIndex = blockRules.FindIndex(item => item is MarkdownBlockquoteBlockRule); blockRules[markdownBlockQuoteIndex] = new DfmBlockquoteBlockRule(); InlineRules = inlineRules.ToImmutableList(); BlockRules = blockRules.ToImmutableList(); Rewriter = InitMarkdownStyleCop(host); }