You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
{@example} may breakout of fenced code block, insufficient backticks #4284
Per CommonMark a fenced
code block ends at the first closing fence of at least the opening length, so any
example whose content contains a ``` line truncates the block early and leaks
the remainder of the example into the page as markdown.
Actual output — the block closes at the ```console line's matching fence,
so only Install it: is inside the code block and dart pub add foo plus the
trailing fence escape into the rendered page:
```md
Install it:
```console
dart pub add foo
```
Expected — a fence long enough to contain the content:
Compute the fence length from the content instead of hard-coding 3:
final longest =RegExp(r'^\s*(`{3,})', multiLine:true)
.allMatches(content)
.map((m) => m[1]!.length)
.fold(2, max);
final fence ='`'*max(3, longest +1);
return'$fence$language\n$content$trailing$fence';
Why it matters
This isn't hypothetical — it hits any example file that is itself markdown, any
Dart example containing a doc comment with a code sample, and any example
containing a string literal with a fence. The failure is silent: no warning, just
broken documentation.
Activity
FMorschel commentedon Sep 17, 2026
jonasfj commentedon Sep 20, 2026
@FMorschel please file as separate issues, this is unrelated to dartdoc.
If there are markdown parsing issues in package:markdown file against that package.
szakarias commentedon Sep 22, 2026
Fixed in #4285