The method kirbytextinline() / kti() doesn’t render “blockquotes”. Is this normal?
Yes, since a blockquote is not an inline element.
Is there a way to render Blockquote?
> This is my Quote
The question has already been answered? What exactly are you trying to do?
I have a writer field. I use $field->kirbytext()
in the output. I like the example above converted to
<blockquote>
This is my Quote
</blockquote>
Well, but a writer field is not a markdown field, and a quote is not a supported node in a writer field. So this won’t work.
Your example is stored as <p>> This is my Quote</p>
in the content file. So even if the kirbytext()
method translated this into a quote, the resulting HTML wouldn’t be valid (quote inside p tag).
This seems to work:
'hooks' => [
'kirbytext:after' => function ($text) {
return implode('', array_map(function ($l) {
if (substr($l, 0, 5) == "> ") {
//Remove Markdown
$l = str_replace('> ', '', $l);
return '<blockquote>'.str_replace('</p>', '</blockquote>', $l);
}
return '<p>' . $l;
}, explode('<p>', $text));
}
]