Tech News
← Back to articles

Nested Code Fences in Markdown

read original related products more articles

Nested Code Fences in Markdown

By Susam Pal on 19 Jan 2026

Today, we will meet a spiky-haired nerd named Corey Dumm, who normally lives within Markdown code fences. We will get to know him a bit, smile with him when his fences hold and weep quietly when misfortune strikes.

One of the caveats of the Markdown universe is the wide variety of Markdown implementations available. In these parallel universes, the rules of Markdown rendering differ subtly. In this post, we will focus only on the CommonMark specification. Since GitHub Flavoured Markdown (GFM) is a strict superset of CommonMark, whatever we discuss here applies equally well to both CommonMark and GFM.

Contents

Basic Code Fences

Corey had a knack for working with computers ever since he was a kid.

Corey at his computer: ``` (o_o)--.|[_]| ```

Everything was perfect in Corey's world. The CommonMark renderer would convert the Markdown above to the following HTML:

Corey at his computer: (o_o)--.|[_]|

... continue reading