Use Kirbytext syntax inside code blocks


When I try to show markdown syntaxe using Code Blocks of a link for exemple:

It returns in the page :
<a href="">Wikipedia</a>

instead of:
(link: text: Wikipedia)

Same for Email, Youtube etc

I watched on Ghitub and saw a \ before all link.

I certainly missed something, what is the good way to show markdown in code tag ?

Thank you,

You are right, the Kirby website uses a backslash after the opening of the bracket and does some string replacement in the template.

An alternative would be to use some other characters like double curly braces that you don’t need in your text files and use a kirbytext pre filter before kirbytext is processed.

I think this is a bug in Kirby. Other markdown syntax is not interpreted in code blocks and inline blocks, but Kirbytext is. Shouldn’t that be ignored as well?

But if I use :

(link: alone without the text add, it shows the correct markdown syntaxe in code blocks.

In my install it doesn’t work without the text attribute, either.


I need to create a page (same as Kirbytext) but in french for a client. He needs to have something easy to read and anderstand.

I also have some tags that do not show correctly in code blocks for exemple:


 kirbytext::$tags['separateur'] = array(
 'html' => function($tag) {
 return '<hr class="' . $tag->attr('separateur') . '">';

I need to give my client some easy “codes” to copy and past to style his content throught an exemple page.

I would be very grateful if you could help me to use alternative Texnixe solution with pre filter or Kirby text page solution, because I do not really anderstand how to.

Thank you.

Let`s suppose you use double curly braces in your code block like this:

{{link: text: Google}}

Then you could use the following code (actually a post filter, not a pre filter)

kirbytext::$post[] = function($kirbytext, $value) {
   return str_replace('{{','(',str_replace('}}',')',$value));

Put that file into /site/plugins. You can, of course, use any other characters that you see fit.

1 Like

I’m sorry, but if I use

{{link: text: Google}}

and your exemple code in /site/plugins/test.php it just show a link (as if there were no code blocks arround) on the page.

Hm …

This is how it looks in my test panel (Kirby 2.2.3):

And this is the result on the page:

And the resulting source code:

  <code class="language-php">(link:</code>


I think I found a possible beug reason.

I use the Columns Plugin to display my exemples. It seems that it does not show correctly inside the columns.

Your exemple works for me also fine, if I do not display my exemple in column plugin.

Do you think it can have any conflict from here ?

Yes, indeed, I can confirm that the column plugin seems to interfere here.

I had the same issue some weeks ago. I replace the brackets with HTML-Entities.

for the ( use &#40; and for the ) use &#41;

This works for me und you don’t need to add code or something.

1 Like