Node-Red Flows in Wordpress


I wonder if anyone has any ideas. I'm trying to publish one of llarger flows in my Wordpress blog - but no matter which way I try it I end up with a mess. I need a Wordpress plug-in that handles json format... I'm using one that handles javascript... and some formatting is going on but when it comes to the Javascript inside a function node, instead of putting each item on it's own line, I get a mess of text separated by backslashes and "n"... i.e.

"id": "d9f5055c.d034d8",
"type": "function",
"z": "e7f81119.1bd4",
"name": "Process heat",
"func": "var timing=global.get("timing");\nvar now = new Date();\nmsg.payload=timing[(now.getDay()*24)+now.getHours()];\nmsg.frost=timing[168];\nmsg.away=timing[169];\n\nmsg.temperature=flow.get("incomingTemperature");\nmsg.humidity=flow.get("incomingHumidity");\nmsg.set=msg.payload;\nif (flow.get("manualTimer")) flow.set("manualTimer",flow.get("manualTimer")-1);\nelse flow.set("manual",0);\nmsg.desired=msg.set;\nflow.set("setTemperature",msg.desired);\nmsg.desired+=flow.get("manual");\nif (flow.get("frost")) { msg.desired=global.get("timing")[168]; flow.set("frost",flow.get("frost")-1); }\nif (flow.get("away")) { msg.desired=global.get("timing")[169]; flow.set("away",flow.get("away")-1); }\nif (msg.desired>msg.temperature) msg.relay=1; else msg.relay=0;\n\nmsg.payload=flow.get("incomingTemperature");\n\nnode.status({fill:"blue",shape:"dot",text:"Set point " + msg.desired + "c - Actual " + msg.temperature +"c"});\n\nnode.send([msg,null]);\nmsg.payload=msg.relay;\nnode.send([null,msg]);\n\n\n\n\n",
"outputs": "2",
"noerr": 0,
"x": 750,
"y": 500,



We've just had exactly the same question in another topic here: Wordpress plugin - oneliner code style similar to NR discussion goup

Strange coincidence....

If you updated to the latest wordpress 5.x, then their new editor lets you add a block to your post which you can identify as a code block and it will do the right thing.



When I got to the bottom of this - I found the main issue was in any code, \n appearing instead of actual new lines - I've made a start...



I am on Wordpress 5.x but cannot get away with that horrible editor arrangement and getting images out of resources. I use Microsoft Live Writer and simply paste in images giving them alt text as needed,




One of many reasons I've ditched WordPress. I'm now using the Hugo static site generator hosted by Netlify. I use Typora if I want a WYSIWYG editor, mostly I just write Markdown.



Save the settings and use the tag I have found on the the bottom of the settings page:

  • [sourcecode language="plain"]your code here[/sourcecode]

Than the NR flow in the wordpress page will look similar to the oneliner in the NR forum: