示例#1
0
 /// <summary>
 /// Uses all extensions except the BootStrap, Emoji, SmartyPants and soft line as hard line breaks extensions.
 /// </summary>
 /// <param name="pipeline">The pipeline.</param>
 /// <returns>The modified pipeline</returns>
 public static MarkdownPipelineBuilder UseAdvancedExtensions(this MarkdownPipelineBuilder pipeline)
 {
     return(pipeline
            .UseAbbreviations()
            .UseAutoIdentifiers()
            .UseCitations()
            .UseCustomContainers()
            .UseDefinitionLists()
            .UseEmphasisExtras()
            .UseFigures()
            .UseFooters()
            .UseFootnotes()
            .UseGridTables()
            .UseMathematics()
            .UseMediaLinks()
            .UsePipeTables()
            .UseListExtras()
            .UseTaskLists()
            .UseGenericAttributes()); // Must be last as it is one parser that is modifying other parsers
 }
示例#2
0
        /// <summary>
        /// Configures the pipeline using a string that defines the extensions to activate.
        /// </summary>
        /// <param name="pipeline">The pipeline (e.g: advanced for <see cref="UseAdvancedExtensions"/>, pipetables+gridtables for <see cref="UsePipeTables"/> and <see cref="UseGridTables"/></param>
        /// <param name="extensions">The extensions to activate as a string</param>
        /// <returns>The modified pipeline</returns>
        public static MarkdownPipelineBuilder Configure(this MarkdownPipelineBuilder pipeline, string extensions)
        {
            if (extensions == null)
            {
                return(pipeline);
            }

            // TODO: the extension string should come from the extension itself instead of this hardcoded switch case.

            foreach (var extension in extensions.Split(new[] { '+' }, StringSplitOptions.RemoveEmptyEntries))
            {
                switch (extension.ToLowerInvariant())
                {
                case "common":
                    break;

                case "advanced":
                    pipeline.UseAdvancedExtensions();
                    break;

                case "pipetables":
                    pipeline.UsePipeTables();
                    break;

                case "gfm-pipetables":
                    pipeline.UsePipeTables(new PipeTableOptions {
                        UseHeaderForColumnCount = true
                    });
                    break;

                case "emphasisextras":
                    pipeline.UseEmphasisExtras();
                    break;

                case "listextras":
                    pipeline.UseListExtras();
                    break;

                case "hardlinebreak":
                    pipeline.UseSoftlineBreakAsHardlineBreak();
                    break;

                case "footnotes":
                    pipeline.UseFootnotes();
                    break;

                case "footers":
                    pipeline.UseFooters();
                    break;

                case "citations":
                    pipeline.UseCitations();
                    break;

                case "attributes":
                    pipeline.UseGenericAttributes();
                    break;

                case "gridtables":
                    pipeline.UseGridTables();
                    break;

                case "abbreviations":
                    pipeline.UseAbbreviations();
                    break;

                case "emojis":
                    pipeline.UseEmojiAndSmiley();
                    break;

                case "definitionlists":
                    pipeline.UseDefinitionLists();
                    break;

                case "customcontainers":
                    pipeline.UseCustomContainers();
                    break;

                case "figures":
                    pipeline.UseFigures();
                    break;

                case "mathematics":
                    pipeline.UseMathematics();
                    break;

                case "bootstrap":
                    pipeline.UseBootstrap();
                    break;

                case "medialinks":
                    pipeline.UseMediaLinks();
                    break;

                case "smartypants":
                    pipeline.UseSmartyPants();
                    break;

                case "autoidentifiers":
                    pipeline.UseAutoIdentifiers();
                    break;

                case "tasklists":
                    pipeline.UseTaskLists();
                    break;

                case "diagrams":
                    pipeline.UseDiagrams();
                    break;

                case "nofollowlinks":
                    pipeline.UseReferralLinks("nofollow");
                    break;

                case "noopenerlinks":
                    pipeline.UseReferralLinks("noopener");
                    break;

                case "noreferrerlinks":
                    pipeline.UseReferralLinks("noreferrer");
                    break;

                case "nohtml":
                    pipeline.DisableHtml();
                    break;

                case "yaml":
                    pipeline.UseYamlFrontMatter();
                    break;

                case "nonascii-noescape":
                    pipeline.UseNonAsciiNoEscape();
                    break;

                case "autolinks":
                    pipeline.UseAutoLinks();
                    break;

                case "globalization":
                    pipeline.UseGlobalization();
                    break;

                default:
                    throw new ArgumentException($"Invalid extension `{extension}` from `{extensions}`", nameof(extensions));
                }
            }
            return(pipeline);
        }
示例#3
0
        /// <summary>
        /// Configures the pipeline using a string that defines the extensions to activate.
        /// </summary>
        /// <param name="pipeline">The pipeline (e.g: advanced for <see cref="UseAdvancedExtensions"/>, pipetables+gridtables for <see cref="UsePipeTables"/> and <see cref="UseGridTables"/></param>
        /// <param name="extensions">The extensions to activate as a string</param>
        /// <returns>The modified pipeline</returns>
        public static MarkdownPipelineBuilder Configure(this MarkdownPipelineBuilder pipeline, string extensions)
        {
            if (extensions == null)
            {
                return(pipeline);
            }

            foreach (var extension in extensions.Split(new[] { '+' }, StringSplitOptions.RemoveEmptyEntries))
            {
                switch (extension.ToLowerInvariant())
                {
                case "common":
                    break;

                case "advanced":
                    pipeline.UseAdvancedExtensions();
                    break;

                case "pipetables":
                    pipeline.UsePipeTables();
                    break;

                case "emphasisextras":
                    pipeline.UseEmphasisExtras();
                    break;

                case "listextras":
                    pipeline.UseListExtras();
                    break;

                case "hardlinebreak":
                    pipeline.UseSoftlineBreakAsHardlineBreak();
                    break;

                case "footnotes":
                    pipeline.UseFootnotes();
                    break;

                case "footers":
                    pipeline.UseFooters();
                    break;

                case "citations":
                    pipeline.UseCitations();
                    break;

                case "attributes":
                    pipeline.UseGenericAttributes();
                    break;

                case "gridtables":
                    pipeline.UseGridTables();
                    break;

                case "abbreviations":
                    pipeline.UseAbbreviations();
                    break;

                case "emojis":
                    pipeline.UseEmojiAndSmiley();
                    break;

                case "definitionlists":
                    pipeline.UseDefinitionLists();
                    break;

                case "customcontainers":
                    pipeline.UseCustomContainers();
                    break;

                case "figures":
                    pipeline.UseFigures();
                    break;

                case "mathematics":
                    pipeline.UseMathematics();
                    break;

                case "bootstrap":
                    pipeline.UseBootstrap();
                    break;

                case "medialinks":
                    pipeline.UseMediaLinks();
                    break;

                case "smartypants":
                    pipeline.UseSmartyPants();
                    break;

                case "autoidentifiers":
                    pipeline.UseAutoIdentifiers();
                    break;

                case "tasklists":
                    pipeline.UseTaskLists();
                    break;

                default:
                    throw new ArgumentException($"Invalid extension `{extension}` from `{extensions}`", nameof(extensions));
                }
            }
            return(pipeline);
        }