---
title: "Markdig: CommonMark parser fixes in C# and .NET | VulCode"
description: "Four fixes to the Markdig parser in C#: emphasis in round-trip mode, heading links in nested labels, definition list markers and open cells in grid tables."
url: "https://vulcode.com/en/opensource/contributions/markdig"
lang: "en"
---

[All contributions](https://vulcode.com/en/opensource/contributions)

xoofx/markdig

# Markdig

A fast CommonMark-compliant Markdown processor for .NET, with extensions such as tables, definition lists and automatic heading identifiers.

[See the repository](https://github.com/xoofx/markdig) [All contributions](https://vulcode.com/en/opensource/contributions)

- **Language**: C#
- **GitHub stars**: 5,359
- **Merged changes**: 5
- **Project site**: [xoofx.github.io](http://xoofx.github.io/markdig/)

## What we changed

We fixed four parser bugs: an unmatched emphasis closer no longer moves text to the end of the block, heading references no longer hijack nested link labels, definition lists accept a single space after the marker, and an open last grid table cell no longer takes a | from the next line.

### What this work shows

- The CommonMark spec

- Emphasis delimiter algorithm

- Link reference resolution

- Parser round-trip tests

What was broken

### An unmatched emphasis closer moved text to the end of the block

With EnableTrackTrivia and RoundtripRenderer, a block with +===+ separators came back corrupted: the middle separator column collapsed to a single = and a run of = ended up at the end of the block. Runs of = are delimiters of the == emphasis, and when a match left spare characters, the following text stayed inside the emphasis.

How we fixed it

### Trailing text moves back where it was

In EmphasisInlineParser.ProcessEmphasis, when a closing run has leftover characters, we move the inlines after it out past the outermost emphasis. Tests cover the reported example, a minimal version, and check that ==bold== still renders <mark>bold</mark>.

[#950](https://github.com/xoofx/markdig/pull/950)

What was broken

### A heading hijacked an outer link label

With the AutoLinks and AutoIdentifiers extensions, every heading becomes an implicit link reference definition. In [Testing [Header]](https://www.bing.com), the inner [Header] turned into a link to the heading and the outer link fell apart into plain text.

How we fixed it

### Implicit references stay out of open links

We added an AllowResolutionInsideOpenLink property that heading references set to false, so they are not resolved inside an open link label. Explicit [label]: url definitions and a standalone [Header] work as before.

[#949](https://github.com/xoofx/markdig/pull/949)

What was broken

### Definition lists needed three spaces

The definition list extension treated a colon (:) or a tilde (~) as a marker only when the definition text started in the fourth column. The single-space form, which PHP Markdown Extra and Pandoc accept, ended up as a plain paragraph.

How we fixed it

### One space or tab is enough

The parser now checks for a space or tab after the marker instead of measuring the indent. We replaced the spec example that locked in the old rule with the case from the issue.

[#959](https://github.com/xoofx/markdig/pull/959)

What was broken

### An open cell took a | from the next line

In a grid table the last cell may have no closing |. When such a row was shorter than the table, PeekCharExtra read past the end of the line and the cell picked up the | from the next row.

How we fixed it

### Reading stays within the current line

We replaced PeekCharExtra with PeekChar, which does not read past the current line, so each content line is read on its own. A regression test covers a short row with an open last cell.

[#958](https://github.com/xoofx/markdig/pull/958)

## Merged changes 5

- [#979 Add ConfigureHtmlRenderer to MarkdownPipelineBuilder (#385) Merged 22 November 2026](https://github.com/xoofx/markdig/pull/979)

- [#959 Fix definition lists requiring 3 spaces after the marker Merged 15 October 2026](https://github.com/xoofx/markdig/pull/959)

- [#958 Fix grid table open last cell taking a | from the next line (#494) Merged 15 October 2026](https://github.com/xoofx/markdig/pull/958)

- [#950 Fix: keep trailing content out of an unmatched emphasis closer (#743) Merged 19 September 2026](https://github.com/xoofx/markdig/pull/950)

- [#949 Fix heading auto-link hijacking nested link labels (#668) Merged 19 September 2026](https://github.com/xoofx/markdig/pull/949)

## What it taught us

Markdown parsers break on unclosed and nested constructs, so we start each fix from the CommonMark rule or the behaviour of other implementations. We finish it with a test built from the reported example, including round-trip mode, where the text must come back character for character.

[More about this technology: C# and .NET](https://vulcode.com/en/technologies/csharp-and-dotnet)

## Other projects we write code for

- [**ILSpy** C# · 27,138 stars An open source .NET decompiler that turns compiled assemblies back into readable C# code. It is used to inspect libraries whose source code is not at hand.](https://vulcode.com/en/opensource/contributions/ilspy)

- [**OpenRA** C# · 17,827 stars An open source real-time strategy engine for classic Westwood games such as Command & Conquer: Red Alert, written in C# with SDL and OpenGL.](https://vulcode.com/en/opensource/contributions/openra)

- [**Polly** C# · 14,255 stars A .NET library for handling transient faults: retries, circuit breakers, timeouts and fallback. Its Simmy module injects faults on purpose to test how an application copes with them.](https://vulcode.com/en/opensource/contributions/polly)

- [**FluentValidation** C# · 9,780 stars A popular .NET library for writing strongly typed validation rules in a fluent style, such as RuleFor(...).InclusiveBetween(...).](https://vulcode.com/en/opensource/contributions/fluentvalidation)

- [**Serilog** C# · 8,064 stars A structured logging library for .NET. It records events from message templates, with named properties rather than plain text.](https://vulcode.com/en/opensource/contributions/serilog)

- [**NLog** C# · 6,547 stars A flexible structured logging library for many .NET platforms, configured through layouts, filters and targets.](https://vulcode.com/en/opensource/contributions/nlog)

## Describe your project.

A free quote comes back within an hour during working hours.

### Rather skip the form?

Ask in the chat or write to us directly.

Open the chat

- **Email**: [hello@vulcode.com](mailto:hello@vulcode.com)
- **Phone**: [+48 576 043 920](tel:+48576043920)
- **Discord**: [discord.gg/vulcode](https://discord.gg/vulcode)
