frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Nested Code Fences in Markdown

https://susam.net/nested-code-fences.html
64•todsacerdoti•2h ago

Comments

epage•1h ago
> In fact, a code fence need not consist of exactly three backticks or tildes. Any number of backticks or tildes is allowed, as long as that number is at least three

Unfortunately, some markdown implementations don't handle this well. We were looking at using code-fence like syntax in Rust and we were worried about people knowing how to embed it in markdown code fences but bad implementations was the ultimate deal breaker. We switched to `---` instead, making basic cases look like yaml stream separators which are used for frontmatter.

zelphirkalt•1h ago
All this complication seems to stem from the simple fact, that the fences don't have a recognizably distinct start and end marker. It's all "`" or "~", instead of one symbol at the start and another, different symbol at the end. And then going into the different numbers of backticks or tildes. Why add such ambiguity, that will only make it harder to parse things correctly? This immediately raises the question: "What if I start a block with 4 backticks and end it with 5?"

All these complications would have been avoidable with a more thought through design/better choices of symbols. For example one could have used brackets:

    [[[lang
    code here
    ]]]
And if one wanted to nest it, it should automatically work:

    [[[html
    html code
    [[[css
    css code
    ]]]
    [[[js
    js code
    ]]]
    html code
    ]]]
In case one wants to output literally "[[[" one could escape it using backslash, as usual in many languages.

In a parser that would be much simpler to parse. It is kind of like parsing S-expressions. There is no need for 4 backticks, 5, or any higher number. I don't want to sit there counting backticks in the document, to know what part of a nested code block some code belongs to. It's a silly design.

embedding-shape•59m ago
Indeed! Last time I dealt with this exact problem in a toy application made for myself, I ended up making the markdown parser only read ```$LANG syntax, and making it assume just ``` is a closing tag, not accepting it as a opening tag. Made it easier for the pretty syntax formatter to do it's job too, as it no longer has to figure out the language.
armchairhacker•28m ago
> In case one wants to output literally "[[[" one could escape it using backslash, as usual in many languages.

Sometimes you want to paste a large region of code into a code block, and escaping the content is harder than fixing and start and end delimiters. This matters particularly in Markdown, where embedding large regions of code or text is common, whereas other languages you’d put it in its own file.

So I still suggest the ability to change the number of open and close brackets. Then you’ll also need an implicit newline or other way to distinguish content that starts with an open bracket.

charles_f•21m ago
Your solution for the problem described here is to escape with a different character. MD's is to add more special characters. Both are valid and exist in other languages, I wouldn't qualify one as better thought than the other - though since we're talking about text that I don't want modified, if I prefer adding ticks rather than going into the text and escaping them one by one.

The complication doesn't stem from lack of distinct start and end, what you are trying to solve for here, is when you have multiple languages in a single block, and want pretty colors on each. Seeing that HTML doesn't support imbrication of pre tags (or rather doesn't render one embedded in the next), that would probably not work without producing something that is not pure html.

> In a parser that would be much simpler to parse

Parsing a variable number of ` is not more complex than looking ahead for a closing boundary. In fact, once you introduce escaping characters, you need to handle escaping of the escaping character, which is slightly more complex.

codazoda•48m ago
I might be able to use this, especially in LLMs where I ask them to give me things in code fences all the time. If I ask for markdown in a code fence, it all falls apart. If, however, I asked for markdown in a ~~~ code fence, or even ~~~~~, all would be right with the world, since they typically use ```.
chuckadams•31m ago
Markdown's parser seems to be a fascinating anomaly: a specification that consists only of exceptions and corner cases.
mohsen1•14m ago
I love hacker news! You learn something useful here and there.

I always used html elements like <pre /> and <code /> to go around this in the past

zokier•9m ago
I realize that it would be somewhat antithetical for markdown, but I increasingly feel that length-prefixing everything makes lot of stuff easier at pretty low cost. Anything depending on delimiters or start/end tags inevitably ends up with difficult quoting rules or some other awkward scheme (like seen here).

Show HN: ChartGPU – WebGPU-powered charting library (1M points at 60fps)

https://github.com/ChartGPU/ChartGPU
75•huntergemmer•55m ago•20 comments

Nested Code Fences in Markdown

https://susam.net/nested-code-fences.html
67•todsacerdoti•2h ago•9 comments

RTS for Agents

https://www.getagentcraft.com/
38•summoned•4d ago•18 comments

Anthropic's original take home assignment open sourced

https://github.com/anthropics/original_performance_takehome
502•myahio•12h ago•241 comments

EU–INC – A new pan-European legal entity

https://www.eu-inc.org/
483•tilt•5h ago•468 comments

Batmobile: 10-20x Faster CUDA Kernels for Equivariant Graph Neural Networks

https://elliotarledge.com/blog/batmobile
52•ipnon•3d ago•10 comments

Ireland wants to give its cops spyware, ability to crack encrypted messages

https://www.theregister.com/2026/01/21/ireland_wants_to_give_police/
72•jjgreen•1h ago•25 comments

What Is a PC Compatible?

https://codon.org.uk/~mjg59/blog/p/what-is-a-pc-compatible/
51•edward•5d ago•13 comments

EmuDevz: A game about developing emulators

https://afska.github.io/emudevz/
114•ingve•3d ago•23 comments

Show HN: yolo-cage – AI coding agents that can't exfiltrate secrets

https://github.com/borenstein/yolo-cage
6•borenstein•37m ago•0 comments

Comic-Con Bans AI Art After Artist Pushback

https://www.404media.co/comic-con-bans-ai-art-after-artist-pushback/
60•cdrnsf•1h ago•37 comments

Vibecoding #2

https://matklad.github.io/2026/01/20/vibecoding-2.html
81•ibobev•3h ago•62 comments

Stories removed from the Hacker News Front Page, updated in real time (2024)

https://github.com/vitoplantamura/HackerNewsRemovals
162•akyuu•3h ago•86 comments

Hightouch (YC S19) Is Hiring

https://hightouch.com/careers
1•joshwget•3h ago

SETI@home is in hiberation

https://setiathome.berkeley.edu/
169•keepamovin•6h ago•81 comments

A 26,000-year astronomical monument hidden in plain sight (2019)

https://longnow.org/ideas/the-26000-year-astronomical-monument-hidden-in-plain-sight/
525•mkmk•21h ago•103 comments

RSS.Social – the latest and best from small sites across the web

https://rss.social/
168•Curiositry•13h ago•39 comments

Nukeproof: Manifesto for European Data Sovereignty

https://nukeproof.org/
75•jamesblonde•4h ago•28 comments

cURL removes bug bounties

https://etn.se/index.php/nyheter/72808-curl-removes-bug-bounties.html
348•jnord•9h ago•192 comments

The super-slow conversion of the U.S. to metric (2025)

https://www.thefabricator.com/thefabricator/blog/testingmeasuring/the-super-slow-conversion-of-th...
63•itvision•4h ago•131 comments

TPM on Embedded Systems: Pitfalls and Caveats to Watch Out For

https://sigma-star.at/blog/2026/01/tpm-on-embedded-systems-pitfalls-and-caveats/
5•Deeg9rie9usi•2d ago•0 comments

The percentage of Show HN posts is increasing, but their scores are decreasing

https://snubi.net/posts/Show-HN/
155•plastic041•8h ago•115 comments

The challenges of soft delete

https://atlas9.dev/blog/soft-delete.html
222•buchanae•18h ago•131 comments

Libbbf: Bound Book Format, A high-performance container for comics and manga

https://github.com/ef1500/libbbf
92•zdw•11h ago•57 comments

Finding Matrices that you can multiply wrong, right

https://www.hgreer.com/BadMatrixMultiply/
9•aebtebeten•5d ago•2 comments

I Made Zig Compute 33M Satellite Positions in 3 Seconds. No GPU Required

https://atempleton.bearblog.dev/i-made-zig-compute-33-million-satellite-positions-in-3-seconds-no...
27•signa11•5h ago•4 comments

Which AI Lies Best? A game theory classic designed by John Nash

https://so-long-sucker.vercel.app/
168•lout332•17h ago•72 comments

Show HN: Mastra 1.0, open-source JavaScript agent framework from the Gatsby devs

https://github.com/mastra-ai/mastra
195•calcsam•23h ago•61 comments

The first 100 days as a Renovate maintainer

https://www.jvt.me/posts/2026/01/21/renovate-100-days/
4•speckx•2h ago•0 comments

IPv6 is not insecure because it lacks a NAT

https://www.johnmaguire.me/blog/ipv6-is-not-insecure-because-it-lacks-nat/
264•johnmaguire•20h ago•372 comments