Text like “\newline” vs. structure field in panel


I came to a problem when building my site. I git some pages where I like to show LaTeX code. I use a structured field but entries like \newline (which is a common LaTeX macro don’t get saved properly, i.e. the \n is cut of and interpreted as new line control sequence.

How to reproduce:

  1. download starter kit

  2. add the following field to blueprints/default.php

         label: Test-Field
         type: structure
         entry: {{text}}
             label: Text
             type: text
  3. go to the panel

  4. edit a default page

  5. add a new entry to the structure field

  6. type in \newline and click “Add”

  7. save the page

Result: The entry is saved as ewline

I also created an issue on GitHub but since this is quite urgent I hope it’s ok to ask here too …

I just tested this in a fresh langkit install and it saves '\newline' to text file (in single quotes)

Edit: I added some more entries, and I get three different results.

But then again, shouldn’t backslashes be escaped anyway? Having said that, escaping the backslash results in double backslashes in the text file but display in the panel is nevertheless weird …

Different results are even more strange … I guess it has something to do with \n being a control sequence. But I don’t know why it is not escaped. When I add braces to the entry – \newcommand\x{X} for instance – the entry is saved with single quotes and everything works …

Hope that @bastianallgeier or someone else has a solution for that :slight_smile: