Giving panel users indentation control in a textarea

Hi again everyone,

Hopefully a straightforward question, but perhaps not. For a site I’m working on at the moment, I’d like to be able to give users the ability to control the indentation inside a textarea field by entering spaces preceding lines of text. Currently, doing so would change the text to a code block. Is there any way to change this behaviour so the kirbytext processor turns each space preceding text on a new line into   characters?

Thanks in advance for any help or ideas :slight_smile:

What is your use case for this?

It’s an odd use case, but my users will be posting poetry that requires some quirky line indents. None of them are technical enough to know about adding classes to <P> tags for example, which is a solution I’d considered too.

You could probably use a kirbytext pre filter: https://getkirby.com/docs/developer-guide/kirbytext/filters to prevent the default markdown behaviour and convert those spaces to &nbsp; characters, maybe this is possible with some regex voodoo.

1 Like

Thanks for the link, I’ll check it out shortly :slight_smile:

Those are two words that genuinely terrify me! Haha

Is there a pattern regarding the spaces? Are they only at the beginning of a line after a new line?

They will often be at the start of a new line inside a paragraph (after a <br>), or sometimes the beginning of a paragraph.

Maybe it would be easier to use a kirbytag?

(spaces: 4) some text
some more text
(spaces: 2) and so on

This seems like a great idea! Why hadn’t I thought of doing it that way?

Thanks for your help, I’ll see how I go!

That Kirbytag could then also use a class with a left padding/margin instead of inserting spaces directly. Spaces are not very semantic as they are only used for presentation purposes in your use-case, so using CSS would make more sense.

Also may also want to check out this article: http://www.vianegativa.us/2010/06/how-to-format-poetry-on-the-web-an-incomplete-guide/#css