How to modify a Kirbytext tag in a plugin

Hi,

I’m using the lang attribute for <a> links. Surprisingly, Kirby uses such an attribute, but for other purposes (multi language installations).

So I modified it in kirby/extensions/tags.php directly.

Bastian told me in the meantime it should be working if I just put the code into site/plugins/link/link.php

But I think I cannot use the tag code itself modified, because Kirby just echoes it on top of the page.

Can you steer me in the right direction? I’m unsure, if I can really access kirbytext::$tags here.

// link tag
kirbytext::$tags['link'] = array(
  'attr' => array(
    'text',
    'class',
    'role',
    'title',
    'rel',
    'lang',
    'target',
    'popup',
	'linklang'
  ),
  'html' => function($tag) {

    $link = url($tag->attr('link'), $tag->attr('lang'));
    $text = $tag->attr('text');

    if(empty($text)) {
      $text = $link;
    } 

    if(str::isURL($text)) {
      $text = url::short($text);
    }

    return html::a($link, $text, array(
      'rel'    => $tag->attr('rel'),
      'class'  => $tag->attr('class'),
      'role'   => $tag->attr('role'),
      'title'  => $tag->attr('title'),
      'target' => $tag->target(),
	  'lang' => $tag->attr('linklang'),
    ));

  }
);

There should be a php tag at the beginning of your file:

<?php

//rest of code here