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
638 B
JavaScript
Raw Permalink Normal View History

module.exports = function(RED) {
"use strict";
var markdownNode = function(n) {
2019-07-06 00:54:27 +02:00
var md = require('markdown-it')({html:true, linkify:true, typographer: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);
}