Perspective Line Breaks in text label/markdown

How to do line breaks in a text label in Perspective?

I try to replace “\n” by “< b>”(without space) in a script transform but it didn’t work, the is showing and doesn’t create a line break. I try Markdown component too but I have the same issue, I can’t have line break.

You will need to use a markdown component, the proper element however is </br>

Also, ensure you have set the escapeHtml property false.


I have set the escapeHtml property false and add </br> at the end of the line but do I need to do it in a script transform?

If the text is changing then you would need to do this in a transform. If it is static then there wouldn’t be a need to do it in a script.

Ok thanks I understand that part!
But right now my Markdown as a Component Error, do you understand why?

You need to also indicate where the html starts.

Put in opening and closing html tags:

<html>Your Text</br>should go here</html>

Note that you can not have any new lines in your text or this will also result in a component error.

</br> may work, but I’ve always used <br> (no forward slash). This might be part of the problem.

The official short tag is <br/>.

1 Like

you can also do this in labels/buttons ect.

look here and the quote i did there.

@lrose

can you correct me what i am doing wrong in this script

if len(tag_check_neagtive) > 0:
    i = 0
    confirm = False	
    negative_message = 'This chart is unavailable for string type data. Please unselect the tags listed below from the Tag Tree Browser.'
    
    for y in tag_check_neagtive:
        negative_message += '<br>' + str(tag_check_neagtive[i])
        i += 1	
    
    system.perspective.openPopup("Warning", "test", 
                                 {"message": negative_message}, "Error", 
                                 modal=True, showCloseIcon=True, draggable=False, resizable=False)

output i am getting

This chart is unavailable for string type data. Please unselect the tags listed below from the Tag Tree Browser.
[MQTT Engine]Edge Nodes//Electricity/Valid From

but i want output

This chart is unavailable for string type data. Please unselect the tags listed below from the Tag Tree Browser.
[MQTT Engine]Edge Nodes//Electricity/Valid From

tag in next line

I can't see any difference between what you're getting and your wanted output. Can you edit your post to clarify?

sorry i am getting output like this without line break
This chart is unavailable for string type data. Please unselect the tags listed below from the Tag Tree Browser.[MQTT Engine]Edge Nodes//Electricity/Valid From

but i want
This chart is unavailable for string type data. Please unselect the tags listed below from the Tag Tree Browser - single line
and
tag in another line
[MQTT Engine]Edge Nodes//Electricity/Valid From

final output there should be break inbetween
This chart is unavailable for string type data. Please unselect the tags listed below from the Tag Tree Browser
[MQTT Engine]Edge Nodes//Electricity/Valid From

Have you got these settings set correctly?
markdown.escapeHtml : false
markdown.skipHtml : false

1 Like

There's no need for this tag_check_neagtive[i], this is your y. No need to use i at all

1 Like

I have used label previously.

now changed it to markdown and disbaled the settings what u given

working now thanks

image
its automatically giving underline to mqqt/engine
any way to remove it?

Try using the preformatted HTML syntax, <pre>...</pre>.

Welcome to _Markdown_
<pre>[MQTT Engine]Edge Nodes/</pre>

with
markdown.escapeHtml : false
markdown.skipHtml : false

1 Like

You need to escape the bracket characters.

You can use the <pre> tag as @transistor shows but that changes the formatting, which means you might need to provide additional styling.

What is the actual type held in the tag_check_negative list. I see you're converting it to a string, does that mean its actually a list of TagPath objects? How are you obtaining the list?

yes its tagpath so only i converting to str

like this?
negative_message += '<pre>' + str(tag_check_neagtive[i]) + '</pre>'

its not working same underline is showing