wiki-grav/plugins/shortcode-custom/Prismjsshroot.php

18 lines
570 B
PHP
Raw Normal View History

2023-06-02 15:14:26 +02:00
<?php
namespace Grav\Plugin\Shortcodes;
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
2023-06-02 17:20:27 +02:00
class Prismjsshroot extends Shortcode
2023-06-02 15:14:26 +02:00
{
public function init()
{
2023-06-02 15:38:12 +02:00
$this->shortcode->getRawHandlers()->add('shroot', function(ShortcodeInterface $sc) {
2023-06-02 15:33:33 +02:00
$content = trim($sc->getContent(), "\n ");
2023-06-02 17:39:06 +02:00
$content = preg_replace('/^```.*$/m', '', $content);
return '<pre class="command-line language-sh" data-prompt="#" data-continuation-str="\" tabindex="0"><code class="language-sh">'.$content.'</code></pre>';
2023-06-02 15:14:26 +02:00
});
}
}
2023-06-02 17:20:27 +02:00
?>