Socket
Socket
Sign inDemoInstall

shortcode-tree

Package Overview
Dependencies
0
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.4.8 to 1.4.9

34

dist/shortcode-tree.js

@@ -102,2 +102,36 @@ 'use strict';

return textContent;
},
generateHtmlEquivalent: function generateHtmlEquivalent(input) {
var treeRootNode = this.parse(input);
var textContent = "";
var fnTraverseNodeForContent = function fnTraverseNodeForContent(node) {
var nodeChildText = null;
if (node instanceof TextNode) {
nodeChildText = node.text;
} else if (node instanceof ShortcodeNode) {
if (node.children.length) {
var _tvChildContent = '';
node.children.forEach(function (node) {
_tvChildContent += fnTraverseNodeForContent(node);
});
if (node.shortcode) {
node.shortcode.content = _tvChildContent;
nodeChildText = node.shortcode.stringifyAsHtml();
} else {
nodeChildText = _tvChildContent;
}
} else {
// Topmost node with no children
nodeChildText = node.shortcode.stringifyAsHtml();
}
}
return nodeChildText;
};
return fnTraverseNodeForContent(treeRootNode);
}

@@ -104,0 +138,0 @@ };

2

package.json
{
"name": "shortcode-tree",
"version": "1.4.8",
"version": "1.4.9",
"description": "Parser library for reading short codes (BB codes) into a tree structure",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -131,2 +131,9 @@ let ShortcodeTree = require('../src').ShortcodeTree;

});
it('generates html equiv text', function () {
let testInput = `text [div][strong]Hi[/strong][img/]text[div][strong]sub[/strong][/div][/div] text`;
let html = ShortcodeTree.generateHtmlEquivalent(testInput);
expect(html).to.equal("text <div><strong>Hi</strong><img/>text<div><strong>sub</strong></div></div> text");
});
});

@@ -133,0 +140,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc