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

Add initial markdown node

(not quite ready for prime time)
This commit is contained in:
Dave Conway-Jones 2019-07-05 18:53:25 +01:00
parent 1ea7885b58
commit fef734486f
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4
7 changed files with 103 additions and 1 deletions

View File

@ -17,7 +17,7 @@
"name": "Benjamin Hardill", "name": "Benjamin Hardill",
"url": "http://www.hardill.me.uk/wordpress/" "url": "http://www.hardill.me.uk/wordpress/"
}, },
"license": "APACHE-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"node-ssdp": "~3.2.5", "node-ssdp": "~3.2.5",
"request": "~2.74.0", "request": "~2.74.0",

View File

@ -0,0 +1,32 @@
<script type="text/x-red" data-template-name="markdown">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>
<script type="text/x-red" data-help-name="markdown">
<p>A function that converts the <code>msg.payload</code> in markdown format to html.</p>
<p>If the input is a string it tries to convert it to html.</p>
<p>All other message types are ignored.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('markdown',{
category: 'function',
color:"#DEBD5C",
defaults: {
name: {value:""}
},
inputs:1,
outputs:1,
icon: "parser-markdown.png",
label: function() {
return this.name||"markdown";
},
labelStyle: function() {
return this.name?"node_label_italic":"";
}
});
</script>

View File

@ -0,0 +1,17 @@
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);
}

13
parsers/markdown/LICENSE Normal file
View File

@ -0,0 +1,13 @@
Copyright 2019 JS Foundation and other contributors, https://js.foundation/
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -0,0 +1,16 @@
node-red-node-markdown
======================
A <a href="http://nodered.org" target="_new">Node-RED</a> node to convert a markdown string to html.
Install
-------
Run the following command in your Node-RED user directory - typically `~/.node-red`
npm install node-red-node-markdown
Usage
-----
If the input is a string it tries to convert it into an html string.

Binary file not shown.

After

Width:  |  Height:  |  Size: 568 B

View File

@ -0,0 +1,24 @@
{
"name" : "node-red-node-markdown",
"version" : "0.0.1",
"description" : "A Node-RED node to convert a markdown string to html.",
"dependencies" : {
"markdown-it": "^8.4.2"
},
"repository" : {
"type":"git",
"url":"https://github.com/node-red/node-red-nodes/tree/master/parsers/markdown"
},
"license": "Apache-2.0",
"keywords": [ "node-red", "markdown" ],
"node-red" : {
"nodes" : {
"markdown": "70-markdown.js"
}
},
"author": {
"name": "Dave Conway-Jones",
"email": "ceejay@vnet.ibm.com",
"url": "http://nodered.org"
}
}