Skip to content

Commit

Permalink
Don't add language- to class if already prefixed
Browse files Browse the repository at this point in the history
  • Loading branch information
colinodell committed Jan 29, 2024
1 parent 49998f1 commit 3f640d5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Updates should follow the [Keep a CHANGELOG](https://keepachangelog.com/) princi
### Fixed

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

## [2.4.1] - 2023-08-30

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ public function render(Node $node, ChildNodeRendererInterface $childRenderer): \

$infoWords = $node->getInfoWords();
if (\count($infoWords) !== 0 && $infoWords[0] !== '') {
$attrs->append('class', 'language-' . $infoWords[0]);
$class = $infoWords[0];
if (!\str_starts_with($class, 'language-')) {

Check failure on line 45 in src/Extension/CommonMark/Renderer/Block/FencedCodeRenderer.php

View workflow job for this annotation

GitHub Actions / PHPCS

Expected 1 line after "if", found 0.

Check failure on line 45 in src/Extension/CommonMark/Renderer/Block/FencedCodeRenderer.php

View workflow job for this annotation

GitHub Actions / PHPCS

Expected 1 space after NOT operator; 0 found
$class = 'language-' . $class;
}
$attrs->append('class', $class);
}

return new HtmlElement(
Expand Down

0 comments on commit 3f640d5

Please sign in to comment.