// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using Markdig; using Markdig.Extensions.AutoLinks; using Markdig.Extensions.CustomContainers; using Markdig.Extensions.EmphasisExtras; using Markdig.Extensions.Footnotes; using osu.Game.Graphics.Containers.Markdown.Extensions; namespace osu.Game.Graphics.Containers.Markdown { /// /// Groups options of customising the set of available extensions to instances. /// public class OsuMarkdownContainerOptions { /// /// Allows the to parse and link footnotes. /// /// public bool Footnotes { get; init; } /// /// Allows the container to make URL text clickable. /// /// public bool Autolinks { get; init; } /// /// Allows the to parse custom containers (used for flags and infoboxes). /// /// public bool CustomContainers { get; init; } /// /// Allows the to parse custom attributes in block elements (used e.g. for custom anchor names in the wiki). /// /// public bool BlockAttributes { get; init; } /// /// Returns a prepared according to the options specified by the current instance. /// /// /// Compare: https://github.com/ppy/osu-web/blob/05488a96b25b5a09f2d97c54c06dd2bae59d1dc8/app/Libraries/Markdown/OsuMarkdown.php#L301 /// public MarkdownPipeline BuildPipeline() { var pipeline = new MarkdownPipelineBuilder() .UseAutoIdentifiers() .UsePipeTables() .UseEmphasisExtras(EmphasisExtraOptions.Strikethrough) .UseYamlFrontMatter(); if (Footnotes) pipeline = pipeline.UseFootnotes(); if (Autolinks) pipeline = pipeline.UseAutoLinks(); if (CustomContainers) pipeline = pipeline.UseCustomContainers(); if (BlockAttributes) pipeline = pipeline.UseBlockAttributes(); return pipeline.Build(); } } }