From 34af9d76b48136948014d449ec66670a40a6722d Mon Sep 17 00:00:00 2001 From: Roberto Butti Date: Sun, 27 Nov 2022 19:31:49 +0100 Subject: [PATCH] upgrade to new render for commonmark --- composer.json | 4 ++-- composer.lock | 2 +- src/Commands/BuildCommand.php | 12 +++++++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 3e639e0..5cb4bba 100644 --- a/composer.json +++ b/composer.json @@ -21,9 +21,9 @@ "require": { "illuminate/filesystem": "^7.0|^8.0", "illuminate/support": "^7.0|^8.0|^9.0", - "symfony/console": "^4.2|^5.0|^6.0", "mpdf/mpdf": "^8.1", - "spatie/commonmark-highlighter": "^2.1|^3.0" + "spatie/commonmark-highlighter": "^2.1|^3.0", + "symfony/console": "^4.2|^5.0|^6.0" }, "require-dev": { "laravel/pint": "^1.2", diff --git a/composer.lock b/composer.lock index 1473564..e394563 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "82f563307e9fa59fa8360846882687e6", + "content-hash": "8fd9ff4af82026c376f46e05a4e70d2b", "packages": [ { "name": "dflydev/dot-access-data", diff --git a/src/Commands/BuildCommand.php b/src/Commands/BuildCommand.php index 804930d..ff1d06b 100644 --- a/src/Commands/BuildCommand.php +++ b/src/Commands/BuildCommand.php @@ -7,7 +7,8 @@ use Mpdf\Mpdf; use SplFileInfo; use Mpdf\Config\FontVariables; use Mpdf\Config\ConfigVariables; -use League\CommonMark\Environment; +use League\CommonMark\Environment\Environment; + use Illuminate\Filesystem\Filesystem; use Symfony\Component\Console\Command\Command; use League\CommonMark\Block\Element\FencedCode; @@ -64,8 +65,13 @@ class BuildCommand extends Command $this->themeName = $input->getArgument('theme'); $currentPath = getcwd(); - $config = require $currentPath.'/ibis.php'; + $configIbisFile = $currentPath . '/ibis.php'; + if (!$this->disk->isFile($configIbisFile)) { + $this->output->writeln('Error, check if ' . $configIbisFile . ' exists.'); + exit - 1; + } + $config = require $configIbisFile; $this->ensureExportDirectoryExists( $currentPath = getcwd() ); @@ -113,7 +119,7 @@ class BuildCommand extends Command $environment = Environment::createCommonMarkEnvironment(); $environment->addExtension(new TableExtension()); - $environment->addBlockRenderer(FencedCode::class, new FencedCodeRenderer([ + $environment->addRenderer(FencedCode::class, new FencedCodeRenderer([ 'html', 'php', 'js', 'bash', 'json' ]));