Adding markdown link attribute problem with styling in textfield

I have added a attribute (data-link) to the kirby link-tag in the file kirby > extensions > tags.php.

   // link tag
  kirbytext::$tags['link'] = array(
  'attr' => array(
  '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'),
      'data-link' => $tag->attr('data-link'),
      'target'    => $tag->target()

But if I write this attribute in a markdown textfield it will not getting grey like the other attributes.
What have I to do that it will recognize as a attribute in the markdownfield?



You will have to modify the pattern that is used to identify an attribute in the markdown editor.

Probably the pattern in the following lines:

Currently, it only gets patterns with alphanumeric characters.

Hello Sonja,
actually I havn’t thought about that it is a result from visualmarkdown.
Thanks that you have realized that I use that :).

So I have added the dash to the regex. Here it works.
but not in the visual markdown. What do I’m wrong?

Looks like you have to add the dash to the pattern on line 53 as well.

1 Like

You are right. I thought this is only for the value.

Thank you very much!