Skip to content

Commit

Permalink
Add JSX language to highlighter.
Browse files Browse the repository at this point in the history
  • Loading branch information
timvandijck committed Jul 22, 2024
1 parent 99dff88 commit 0291a44
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
23 changes: 23 additions & 0 deletions app/Docs/Highlighting/JsxLanguage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace App\Docs\Highlighting;

use Tempest\Highlight\Languages\JavaScript\JavaScriptLanguage;

class JsxLanguage extends JavaScriptLanguage
{
public function getName(): string
{
return 'jsx';
}

public function getInjections(): array
{
return [
...parent::getInjections(),
new JsxHtmlInjection(),

Check failure on line 18 in app/Docs/Highlighting/JsxLanguage.php

View workflow job for this annotation

GitHub Actions / phpstan

Instantiated class App\Docs\Highlighting\JsxHtmlInjection not found.
// new DiffAdditionInjection(),
// new DiffDeletionInjection(),
];
}
}
2 changes: 2 additions & 0 deletions app/Http/Controllers/DocsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use App\Docs\Docs;
use App\Docs\DocumentationPage;
use App\Docs\Highlighting\DiffLanguage;
use App\Docs\Highlighting\JsxLanguage;
use App\Support\CommonMark\ImageRenderer;
use App\Support\CommonMark\LinkRenderer;
use Illuminate\Support\Arr;
Expand Down Expand Up @@ -168,6 +169,7 @@ private function renderMarkdown(string $contents): string
{
$highlighter = new Highlighter();
$highlighter->addLanguage(new DiffLanguage());
$highlighter->addLanguage(new JsxLanguage());

return app(MarkdownRenderer::class)
->highlightCode(false)
Expand Down

0 comments on commit 0291a44

Please sign in to comment.