[GH-ISSUE #4557] [Issue]: Newlines between adjacent inline HTML elements are deleted #2486

Closed
opened 2026-10-21 05:48:43 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @Mininimin on GitHub (Aug 4, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/4557

Originally assigned to: @SpicyMarinara on GitHub.

Summary

Newlines between adjacent inline HTML elements are deleted.

Expected behavior

If the AI writes:

<span style="color: #F8BBD0">"Hi."</span>

<span style="color: #FFF59D">"Hello."</span>

I would expect that to display as:

"Hi."

"Hello."

Actual behavior

It is instead written as:

"Hi." "Hello."

Steps to reproduce

  1. In RP mode, write any two HTML elements separated by only newlines.

Environment

  • Marinara Engine version: v2.4.0
  • Install type: source
  • OS + version: Windows
  • Browser or app shell: Firefox Version 152.0.6

Logs, screenshots, or video

Additional context

The fix provided by Professor Mari:

The Bug

In packages/client/src/components/chat/ChatMessage.tsx, the newline-to-
regex had three alternatives:

SVG blocks → preserved as-is
Newlines between HTML tags (>\n<) → eaten entirely (replaced with ><)
All other newlines → <br>

Alternative 2 assumed any newline between angle brackets was pretty-printed HTML indentation (like </div>\n<p>), so it stripped it. But it also ate intentional line breaks between sibling elements like two <span> tags, gluing them together on one line.

The Fix

Line 1068 — changed alternative 2's replacement from ${pre}${post} (eat the newline) to ${pre}<br style="display:block;margin:0.2em 0">${post} (insert a styled <br> between the tags).

The styled <br> gives a small visual gap that mimics paragraph spacing. Block-level elements like <div> ignore stray <br> spacing naturally, so the old pretty-printing concern is handled for free.

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Mininimin on GitHub (Aug 4, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/4557 Originally assigned to: @SpicyMarinara on GitHub. ## Summary Newlines between adjacent inline HTML elements are deleted. ## Expected behavior If the AI writes: &lt;span style="color: #F8BBD0"&gt;"Hi."&lt;/span&gt; &lt;span style="color: #FFF59D"&gt;"Hello."&lt;/span&gt; I would expect that to display as: "Hi." "Hello." ## Actual behavior It is instead written as: "Hi." "Hello." ## Steps to reproduce 1. In RP mode, write any two HTML elements separated by only newlines. ## Environment - Marinara Engine version: v2.4.0 - Install type: source - OS + version: Windows - Browser or app shell: Firefox Version 152.0.6 ## Logs, screenshots, or video <!-- Paste relevant logs and add screenshots when possible --> ## Additional context The fix provided by Professor Mari: The Bug In packages/client/src/components/chat/ChatMessage.tsx, the newline-to-<br> regex had three alternatives: SVG blocks → preserved as-is Newlines between HTML tags (>\n<) → eaten entirely (replaced with ><) All other newlines → <br> Alternative 2 assumed any newline between angle brackets was pretty-printed HTML indentation (like &lt;/div&gt;\n&lt;p&gt;), so it stripped it. But it also ate intentional line breaks between sibling elements like two &lt;span&gt; tags, gluing them together on one line. The Fix Line 1068 — changed alternative 2's replacement from ${pre}${post} (eat the newline) to ${pre}&lt;br style="display:block;margin:0.2em 0"&gt;${post} (insert a styled &lt;br&gt; between the tags). The styled &lt;br&gt; gives a small visual gap that mimics paragraph spacing. Block-level elements like &lt;div&gt; ignore stray &lt;br&gt; spacing naturally, so the old pretty-printing concern is handled for free. ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:48:43 +07:00
Author
Owner

@SpicyMarinara commented on GitHub (Aug 4, 2026):

🔧 Ownership note: @SpicyMarinara is handling this in the current focused issue sweep. The fix will preserve intentional line breaks between adjacent inline HTML elements without changing block-element source formatting. A draft PR targeting staging will follow shortly.

<!-- gh-comment-id:5177986089 --> @SpicyMarinara commented on GitHub (Aug 4, 2026): 🔧 Ownership note: @SpicyMarinara is handling this in the current focused issue sweep. The fix will preserve intentional line breaks between adjacent inline HTML elements without changing block-element source formatting. A draft PR targeting `staging` will follow shortly.
Author
Owner

@SpicyMarinara commented on GitHub (Aug 4, 2026):

Shipped to staging in #4560 (merge commit 156f4189e6).

<!-- gh-comment-id:5178168151 --> @SpicyMarinara commented on GitHub (Aug 4, 2026): Shipped to staging in #4560 (merge commit 156f4189e647f484630736ebabc1e6ac8d0bfd9e).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#2486
No description provided.