Rendering line break in Knime

I am trying to use Text Output Widget (legacy) to render a chunk of text with line breaks. No matter what line break characters I use (\r, \r\n, \n), it just doesn’t render properly. I have enabled/disabled legacy mode and it’s still the same.

Any idea?

"Certainly! Here are some general comments and healthcare advice for a person with a BMI of 24.22:

Your BMI of 24.22 falls within the ""Normal weight"" category, which ranges from 18.5 to 24.9.\n
Maintaining a balanced diet is crucial. Aim to include a variety of fruits, vegetables, whole grains, lean proteins, and healthy fats in your meals.\n
Regular physical activity is important. Aim for at least 150 minutes of moderate-intensity aerobic activity or 75 minutes of vigorous-intensity activity each week, along with muscle-strengthening activities on 2 or more days a week.\n
Stay hydrated by drinking plenty of water throughout the day. Limit sugary drinks and excessive caffeine.\n
Monitor portion sizes to avoid overeating, even when consuming healthy foods.\n
Get regular health check-ups to monitor blood pressure, cholesterol levels, and other vital health indicators.\n
Ensure you get adequate sleep, aiming for 7-9 hours per night, as poor sleep can affect overall health and weight management.\n
Manage stress through activities like yoga, meditation, or hobbies you enjoy, as chronic stress can impact your health.\n
Avoid smoking and limit alcohol consumption to moderate levels, as these can have significant health impacts.\n
Consider consulting with a healthcare provider or a registered dietitian for personalized advice tailored to your specific health needs and goals.\n

Remember, maintaining a healthy lifestyle is a continuous journey. Keep making positive choices for your well-being!"

Hello @drlau and welcome to the KNIME community.
From my understanding you would have to select the right type of ‘Text format’:

Otherwise you will have to translate it to HTML. Let us know.

BR

1 Like

Hi @@drlau, welcome to the KNIME community.

In addition to @gonhaddock 's note, you will also need to convert your literal “\n” in the text into actual line breaks.

This is going to be slightly unintuitive, but if you run you text through String Manipulation (Variable) first, and execute the following, it should fix the text for you (yes you really do need to four backslashes in front of the “n” ! ) :

regexReplace($${SMyText}$$,"\\\\n","\n")

image



image

2 Likes