1. Go to this page and download the library: Download torchlight/engine library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use League\CommonMark\Environment\Environment;
use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
use League\CommonMark\MarkdownConverter;
use Torchlight\Engine\CommonMark\Extension;
$environment = new Environment;
$environment
->addExtension(new CommonMarkCoreExtension)
->addExtension(new Extension('github-light'));
$converter = new MarkdownConverter($environment);
$output = $converter->convert(<<<'MD'
use Torchlight\Engine\CommonMark\Extension;
$extension = new Extension('github-light');
$extension->renderer()
->setDefaultGrammar('php');
namespace Torchlight\Engine\CommonMark;
use League\CommonMark\Extension\CommonMark\Node\Block\FencedCode;
interface BlockCache
{
public function has(FencedCode $node): bool;
public function get(FencedCode $node): string;
public function set(FencedCode $node, string $result): void;
}
use Torchlight\Engine\CommonMark\Extension;
$extension = new Extension('github-light');
$extension->renderer()
->setBlockCache(new MyCacheImplementation);
use Torchlight\Engine\CommonMark\Extension;
echo str()->markdown('...your markdown content...', extensions: [
new Extension('github-light'),
]);
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Statamic\Facades\Markdown;
use Torchlight\Engine\CommonMark\Extension;
class AppServiceProvider extends ServiceProvider
{
public function boot()
{
// Add the Torchlight Engine extension
Markdown::addExtension(function () {
return new Extension('synthwave-84');
});
}
}
use Torchlight\Engine\Engine;
$engine = new Engine;
$code = <<<'PHP'
echo "Hello, world!"; // [tl! ++]
PHP;
$code->toHtml(
$code, // The code to highlight
'php', // The language
'github-light' // The theme(s) to use
);
use Torchlight\Engine\CommonMark\Extension;
$extension = new Extension([
'light' => 'github-light',
'dark' => 'github-dark',
]);
// This is a long bit of text, hard to highlight the middle. [tl! highlight:6,3]
return <<<EOT
spring sunshine
the smell of waters
from the stars
deep winter
the smell of a crow
from the stars
beach to school
the smell of water
in the sky
EOT;
// This is a long bit of text, hard to highlight the middle.
return <<<EOT
spring sunshine
the smell of waters
from the stars
deep winter
the smell of a crow
from the stars
beach to school
the smell of water
in the sky
EOT; // [tl! highlight:-7,3]
return [
'extensions' => [ // Start here [tl! highlight:start]
// Add attributes straight from markdown.
AttributesExtension::class,
// Add Torchlight syntax highlighting.
TorchlightExtension::class,
] // End here [tl! highlight:end]
]
// Reach down 4 lines, add the ID to one line [tl! #popover-trigger:4,1]
return <<<EOT
spring sunshine
the smell of waters
from the stars
deep winter
the smell of a crow
from the stars
beach to school
the smell of water
in the sky
EOT;
use Torchlight\Engine\Options;
Options::setDefaultOptionsBuilder(function () {
return new Options(
// Specify your options here.
);
});
use Torchlight\Engine\Options;
Options::setDefaultOptionsBuilder(function () {
return Options::fromArray([]);
});
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Torchlight\Engine\Options;
class AppServiceProvider extends ServiceProvider
{
public function boot()
{
Options::setDefaultOptionsBuilder(fn () => Options::fromArray(config('torchlight.options')));
}
}
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Torchlight\Engine\CommonMark\Extension;
class AppServiceProvider extends ServiceProvider
{
public function boot()
{
Extension::setThemeResolver(function () {
return config('torchlight.theme');
});
}
}
// torchlight! {"copyable": true}
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Statamic\Facades\Markdown;
use Torchlight\Engine\CommonMark\Extension;
class AppServiceProvider extends ServiceProvider
{
public function boot()
{
// Add the Torchlight Engine extension
Markdown::addExtension(function () {
return new Extension('synthwave-84');
});
}
}