Torchlight.dev — The VS Code Compatible Syntax Highlighting API.

Ibis Client

Latest Stable Version Total Downloads License GitHub

Ibis is a PHP tool helps you write eBooks in markdown.

Installation

To install, require the package from composer:

1composer require torchlight/torchlight-ibis

If you haven't already, Composer will ask you to create a composer.json file in the root of your book directory.

In your ibis.php file, add the following to your configuration:

1return [
2 /**
3 * The book title.
4 */
5 'title' => 'Laravel Queues in Action',
6 
7 // .....
8 
+ 'configure_commonmark' => function ($environment) {
+ \Torchlight\Ibis\TorchlightExtension::make()->register($environment);
+ },
12];

At the top of your ibis.php file, you'll also need to add the composer autoloader if it's not already there:

1<?php
2 
+require_once __DIR__ . '/vendor/autoload.php';
4 
5return [
6 /**
7 * The book title.
8 */
9 'title' => 'Laravel Queues in Action',
10 
11 // .....
12 
13 'configure_commonmark' => function ($environment) {
14 \Torchlight\Ibis\TorchlightExtension::make()->register($environment);
15 },
16];

To publish the Torchlight configuration file, you may run ./vendor/bin/torchlight. It will place a torchlight.php file next to your ibis.php file.

Styles

You'll need to add a few styles to your stylesheet. These are slightly different from the default styles that Torchlight uses, because Ibis uses mPDF to convert the HTML to a PDF, and it has a few specific requirements.

Here is a good starting set of styles, but feel free to tweak them to match your needs.

1/*
2 Margin and rounding are personal preferences,
3 overflow-x-auto is recommended.
4*/
5pre {
6 page-break-inside: avoid;
7 border: solid 1px #eee;
8 margin-bottom: 30px;
9 border-radius: 5px;
10 overflow-x: auto;
11}
12 
13/*
14 Add some vertical padding and expand the width
15 to fill its container. The horizontal padding
16 comes at the line level so that background
17 colors extend edge to edge.
18*/
19pre div.torchlight {
20 padding-top: 16px;
21 padding-bottom: 16px;
22}
23 
24/*
25 Horizontal line padding to match the vertical
26 padding from the code block above. Vertical
27 for line height.
28*/
29pre div.torchlight .line {
30 padding: 2px 16px;
31}
A Hammerstone, LLC Product.
Built with Love & Care by Aaron in Dallas, Texas.