Markdown and links to assets within a kirbytag

I have a simple kirbytag that adds some special classes and javascript effects to some text:

<?php
kirbytext::$tags['quote'] = array(
'html' => function($tag) {
return '<div class="quote wow fadeInUp" data-wow-duration="2s" data-wow-delay=".25s"><h2>'.$tag->attr('quote').'</h2></div>';
  }
);

Markdown doesn’t work here, for example, while trying to add a link or italic text. I’ve tried chaining both of the markdown or kirbytext function and neither work. Is there a way to achieve this?

Also, I’ve been trying to reference the assets folder, to get an svg like this:

<a href="http://www.facebook.com/sharer.php?u=<?php echo rawurlencode ($page->url()); ?>" target="blank" title="Compartir en Facebook"><img src="<?php echo $site->url() ?>/assets/images/facebook-with-circle.svg" alt="" class="share-icon"></a>

My problems here:

  1. The image can’t be found
    and
    2)The share link doesn’t work as expected. The link is broken since the php functions are not being parsed.

Any help would be greatly appreciated! :slight_smile:

You will need to manually call kirbytext() on the content to make that happen:

<?php
kirbytext::$tags['quote'] = array(
  'html' => function($tag) {
    return '<div class="quote wow fadeInUp" data-wow-duration="2s" data-wow-delay=".25s"><h2>' . kirbytext($tag->attr('quote')) . '</h2></div>';
  }
);

Try using echo url('assets/images/facebook-with-circle.svg');, which automatically builds the URL for you.

Why are they not getting parsed? Where did you put this line of code?

I was really pleased when I found this thread. But after calling kirbytext() manually, it doesn’t work. I just outputs an empty tag <p class="myclass"></p>. The Tag itself works, but with kirbytext() it outputs nothing, even no php error message.

Do I miss something? Thanks for any kind of help.

Could you post your code, please?

Of course:

<?php
kirbytext::$tags['lead'] = array(
  'html' => function($tag) {
    return '<p class="lead">' . $tag->attr('lead') . '</p>';
  }
);

Now I got my error… it’s because of the p-tag. If I use a div, everything is fine. It’s obvious, because kirbytext() creates its own paragraphs.
But thanks anyway.