Djot to HTML
[Markup Plugin] | [Djot-PHP] | [Djot Spec]Djot is a modern markup language created by John MacFarlane (author of CommonMark/Pandoc). It's designed to be unambiguous and easy to parse while remaining human-readable.
Using the DjotHelper
Add the helper in your controller:
// In your controller
public function myAction(): void
{
$this->viewBuilder()->addHelper('Markup.Djot');
}
Then in your template:
echo $this->Djot->convert($djotText);
Examples
Basic Formatting
Some strong text and also some emphasized.
You can also use highlighted text and deleted or inserted text.
Links and Images
Visit Djot website for more info.
Lists
Unordered list:
- First item
- Second item - Nested item
- Third item
Ordered list:
- Step one
- Step two
- Step three
Task list:
- Completed task
- Pending task
Code Blocks
Inline code works like this.
// Code blocks with language hints
$converter = new DjotConverter();
echo $converter->convert($text);
Tables
| Name | Type | Description |
|---|---|---|
| Djot | Markup | Modern markup |
| PHP | Lang | Server-side |
| CakePHP | FW | Rapid development |
Blockquotes and Divs
This is a blockquote. It can span multiple lines.
This is a custom div with the “warning” class.
Configuration Options
The helper accepts several options:
// With safe mode (default: true) - filters dangerous content
echo $this->Djot->convert($text, ['safeMode' => true]);
// With a profile to restrict features
echo $this->Djot->convert($text, ['profile' => 'comment']);
// Strict mode - throws on parse errors
echo $this->Djot->convert($text, ['strict' => true]);
Using DjotView
For content-heavy pages, you can use DjotView to write templates directly in Djot format.
See DjotView demo for an example.
// In your controller
public function documentation(): void
{
$this->viewBuilder()->setClassName('Markup.Djot');
$this->set('version', '1.0');
}
// Create templates/MyController/documentation.djot
// Use {{version}} for variable substitution

