| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A PHP parser for Djot, a modern light markup language created by John MacFarlane (author of CommonMark/Pandoc).
composer require php-collective/djotuse Djot\DjotConverter;
$converter = new DjotConverter();
$html = $converter->convert('Hello *world*!');
// Output: <p>Hello <strong>world</strong>!</p>use Djot\DjotConverter;
use Djot\Extension\ExternalLinksExtension;
use Djot\Extension\DefaultAttributesExtension;
$converter = new DjotConverter();
// Add extensions for common features
$converter
->addExtension(new ExternalLinksExtension())
->addExtension(new DefaultAttributesExtension([
'table' => ['class' => 'table'],
]));
$djot = <<<'DJOT'
# Welcome
This is _emphasized_ and *strong* text with a [link](https://example.com).
| Name | Role |
|-------|------------|
| Alice | Developer |
| Bob | Designer |
> "Djot is a light markup syntax."
```php
echo "Hello World";
DJOT;
echo $converter->convert($djot);Output:
<h1>Welcome</h1>
<p>This is <em>emphasized</em> and <strong>strong</strong> text with a <a href="https://example.com" target="_blank" rel="noopener noreferrer">link</a>.</p>
<table class="table">
<thead>
<tr><th>Name</th><th>Role</th></tr>
</thead>
<tbody>
<tr><td>Alice</td><td>Developer</td></tr>
<tr><td>Bob</td><td>Designer</td></tr>
</tbody>
</table>
<blockquote>
<p>"Djot is a light markup syntax."</p>
</blockquote>
<pre><code class="language-php">echo "Hello World";
</code></pre>Full documentation is available at https://php-collective.github.io/djot-php/
When processing untrusted user input, enable safe mode for XSS protection:
$converter = new DjotConverter(safeMode: true);
$html = $converter->convert($untrustedInput);Safe mode automatically blocks dangerous URL schemes (javascript:, etc.), strips event handler attributes (onclick, etc.), and escapes raw HTML.
See Safe Mode for details and advanced configuration.
| Back | FazBrowse Home | New Git URL |