Notice ignores newlines (\n) due to frontend CSS and HTML sanitization - any workarounds to allow multi-line notices?

Discuss statistics related things
Post Reply
NourEdinDarwish
Posts: 9
Joined: Fri Jan 23, 2026 9:14 pm

Notice ignores newlines (\n) due to frontend CSS and HTML sanitization - any workarounds to allow multi-line notices?

Post by NourEdinDarwish »

Hi everyone,

I'm currently developing a Jamovi module using jmvtools and jmvcore, and I've run into an issue when trying to display multi-line text using a Notice element.

When I pass a string containing newline characters (\n) to setContent() in my R code, the newlines are ignored in the Jamovi UI and everything is rendered on a single line.

I took a peek at the Jamovi frontend source code to trace what was happening, and it seems there are two overlapping reasons preventing multi-line notices:
  1. CSS Styling: The newline characters are successfully passed to the frontend via protobuf and injected via inner HTML, but the CSS selector for the notice content does not use "white-space: pre-wrap". Because of standard HTML rendering, the browser collapses the literal \n characters into single spaces.
  2. Strict HTML Sanitization: If I try to force a line break by passing an HTML tag from R, it gets intercepted by the localization and sanitization function. Since this function explicitly restricts allowed HTML tags to a hardcoded whitelist (i, em, b, strong, sub, sup), the
    tag is escaped into <br> and printed as literal text.
Currently, my only workaround is to insert multiple separate Notice items sequentially into the results, but this is visually clunky.

Is my understanding correct? and is there an existing or planned way to emit multi-line notices in Jamovi?

Thanks for your time and for the amazing software!
vjalby
Posts: 26
Joined: Tue Oct 24, 2023 4:52 pm
Contact:

Re: Notice ignores newlines (\n) due to frontend CSS and HTML sanitization - any workarounds to allow multi-line notices

Post by vjalby »

You may also use a "type: Html" result element. Content may include css to format the notice the way you want.

Code: Select all

    
    - name:  htmlNotice
      title: "My Notice"
      type:  Html
      visible: true
      content: "line 1<br />line2"
User avatar
jonathon
Posts: 2949
Joined: Fri Jan 27, 2017 10:04 am

Re: Notice ignores newlines (\n) due to frontend CSS and HTML sanitization - any workarounds to allow multi-line notices

Post by jonathon »

let us take a look at this ... we really want to discourage people from using the Html element as much as possible.

jonathon
Post Reply