Deactivate specific markdown options

I have this line in a textarea field in the panel:

25. - 30. September 2018
Raum 2.70

which renders as:

<ol start="25">
<ol start="30">
<li>September 2018<br>
Raum 2.70</li>

which is of course understandable behavior, but definitely not wanted here.

I know I can use a backslash to escape dots and dashes, but a lot of content is imported from text files so I’d like to avoid manually going through all of it.

But I basically only need kirbytags and line breaks on this specific field type, so is there a way to disable specific formatting options in the markdown parser? Or another approach I could try?

I don’t think you can simply deactivate it. I basically see two/three options:

  1. A custom kirbytext() method that just does the kirbytag parsing without the markdown parsing.
  2. A custom markdown component, that doesn’t do any Markdown parsing:
  3. Don’t use textarea with Markdown/Kirbytext, but the new blocks field.

(2) Is it possible to use a custom markdown component on specific fields only or will this new plugin automatically be applied globally?

Good question, don’t know.

No, the custom component would be globally used.

I think a custom field method would probably be the best option then.


Kirby::plugin('bruno/field-methods', [
    'fieldMethods' => [
        'ktNoMarkdown' => function ($field) {
            return nl2br(kirbytags($field->value));

I think this does it for now. Thanks @distantnative & @texnixe!

1 Like