Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

opmltojs

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

opmltojs - npm Package Compare versions

Comparing version 0.4.3 to 0.4.4

68

opmltojs.js

@@ -1,3 +0,28 @@

exports.parse = parse;
var myProductName = "opmltojs"; myVersion = "0.4.4";
/* The MIT License (MIT)
Copyright (c) 2014-2017 Dave Winer
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
exports.parse = parse;
exports.opmlify = opmlify; //8/6/17 by DW
const xml2js = require ("xml2js");

@@ -63,1 +88,42 @@ const utils = require ("daveutils");

}
function opmlify (theOutline, fname) { //returns the opmltext for the outline -- 8/6/17 by DW
var opmltext = "", indentlevel = 0;
function add (s) {
opmltext += utils.filledString ("\t", indentlevel) + s + "\n";
}
function addSubs (subs) {
if (subs !== undefined) {
for (var i = 0; i < subs.length; i++) {
let sub = subs [i], atts = "";
for (var x in sub) {
if (x != "subs") {
atts += " " + x + "=\"" + utils.encodeXml (sub [x]) + "\"";
}
}
if (sub.subs === undefined) {
add ("<outline" + atts + " />");
}
else {
add ("<outline" + atts + " >"); indentlevel++;
addSubs (sub.subs);
add ("</outline>"); indentlevel--;
}
}
}
}
add ("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
add ("<opml version=\"2.0\">"); indentlevel++;
//do head section
add ("<head>"); indentlevel++;
for (var x in theOutline.opml.head) {
add ("<" + x + ">" + theOutline.opml.head [x] + "</" + x + ">");
}
add ("</head>"); indentlevel--;
//do body section
add ("<body>"); indentlevel++;
addSubs (theOutline.opml.body.subs);
add ("</body>"); indentlevel--;
add ("</opml>"); indentlevel--;
console.log ("opmlify: opmltext == \n" + opmltext);
return (opmltext);
}

2

package.json

@@ -6,3 +6,3 @@ {

"license": "MIT",
"version": "0.4.3",
"version": "0.4.4",
"main": "opmltojs.js",

@@ -9,0 +9,0 @@ "repository": {

@@ -17,1 +17,7 @@ ## opmlToJs package

### Updates
##### v0.4.4 -- 8/4/6 by DW
Added new exported function opmlify. It turns an outline structure returned by opmltojs.parse into the equivalent OPML text. It's the other side of parsing, serializing.

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc