Dashboard-2 Markdown node message payload multiple lines

After playing more with Dashboard 2, we loved it. The new markdown node in Dashboard 2 seems to have lots of potential.

A maybe very simple question:
How to create multiple lines from msg.payload that is sent to the Markdown node? This can avoid using multiple Markdown nodes and send multiple information with just one function node and markdown node.
We tried the following:

msg.payload='MAC address:'+macAddress+'\r';
msg.payload+='LAN IP:'+Lan +'\r';

But it does not work. The Markdown node still put "MAC address" and "LAN IP" in the same line.

Have you tried a single backslash;

msg.payload='MAC address:'+macAddress+'\'

Tried it. Node-RED function does not allow single backslash.

With

const msg = `
some
text
multi
lines
`;

No it is still single line.

Dashboard 2 version 0.11.6.

Ok force with \n

'\r', '\n' ... not working. Already tested.

Maybe with <br /> then :thinking:

Nope tried it already :joy:

I have tried out all my ideas :sweat_smile: :joy:

Some Markdown parsers require either 2 spaces at the end of the line or 2 new lines.

E.g

msg.payload = `
There are 2 spaces at end of this line.  
I should be on a new line.


So should i
`
return msg

Umm, just tested, it is still single line.

Can you share a small demo flow

[{"id":"d031d854b5f70791","type":"inject","z":"be4568a984cb4685","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":260,"y":360,"wires":[["c53091a9cb86c1be"]]},{"id":"c53091a9cb86c1be","type":"function","z":"be4568a984cb4685","name":"function 5","func":"msg.payload = `\nThere are 2 spaces at end of this line.  \nI should be on a new line.  \n\nSo should i\n`\nreturn msg","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":420,"y":360,"wires":[["52c7565d26968030"]]},{"id":"52c7565d26968030","type":"ui-markdown","z":"be4568a984cb4685","group":"48fc19d1161f11e6","name":"","order":0,"width":"11","height":"9","content":"{{ msg.payload }}","className":"","x":630,"y":360,"wires":[[]]},{"id":"48fc19d1161f11e6","type":"ui-group","name":"Test","page":"19eb6d108e9275e2","width":"19","height":"12","order":-1,"showTitle":true,"className":"","visible":"true","disabled":"false"},{"id":"19eb6d108e9275e2","type":"ui-page","name":"Examples","ui":"ae3d4aeb3f977a90","path":"/examples","icon":"","layout":"grid","theme":"a965ccfef139317a","order":-1,"className":"","visible":"true","disabled":"false"},{"id":"ae3d4aeb3f977a90","type":"ui-base","name":"Dashboard","path":"/dashboard","includeClientData":true,"acceptsClientConfig":["ui-notification","ui-control"]},{"id":"a965ccfef139317a","type":"ui-theme","name":"Default","colors":{"surface":"#ffffff","primary":"#0094ce","bgPage":"#eeeeee","groupBg":"#ffffff","groupOutline":"#cccccc"}}]

line

v0.11.6

I suspect this has something to do with how the binding is hooked up/sanitised.

I suspect it is a bug but may be by design or simply not supported - @joepavitt will need to comment when he is back on line.

As a potential hold over, the OP can still render a page using object notation.

e.g...

### Details:
* hostname: {{msg.payload.name}}
* MAC address: {{msg.payload.mac}}
* LAN IP: {{msg.payload.ip}}

Sending payload: { mac: 'xx:xx:xx:xx:xx', ip: 'a.b.c.d', name: 'blahblah' }

chrome_RHL5It6TfD

@Steve-Mcl Yes this object notation works, which is even better.

Glad this works, odd that the </br> does not though, I would have expected that to, but will need to dig into more as to why it doesn't.

Have opened Markdown - New line options do not work · Issue #512 · FlowFuse/node-red-dashboard · GitHub to keep track of it

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.