* fix: keep trailing content out of unmatched emphasis closer (#743) When EnableTrackTrivia() is enabled, an emphasis closer whose delimiter run is only partially consumed (its leftover dropping below the minimum count) kept the inlines that follow it nested inside the emphasis. The roundtrip renderer then emitted the closing delimiters after that trailing content, corrupting the output, for example a grid table separator row using the "marked" (==) delimiter from EmphasisExtras. Move the trailing content out to the outermost enclosing emphasis when the closer can no longer be matched, mirroring the existing handling for a fully consumed opener. The leftover closer keeps its position, so cases without trailing content are unaffected. Adds a regression test. * Fix unmatched emphasis closer cleanup order (#743) --------- Co-authored-by: Alexandre Mutel <alexandre_mutel@live.com>
99 lines
2.0 KiB
Markdown
99 lines
2.0 KiB
Markdown
---
|
|
title: Emphasis extras
|
|
---
|
|
|
|
# Emphasis extras
|
|
|
|
Enable with `.UseEmphasisExtras()` (included in `UseAdvancedExtensions()`).
|
|
|
|
This extension adds several emphasis styles beyond standard bold and italic.
|
|
|
|
If you need improved emphasis parsing for Chinese/Japanese/Korean (CJK) text, see [CJK friendly emphasis](cjk-friendly-emphasis.md).
|
|
|
|
## Strikethrough
|
|
|
|
Wrap text with `~~` for strikethrough:
|
|
|
|
```markdown
|
|
This is ~~deleted~~ text.
|
|
```
|
|
|
|
This is ~~deleted~~ text.
|
|
|
|
## Subscript
|
|
|
|
Wrap text with `~` for subscript:
|
|
|
|
```markdown
|
|
H~2~O is water.
|
|
```
|
|
|
|
H~2~O is water.
|
|
|
|
## Superscript
|
|
|
|
Wrap text with `^` for superscript:
|
|
|
|
```markdown
|
|
2^10^ is 1024.
|
|
```
|
|
|
|
2^10^ is 1024.
|
|
|
|
## Inserted text
|
|
|
|
Wrap text with `++` for inserted/underlined text:
|
|
|
|
```markdown
|
|
This text has been ++inserted++.
|
|
```
|
|
|
|
This text has been ++inserted++.
|
|
|
|
## Marked/highlighted text
|
|
|
|
Wrap text with `==` for marked/highlighted text:
|
|
|
|
```markdown
|
|
This is ==highlighted== text.
|
|
```
|
|
|
|
This is ==highlighted== text.
|
|
|
|
An unmatched remainder of a closing delimiter run must not pull subsequent text
|
|
into the emphasis. For example, `===a===== tail` renders as
|
|
`=<mark>a===</mark> tail`. This example also round-trips unchanged with
|
|
`EnableTrackTrivia()` and `RoundtripRenderer`.
|
|
|
|
## HTML output
|
|
|
|
{.table}
|
|
| Syntax | HTML output |
|
|
|---|---|
|
|
| `~~text~~` | `<del>text</del>` |
|
|
| `~text~` | `<sub>text</sub>` |
|
|
| `^text^` | `<sup>text</sup>` |
|
|
| `++text++` | `<ins>text</ins>` |
|
|
| `==text==` | `<mark>text</mark>` |
|
|
|
|
## Selective activation
|
|
|
|
By default, all emphasis extras are enabled. Use `EmphasisExtraOptions` to enable only specific ones:
|
|
|
|
```csharp
|
|
using Markdig.Extensions.EmphasisExtras;
|
|
|
|
var pipeline = new MarkdownPipelineBuilder()
|
|
.UseEmphasisExtras(EmphasisExtraOptions.Strikethrough | EmphasisExtraOptions.Superscript)
|
|
.Build();
|
|
```
|
|
|
|
Available options:
|
|
|
|
- `EmphasisExtraOptions.Strikethrough`
|
|
- `EmphasisExtraOptions.Subscript`
|
|
- `EmphasisExtraOptions.Superscript`
|
|
- `EmphasisExtraOptions.Inserted`
|
|
- `EmphasisExtraOptions.Marked`
|
|
- `EmphasisExtraOptions.Default` (all of the above)
|