Repository navigation
Highlights
Less memory on real-world pages
The cleanup pass for unclosed <script> and <style> tags copied the rest of the document once per tag, so script-heavy pages paid for it on every conversion. It now runs in linear time.
Measured with BenchmarkDotNet on real-world pages (Wikipedia, framework docs, MDN), 6.2.1 against 6.3.0, three launches each:
| Page | Allocated | Time |
|---|---|---|
| github-markdown-complete (420 KB) | -58% | -15% |
| mdn-array (230 KB) | -55% | -1% |
| react-learn (259 KB) | -50% | -3% |
| vuejs-docs (110 KB) | -32% | -2% |
| nuxt-example (3.5 KB) | -21% | -13% |
| wikipedia-small (162 KB) | -20% | -1% |
| wikipedia-largest (1.77 MB) | -11% | +1% |
Allocations drop on every page. Time improves on github-markdown-complete and nuxt-example; on the other pages the change is within run-to-run noise. See the Performance guide for the full results and how to reproduce them.
Write Markdown to a TextWriter
Convert and Render have new overloads that write straight to a file or any other TextWriter, skipping the full-size output string:
Convert(html, TextWriter)andRender(document, TextWriter)ConvertAsync(html, TextWriter, CancellationToken)andRenderAsync(...), which await every write, so they work where synchronous I/O is disallowed, such as an ASP.NET Core response body
The output is identical to the string overloads, including trimming and Formatting.OutputLineEnding. With the Slack, CommonMark and GitHub flavors the string is still built internally, so there is no memory saving there. See Writing to a TextWriter.
Other changes
- Writers that derive from
MarkdownWriterBaseget a protectedWritePostamblehook for content after the body and footnotes. MultiMarkdown abbreviation definitions now use it. - Benchmark tooling for contributors: a script to fetch the real-world page set, corpus and throughput benchmarks, and
-p:UseLocalReverseMarkdown=trueto measure a working tree.
No breaking changes: everything new is additive.
What's Changed
- 6.3.0: faster script/style cleanup, TextWriter and async output by @mysticmind in #437
Full Changelog: 6.2.1...6.3.0