1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00
node-red-nodes/parsers/markdown/70-markdown.js

18 lines
620 B
JavaScript
Raw Normal View History

module.exports = function(RED) {
"use strict";
var markdownNode = function(n) {
var md = require('markdown-it')({html:true, linkify:true});
RED.nodes.createNode(this,n);
var node = this;
//<div id="nr-markdown" style="font-family:helvetica neue,arial,helvetica,sans-serif; margin:12px">';
node.on("input", function(msg) {
if (msg.payload !== undefined && typeof msg.payload === "string") {
msg.payload = md.render(msg.payload);
}
node.send(msg);
});
}
RED.nodes.registerType("markdown",markdownNode);
}