Skip to content

Commit 3f640d5

Browse files
committed
Don't add language- to class if already prefixed
See commonmark/commonmark.js@c7aef33
1 parent 49998f1 commit 3f640d5

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Updates should follow the [Keep a CHANGELOG](https://keepachangelog.com/) princi
99
### Fixed
1010

1111
- Fixed declaration parser being too strict
12+
- `FencedCodeRenderer`: don't add `language-` to class if already prefixed
1213

1314
## [2.4.1] - 2023-08-30
1415

src/Extension/CommonMark/Renderer/Block/FencedCodeRenderer.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ public function render(Node $node, ChildNodeRendererInterface $childRenderer): \
4141

4242
$infoWords = $node->getInfoWords();
4343
if (\count($infoWords) !== 0 && $infoWords[0] !== '') {
44-
$attrs->append('class', 'language-' . $infoWords[0]);
44+
$class = $infoWords[0];
45+
if (!\str_starts_with($class, 'language-')) {
46+
$class = 'language-' . $class;
47+
}
48+
$attrs->append('class', $class);
4549
}
4650

4751
return new HtmlElement(

0 commit comments

Comments
 (0)