/**
* Process shortcodes after Grav's processing, but before caching
*
* @param Event $e
*/
public function onPageContentProcessed(Event $e)
{
$page = $e['page'];
$config = $this->mergeConfig($page);
$this->active = $config->get('active', true);
// if the plugin is not active (either global or on page) exit
if (!$this->active) {
return;
}
switch ($config->get('parser')) {
case 'regular':
$parser = 'Thunder\\Shortcode\\Parser\\RegularParser';
break;
case 'wordpress':
$parser = 'Thunder\\Shortcode\\Parser\\WordpressParser';
break;
default:
$parser = 'Thunder\\Shortcode\\Parser\\RegexParser';
break;
}
if ($page && $config->get('enabled')) {
$content = $e['page']->getRawContent();
$processor = new Processor(new $parser(new CommonSyntax()), $this->handlers);
$processed_content = $processor->process($content);
$e['page']->setRawContent($processed_content);
}
}