Skip to content

Commit 56f23ab

Browse files
authored
Merge pull request #8 from dev-community-de/support-code-addon-code-blocks
Support Code add-on code blocks
2 parents 432e9d5 + 553a326 commit 56f23ab

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

app/CodeFormatterApp.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class CodeFormatterApp
1616
/**
1717
* @var string
1818
*/
19-
protected const CODE_BLOCK_REGEX = '/(\[CODE(?:=([a-z]+)?)?\])((?:.*\n?)*)/';
19+
protected const CODE_BLOCK_REGEX = '/(\[CODE(?:(?:=([a-z]+)?)|(?:\slang=\"?([a-z]+)\"?).*)?\])((?:.*\n?)*)/';
2020

2121
/**
2222
* @var string|array
@@ -116,8 +116,10 @@ protected function captureCodeBlockComponents(array $match)
116116
{
117117
// capture code block components (code tag, code language, actual code content)
118118
$this->code_tag = $match[1];
119-
$this->code_language = $match[2] ?: 'txt';
120-
$this->code_content = $match[3];
119+
$this->code_content = $match[4];
120+
121+
$specified_code_lang = $match[2] ?: $match[3];
122+
$this->code_language = $specified_code_lang ?: 'txt';
121123
}
122124

123125
/**

0 commit comments

Comments
 (0)