Problem with kirbytext() is duplicating tags

I’m having issues with rendering markdown onto the frontend - I can’t understand what is happening but the code is duplicating tags and classes that destroy my grid. This is illustrated in the image below where the project on top has no markdown whereas the bottom one has link created in kirby panel - (link: text: here)

When inspecting the code it shows that the tag with ‘news_wrapper’ class has been duplicated

Screen Shot 2020-08-21 at 12.31.35 pm

  <a href="<?= $article->url() ?>" class="news__wrapper">
            <div class="news__inner gc">
                <div class="d-1-5 t-1-7 m-1-13">
                    <p style="--textcolor:<?= $page->textcolourpicker()->value(); ?>"><?= $article->title() ?></p>
                    <div class="news__image">
                        <?= $article->image()->crop(500, 350) ?>

                <div class="d-5-7 t-1-7 m-1-13">
                    <p style="--textcolor:<?= $page->textcolourpicker()->value(); ?>"><?= $article->date() ?></p>
                <div class="d-7-11 t-7-13 t-r-1 m-1-13" style="--textcolor:<?= $page->textcolourpicker()->value(); ?>">
                    <p style="--textcolor:<?= $page->textcolourpicker()->value(); ?>"><?= kirbytext($article->text()->short(550)) ?></p>

                <div class="read_more d-11-13 t-7-13 m-1-13">
                    <span><p style="--textcolor:<?= $page->textcolourpicker()->value(); ?>">Read More</p>
            </a><!-- End of News Wrapper -->

Hm, have to check, but using a link inside a link doesn’t make sense, anyway. Is this Kirby 2 or 3?

Unrelated side note: It is not valid HTML to use a p tag inside a span tag.

I know what you mean - this is like the preview text and links to a news article page that shows the whole text body and the client wants to include links - This is kirby 3

If this isn’t possible to resolve I will just have to create a new textarea field for the preview text

Maybe it would make more sense to remove tags for the purpose of the preview, using an excerpt that removes all HTML. That way, you don’t end up with invalid code.

This line is invalid HTML as well, because the kirbytext() method creates a p tag, so you end up with nested p tags.