Extra emphasis
editCommonMark has two kinds of emphasis, * and **. EmphasisExtras adds the styles that chemical formulas, exponents and reviews need:
| Syntax | Flag | HTML |
|---|---|---|
H~2~O | Subscript | <sub> |
2^10^ | Superscript | <sup> |
++text++ | Inserted | <ins> |
==text== | Marked | <mark> |
~~text~~ | Strikethrough | <del> |
EmphasisExtras enables the five flags, and each one can be enabled alone.
var options = new MarkdownParseOptions { Extensions = MarkdownExtensions.EmphasisExtras };
var tree = MarkdownSyntaxTree.ParseText("H~2~O, 2^10^, ++added++, ==marked== and ~~removed~~\n", options);
var styles = tree.GetRoot().DescendantNodes().OfType<MarkdownEmphasisExtraSyntax>().Select(node => node.Style);
Assert.Equal([MarkdownEmphasisExtraStyle.Subscript, MarkdownEmphasisExtraStyle.Superscript, MarkdownEmphasisExtraStyle.Inserted, MarkdownEmphasisExtraStyle.Marked], styles);
Assert.Equal("<p>H<sub>2</sub>O, 2<sup>10</sup>, <ins>added</ins>, <mark>marked</mark> and <del>removed</del></p>\n", MarkdownHtmlRenderer.ToHtml(tree));They are MarkdownEmphasisExtraSyntax nodes, whose Style gives the kind. The delimiters follow the rules of the delimiters of emphasis. When subscript is enabled, a single ~ is a subscript rather than a strikethrough.