Codegen escape JS open

Markdoc formatter over-escapes a mid-line # (C# becomes C\#)

Formatter over-escapes a mid-line # (C# becomes C\#)

markdoc · markdoc/markdoc

Symptom

The formatter over-escapes a # in the middle of a line because the heading branch of the escape regex is not anchored to line start: 'C# is a language' becomes 'C\# is a language'.

Minimal repro
format(parse('C# is a language')) // 'C\# is a language' - the '#' is escaped mid-sentence
Fix

Anchor the heading alternative: change #+\s to ^#+\s, mirroring the already-anchored ^* and ^> cases.

Fix PR → #markdoc-mid-line-hash-escape

Also in: JavaScript

← all 93 entries