Skip to content

Commit

Permalink
Markdown Code syntax highlight
Browse files Browse the repository at this point in the history
  • Loading branch information
roberto-butti committed May 1, 2024
1 parent 7ce26ab commit c56a53b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
],
"require": {
"php": "^8.2|^8.3",
"illuminate/support": "^11.0",
"calebporzio/sushi": "^2.5",
"illuminate/support": "^11.0",
"league/commonmark": "^2.4",
"spatie/commonmark-highlighter": "^3.0",
"spatie/yaml-front-matter": "^2.0"
},
"require-dev": {
Expand Down
9 changes: 9 additions & 0 deletions src/Models/FusionBaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
use Illuminate\Support\Str;
use League\CommonMark\Environment\Environment;
use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
use League\CommonMark\Extension\CommonMark\Node\Block\FencedCode;
use League\CommonMark\Extension\CommonMark\Node\Block\IndentedCode;
use League\CommonMark\MarkdownConverter;
use Spatie\CommonMarkHighlighter\FencedCodeRenderer;
use Spatie\CommonMarkHighlighter\IndentedCodeRenderer;
use Spatie\YamlFrontMatter\YamlFrontMatter;

abstract class FusionBaseModel extends Model
Expand Down Expand Up @@ -67,6 +71,11 @@ public function getFrontmatterRows($columns = []): array

$environment = (new Environment())
->addExtension(new CommonMarkCoreExtension());

//$environment->addExtension(new CommonMarkCoreExtension());
$environment->addRenderer(FencedCode::class, new FencedCodeRenderer());
$environment->addRenderer(IndentedCode::class, new IndentedCodeRenderer());

$converter = new MarkdownConverter($environment);

$filesystem = new FileSystem();
Expand Down

0 comments on commit c56a53b

Please sign in to comment.