Created
April 29, 2022 15:23
-
-
Save daronspence/09c7a5712fd59ce7cedd7543a4aafa6b to your computer and use it in GitHub Desktop.
Stringable Markdown with Iframe Support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// within AppServiceProvider::boot() or a similar entry point | |
Stringable::macro('markdownWithIframes', function ($config = []) { | |
$config['disallowed_raw_html'] = [ | |
'disallowed_tags' => ['title', 'textarea', 'style', 'xmp', 'noembed', 'noframes', 'script', 'plaintext'], | |
]; | |
$environment = new Environment($config); | |
$environment->addExtension(new CommonMarkCoreExtension()); | |
$environment->addExtension(new AutolinkExtension()); | |
$environment->addExtension(new DisallowedRawHtmlExtension()); | |
$environment->addExtension(new StrikethroughExtension()); | |
$environment->addExtension(new TableExtension()); | |
$environment->addExtension(new TaskListExtension()); | |
$converter = new MarkdownConverter($environment); | |
return new static($converter->convert($this->value)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment