Cannot create line breaks in Palantir Foundry's Markdown widget from a TS function-backed variable

I’m working with Palantir Foundry’s Workshop application and trying to create an unordered list in a Markdown widget. The data for this list comes from a TypeScript function-backed variable.

Despite my efforts, I’ve observed that all line breaks appear to be ignored or stripped away when the string is resolved or passed to the markdown widget.

My objective is to create a dynamically generated list without having to hard-code multiple variables and concatenate those in Workshop (line breaks between concatenated variables are preserved, leading to correct new lines). However, this is not a sustainable solution.

So far, I’ve tried the following to introduce line breaks:

  • \n
  • use of the br html tag
  • double white spaces

Unfortunately, none of these approaches work. There’s also limited documentation on the Markdown renderer or the widget in question.

Has anyone successfully created dynamic lists or managed to preserve line breaks in this context?

Question originally asked by Falkao on Stack Overflow: Cannot create line breaks in Palantir Foundry's Markdown widget from a TS function-backed variable - Stack Overflow

I would make an additional Typescript Function that returns the pre-formatted list as markdown, which you can store in a string variable. I tested the following function and it is rendered as an unordered list as I would expect.

@Function()
public markdown(): string {
    const a = ["* one", "* two", "* three"];
    return a.join("\n")
}

Answer originally provided by Ontologize on Stack Overflow: Cannot create line breaks in Palantir Foundry's Markdown widget from a TS function-backed variable - Stack Overflow