Custom containers

edit

CustomContainers groups blocks so that a stylesheet or a script can treat them as one, such as a warning box, tabs or columns: blocks between a fence of three colons or more, :::name arguments, and a fence as long are rendered as <div class="name">. Text between :: is rendered as <span>.

var options = new MarkdownParseOptions { Extensions = MarkdownExtensions.CustomContainers };
var tree = MarkdownSyntaxTree.ParseText(":::warning Read this\nThis is ::important::.\n:::\n", options);

var container = Assert.IsType<MarkdownCustomContainerSyntax>(tree.GetRoot().Blocks.Single());
Assert.Equal("warning", container.Name);
Assert.Equal("Read this", container.Arguments);
Assert.Equal("<div class=\"warning\"><p>This is <span>important</span>.</p>\n</div>\n", MarkdownHtmlRenderer.ToHtml(tree));

A container is a MarkdownCustomContainerSyntax, whose Name and Arguments give the text after the fence. The closing fence closes the container and its blocks, even a code block. Text between :: is a MarkdownEmphasisExtraSyntax of style CustomContainer.

Generic attributes give a container other classes or attributes.

A node renderer writes the containers of a name as other HTML, such as a <details> element.