You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Add Extensions to features list in README
- Add Extensions link to documentation list
- Update main example to use ExternalLinksExtension and DefaultAttributesExtension
- Add Extensions section to docs/README.md
- Update Custom Syntax Patterns to show hashtags (mentions covered by extension)
- Simplify Event System example
-**File support**: Parse and convert files directly
38
39
39
40
## Example
40
41
41
42
```php
42
43
use Djot\DjotConverter;
43
-
use Djot\Event\RenderEvent;
44
+
use Djot\Extension\ExternalLinksExtension;
45
+
use Djot\Extension\DefaultAttributesExtension;
44
46
45
47
$converter = new DjotConverter();
46
48
47
-
// Customize link rendering
48
-
$converter->on('render.link', function (RenderEvent $event): void {
49
-
$link = $event->getNode();
50
-
if (str_starts_with($link->getDestination(), 'http')) {
51
-
$link->setAttribute('target', '_blank');
52
-
}
53
-
});
49
+
// Add extensions for common features
50
+
$converter
51
+
->addExtension(new ExternalLinksExtension())
52
+
->addExtension(new DefaultAttributesExtension([
53
+
'table' => ['class' => 'table'],
54
+
]));
54
55
55
56
$djot = <<<'DJOT'
56
57
# Welcome
@@ -75,8 +76,8 @@ Output:
75
76
76
77
```html
77
78
<h1>Welcome</h1>
78
-
<p>This is <em>emphasized</em> and <strong>strong</strong> text with a <ahref="https://example.com"target="_blank">link</a>.</p>
79
-
<table>
79
+
<p>This is <em>emphasized</em> and <strong>strong</strong> text with a <ahref="https://example.com"target="_blank"rel="noopener noreferrer">link</a>.</p>
0 commit comments