Hi,
I have a problem with a own Kirbytag for centering text.
The tags will be replaced but paragraphs will be mixed between.
Here is the code:
<?php
Kirby::plugin('kdjfs/centertxt', [
'options' => [
'class' => 'center-text'
],
'hooks' => [
'kirbytags:before' => function ($text, array $data = []) {
$text = preg_replace_callback('!\(center(…|\.{3})\)(.*?)\((…|\.{3})center\)!is', function ($matches) use ($text) {
$html = kirbytext($matches[2]);
return '<span class="' . option('kdjfs.centertxt.class') . '">' . $html . '</span>';
}, $text);
return $text;
}
]
]);
and the markdown will look like (center…)Lorem Ipsum(…)
.
The Output should <p><span class="center-text">Lorem Ipsum</span></p>
.
But the Output is
<p>
<span class="center-text"></span>
</p>
<p>
Lorem Ipsum
</p>
I thing have an problem with parcing flow problems. Because if I dump inside the plugin the output will be okay.
Disable the paragraphs is not so smart to solve the problem.
Hopefull someone had an idea.