Prevent Panel from stripping spaces

Hi,

I just made an update to 2.2.3 now I got a rather big problem โ€ฆ

I got a builder field to add different block in my block. Some of them contain a code field of type textarea. This text contains preformatted text using spaces to indent.

Blocks: 

- 
  code: |
    โˆ†   code
            more code
  _fieldset: code

but after saving in the panel the spaces at the beginning of the lines a stripped and I get

Blocks: 

- 
  code: |
    โˆ†   code
    more code
  _fieldset: code

Which is really awkward โ€ฆ In previous versions the striping was only done of the first line (which I prevented by adding a โˆ† in the first position and removing it in my output at the template. No I can add a โˆ† to every line, but that is far away from being an ideal solution.

I hope I could explain my problem :wink: and even more, the someone can solve it!

Best
Tobi

You mean a field of type structure, right?
Which Kirby version did you use before the upgrade? I can check what changed since then that may cause the issue.

No, this must be a textarea field within a kirby-builder field (thanks to autocorrection, you get a texture field)

Hi,

Yes @texnixe is wright, but as far as I can tell it has nothing to do with the builder plugin. You can reproduce this behavior with a simple structure too.

I made an update from

Toolkit version: 2.1.1
Kirby version: 2.1.2
Panel version: 2.1.1

to 2.2.3 for all three.

To reproduce the problem please do the following with a 2.1.2 and a 2.2.3 starter kit:

  • change the default.php template to
<?php if(!defined('KIRBY')) exit ?>

title: Page
pages: true
files: true
fields:
  title:
    label: Title
    type:  text
  text:
    label: Test 1
    type:  textarea
  test:
    label: Test 2
    type:  structure
    fields:
      text:
        label: Text
        type: textarea
  • open the about page in panel
  • remove the current text in โ€œTest 1โ€
  • type in (middle dot ยท = space)
ยทยทยทยทfour
ยทยทยทยทยทยทยทยทeight
  • add a structure entry in โ€œTest 2โ€ with the same text
  • hit โ€œsaveโ€

Results in 2.1.1

Title: About

----

Text: 

four
ยทยทยทยทยทยทยทยทeight

----

Test: 

- 
  text: |
    ยทยทยทยทfour
    ยทยทยทยทยทยทยทยทeight

but in the panel the structure content is viewed as it was saved as

  text: |
    four
    ยทยทยทยทeight

i.e. when viewing there are four spaces stripped form every line.

Results in 2.2.3

Title: About

----

Text: 

four
ยทยทยทยทยทยทยทยทeight

----

Test: 

- 
  text: |
    four
    eight

In the structure field all leading spaces get stripped.


In an optimal solution no spaces would be stripped. Maybe this could be achieved with a custom filed code.


An a question belonging to this is how does Kirby decide when to use text: '', text: | oder text: >?

Seems that single quotes are used if the text contains leading or trailing spaces.

The greater sign is used for longer text without line breaks.

The pipe is used when the text contains line breaks.

Hm โ€ฆ okay, but can I define manually which one to use and more important prevent the space stripping?

Any news?

While searching the issues on GitHub, I found one I sent myself some time ago: #322 โ€“ Spaces at the beginning and the end of fields get removed.

Since this seems to be a bug (testes again with a fresh starter kit) I opened issue #714 on GitHub. Hope that someone will fix it :slightly_smiling: