Ejemplo n.º 1
0
 /// <summary>
 /// Uses the softline break as hardline break extension
 /// </summary>
 /// <param name="pipeline">The pipeline.</param>
 /// <returns>The modified pipeline</returns>
 public static MarkdownPipelineBuilder UseSoftlineBreakAsHardlineBreak(this MarkdownPipelineBuilder pipeline)
 {
     pipeline.Extensions.AddIfNotAlready <SoftlineBreakAsHardlineExtension>();
     return(pipeline);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Uses the list extra extension to add support for `a.`, `A.`, `i.` and `I.` ordered list items.
 /// </summary>
 /// <param name="pipeline">The pipeline.</param>
 /// <returns>
 /// The modified pipeline
 /// </returns>
 public static MarkdownPipelineBuilder UseListExtras(this MarkdownPipelineBuilder pipeline)
 {
     pipeline.Extensions.AddIfNotAlready <ListExtraExtension>();
     return(pipeline);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Uses the grid table extension.
 /// </summary>
 /// <param name="pipeline">The pipeline.</param>
 /// <returns>The modified pipeline</returns>
 public static MarkdownPipelineBuilder UseGridTables(this MarkdownPipelineBuilder pipeline)
 {
     pipeline.Extensions.AddIfNotAlready <GridTableExtension>();
     return(pipeline);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Uses the footnotes extension.
 /// </summary>
 /// <param name="pipeline">The pipeline.</param>
 /// <returns>The modified pipeline</returns>
 public static MarkdownPipelineBuilder UseFootnotes(this MarkdownPipelineBuilder pipeline)
 {
     pipeline.Extensions.AddIfNotAlready <FootnoteExtension>();
     return(pipeline);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Adds the specified extension instance to the extensions collection.
 /// </summary>
 /// <param name="pipeline">The pipeline.</param>
 /// <param name="extension">The instance of the extension to be added.</param>
 /// <typeparam name="TExtension">The type of the extension.</typeparam>
 /// <returns>The modified pipeline</returns>
 public static MarkdownPipelineBuilder Use <TExtension>(this MarkdownPipelineBuilder pipeline, TExtension extension) where TExtension : class, IMarkdownExtension
 {
     pipeline.Extensions.AddIfNotAlready(extension);
     return(pipeline);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Uses this extension to disable URI escape with % characters for non-US-ASCII characters in order to workaround a bug under IE/Edge with local file links containing non US-ASCII chars. DO NOT USE OTHERWISE.
 /// </summary>
 /// <param name="pipeline">The pipeline.</param>
 /// <returns>The modified pipeline</returns>
 public static MarkdownPipelineBuilder UseNonAsciiNoEscape(this MarkdownPipelineBuilder pipeline)
 {
     pipeline.Extensions.AddIfNotAlready <NonAsciiNoEscapeExtension>();
     return(pipeline);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Uses the bootstrap extension.
 /// </summary>
 /// <param name="pipeline">The pipeline.</param>
 /// <returns>The modified pipeline</returns>
 public static MarkdownPipelineBuilder UseBootstrap(this MarkdownPipelineBuilder pipeline)
 {
     pipeline.Extensions.AddIfNotAlready <BootstrapExtension>();
     return(pipeline);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Adds support for right-to-left content by adding appropriate html attribtues.
 /// </summary>
 /// <param name="pipeline">The pipeline</param>
 /// <returns>The modified pipeline</returns>
 public static MarkdownPipelineBuilder UseGlobalization(this MarkdownPipelineBuilder pipeline)
 {
     pipeline.Extensions.AddIfNotAlready <GlobalizationExtension>();
     return(pipeline);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Uses precise source code location (useful for syntax highlighting).
 /// </summary>
 /// <param name="pipeline">The pipeline.</param>
 /// <returns>The modified pipeline</returns>
 public static MarkdownPipelineBuilder UsePreciseSourceLocation(this MarkdownPipelineBuilder pipeline)
 {
     pipeline.PreciseSourceLocation = true;
     return(pipeline);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Uses the custom container extension.
 /// </summary>
 /// <param name="pipeline">The pipeline.</param>
 /// <returns>The modified pipeline</returns>
 public static MarkdownPipelineBuilder UseCustomContainers(this MarkdownPipelineBuilder pipeline)
 {
     pipeline.Extensions.AddIfNotAlready <CustomContainerExtension>();
     return(pipeline);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Uses the diagrams extension
 /// </summary>
 /// <param name="pipeline">The pipeline.</param>
 /// <returns>The modified pipeline</returns>
 public static MarkdownPipelineBuilder UseDiagrams(this MarkdownPipelineBuilder pipeline)
 {
     pipeline.Extensions.AddIfNotAlready <DiagramExtension>();
     return(pipeline);
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Uses pragma lines to output span with an id containing the line number (pragma-line#line_number_zero_based`)
 /// </summary>
 /// <param name="pipeline">The pipeline.</param>
 /// <returns>The modified pipeline</returns>
 public static MarkdownPipelineBuilder UsePragmaLines(this MarkdownPipelineBuilder pipeline)
 {
     pipeline.Extensions.AddIfNotAlready <PragmaLineExtension>();
     return(pipeline);
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Uses YAML frontmatter extension that will parse a YAML frontmatter into the MarkdownDocument. Note that they are not rendered by any default HTML renderer.
 /// </summary>
 /// <param name="pipeline">The pipeline.</param>
 /// <returns>The modified pipeline</returns>
 public static MarkdownPipelineBuilder UseYamlFrontMatter(this MarkdownPipelineBuilder pipeline)
 {
     pipeline.Extensions.AddIfNotAlready <YamlFrontMatterExtension>();
     return(pipeline);
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Uses the generic attributes extension.
 /// </summary>
 /// <param name="pipeline">The pipeline.</param>
 /// <returns>The modified pipeline</returns>
 public static MarkdownPipelineBuilder UseGenericAttributes(this MarkdownPipelineBuilder pipeline)
 {
     pipeline.Extensions.AddIfNotAlready <GenericAttributesExtension>();
     return(pipeline);
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Uses the math extension.
 /// </summary>
 /// <param name="pipeline">The pipeline.</param>
 /// <returns>The modified pipeline</returns>
 public static MarkdownPipelineBuilder UseMathematics(this MarkdownPipelineBuilder pipeline)
 {
     pipeline.Extensions.AddIfNotAlready <MathExtension>();
     return(pipeline);
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Add rel=nofollow to all links rendered to HTML.
 /// </summary>
 /// <param name="pipeline"></param>
 /// <returns></returns>
 public static MarkdownPipelineBuilder UseNoFollowLinks(this MarkdownPipelineBuilder pipeline)
 {
     pipeline.Extensions.AddIfNotAlready <NoFollowLinksExtension>();
     return(pipeline);
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Uses the custom abbreviation extension.
 /// </summary>
 /// <param name="pipeline">The pipeline.</param>
 /// <returns>The modified pipeline</returns>
 public static MarkdownPipelineBuilder UseAbbreviations(this MarkdownPipelineBuilder pipeline)
 {
     pipeline.Extensions.AddIfNotAlready <AbbreviationExtension>();
     return(pipeline);
 }
Ejemplo n.º 18
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 "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.UseNoFollowLinks();
                    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);
        }
Ejemplo n.º 19
0
 /// <summary>
 /// Uses the definition lists extension.
 /// </summary>
 /// <param name="pipeline">The pipeline.</param>
 /// <returns>The modified pipeline</returns>
 public static MarkdownPipelineBuilder UseDefinitionLists(this MarkdownPipelineBuilder pipeline)
 {
     pipeline.Extensions.AddIfNotAlready <DefinitionListExtension>();
     return(pipeline);
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Configures the string to be used for line-endings, when writing.
 /// </summary>
 /// <param name="pipeline">The pipeline.</param>
 /// <param name="newLine">The string to be used for line-endings.</param>
 /// <returns>The modified pipeline</returns>
 public static MarkdownPipelineBuilder ConfigureNewLine(this MarkdownPipelineBuilder pipeline, string newLine)
 {
     pipeline.Use(new ConfigureNewLineExtension(newLine));
     return(pipeline);
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Uses this extension to enable autolinks from text `http://`, `https://`, `ftp://`, `mailto:`, `www.xxx.yyy`
 /// </summary>
 /// <param name="pipeline">The pipeline.</param>
 /// <returns>The modified pipeline</returns>
 public static MarkdownPipelineBuilder UseAutoLinks(this MarkdownPipelineBuilder pipeline, AutoLinkOptions options = null)
 {
     pipeline.Extensions.ReplaceOrAdd <AutoLinkExtension>(new AutoLinkExtension(options));
     return(pipeline);
 }