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

Discuss statistics related things
Post Reply
User avatar
NourEdinDarwish
Posts: 13
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: 2965
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
User avatar
NourEdinDarwish
Posts: 13
Joined: Fri Jan 23, 2026 9:14 pm

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

Post by NourEdinDarwish »

Hi Jonathon,

Just checking in to see if there are any updates on this?

Supporting multi-line notices would be incredibly helpful. My main use case is needing to cleanly display multiple warnings generated from a single operation within one cohesive message, rather than cluttering the UI with several separate Notice items.

Would it be helpful if I opened an issue on GitHub to track this?

Thanks again for looking into this!
User avatar
jonathon
Posts: 2965
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 »

yes, as of 2.7.22 notices now support paragraph breaks. you need to use two newline characters to get a paragraph break.

cheers

jonathon
Post Reply