Skip to content

Commit 05f6ec8

Browse files
committed
Add data-lang to the rendered output
1 parent 2813604 commit 05f6ec8

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
],
2020
"require": {
2121
"php": "^7.2|^8.0",
22-
"torchlight/torchlight-laravel": "^0.5.5",
22+
"torchlight/torchlight-laravel": "^0.5.9",
2323
"league/commonmark": "^1.5|^2.0"
2424
},
2525
"require-dev": {

src/BaseExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function useCustomBlockRenderer($callback)
6666
public function defaultBlockRenderer()
6767
{
6868
return function (Block $block) {
69-
return "<pre><code class='{$block->classes}' style='{$block->styles}'>{$block->highlighted}</code></pre>";
69+
return "<pre><code {$block->attrsAsString()}class='{$block->classes}' style='{$block->styles}'>{$block->highlighted}</code></pre>";
7070
};
7171
}
7272

tests/BaseRendererTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ public function it_highlights_code_blocks()
5252
'id' => 'block_id_1',
5353
'classes' => 'torchlight',
5454
'styles' => 'color: red;',
55+
'attrs' => [
56+
'data-lang' => 'lang'
57+
],
5558
'highlighted' => 'highlighted',
5659
]]
5760
];
@@ -64,7 +67,7 @@ public function it_highlights_code_blocks()
6467

6568
$expected = <<<EOT
6669
<p>before</p>
67-
<pre><code class='torchlight' style='color: red;'>highlighted</code></pre>
70+
<pre><code data-lang="lang" class='torchlight' style='color: red;'>highlighted</code></pre>
6871
<p>after</p>
6972
7073
EOT;

0 commit comments

Comments
 (0)