// 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.GenericAttributes; using Markdig.Renderers; using Markdig.Syntax; namespace osu.Game.Graphics.Containers.Markdown.Extensions { /// /// A variant of /// which only handles generic attributes in the current markdown and ignores inline generic attributes. /// /// /// For rationale, see implementation of . /// public class BlockAttributeExtension : IMarkdownExtension { private readonly GenericAttributesExtension genericAttributesExtension = new GenericAttributesExtension(); public void Setup(MarkdownPipelineBuilder pipeline) { genericAttributesExtension.Setup(pipeline); // GenericAttributesExtension registers a GenericAttributesParser in pipeline.InlineParsers. // this conflicts with the CustomContainerExtension, leading to some custom containers (e.g. flags) not displaying. // as a workaround, remove the inline parser here before it can do damage. pipeline.InlineParsers.RemoveAll(parser => parser is GenericAttributesParser); } public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer) => genericAttributesExtension.Setup(pipeline, renderer); } }