Line breaks in a WYSIWYG

Collections

Новичок
Регистрация
11.10.2025
Сообщения
1
Благодарностей
0
Баллы
1
I am new to ZennoPoster, so I spent quite a while thinking I was just doing something wrong. However, I see this old post about the same issue from 2011. Though, I'd be surprised if this still is an issue almost 15 years later.

Basically, formatted text with line breaks like this:

This is my post
This is the next line.

This is two lines later.

Turns into this:
This is my postThis is the next line.This is two lines later.

Nothing I try seems to help. Using the built in variable does not do it either: {-String.Enter-}

Thanks.
 

ameliarosewood

Новичок
Регистрация
25.10.2025
Сообщения
1
Благодарностей
0
Баллы
1
Hi there,

You’re right — that line break issue has been around for a long time, but it’s not really a ZennoPoster bug. The problem is how WYSIWYG iframes interpret plain-text input. When you drop text into a rich editor, it expects HTML formatting (<br> or <p> tags), not plain line breaks like \r\n or \n, so everything gets merged into one line.

Here’s how you can fix it:

  1. Convert newlines to <br> before inserting.
    In ZennoPoster, use a replace action or macro like:

    {-Variable.Text.Replace("\r\n","<br>")-}

    This turns each line break into an HTML line break that the WYSIWYG editor can render properly.
  2. Insert the text via JavaScript if needed.

    Sometimes using “Set Value” ignores formatting. Instead, you can inject the formatted text with:

    document.querySelector('iframe').contentDocument.body.innerHTML = project.Variables["yourVariable"].Value.replace(/\r?\n/g, "<br>");
  3. Double-check encoding.
    If your file is saved as Unicode, try reading it in ZennoPoster with UTF-8 encoding — that ensures line breaks aren’t lost when loading the file.

After this, your text should appear exactly as formatted in your source file — with all line breaks preserved.

Hope this clears it up!
 
Последнее редактирование модератором:

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)