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.9 to 1.4.10

18

dist/shortcode-formatter.js

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -22,6 +22,13 @@ var Shortcode = require('./shortcode');

var buffer = "";
var tagNameToUse = shortcode.name;
if (options.tagName) {
tagNameToUse = options.tagName;
} else if (typeof options.tagNameMap[tagNameToUse] !== "undefined") {
tagNameToUse = options.tagNameMap[tagNameToUse];
}
// Open tag "[name"
buffer += options.asHtml ? ShortcodeFormatter.T_TAG_START_HTML : ShortcodeFormatter.T_TAG_START;
buffer += options.tagName ? options.tagName : shortcode.name;
buffer += tagNameToUse;

@@ -79,3 +86,3 @@ // Add any properties

buffer += ShortcodeFormatter.T_TAG_CLOSER;
buffer += shortcode.name;
buffer += tagNameToUse;
buffer += ShortcodeFormatter.T_TAG_END_HTML;

@@ -85,3 +92,3 @@ } else {

buffer += ShortcodeFormatter.T_TAG_CLOSER;
buffer += shortcode.name;
buffer += tagNameToUse;
buffer += ShortcodeFormatter.T_TAG_END;

@@ -126,5 +133,6 @@ }

asHtml: false,
tagName: null
tagName: null,
tagNameMap: {}
};
module.exports = ShortcodeFormatter;

@@ -103,3 +103,3 @@ 'use strict';

},
generateHtmlEquivalent: function generateHtmlEquivalent(input) {
generateHtmlEquivalent: function generateHtmlEquivalent(input, options) {
var treeRootNode = this.parse(input);

@@ -123,3 +123,3 @@ var textContent = "";

node.shortcode.content = _tvChildContent;
nodeChildText = node.shortcode.stringifyAsHtml();
nodeChildText = node.shortcode.stringifyAsHtml(null, options);
} else {

@@ -130,3 +130,3 @@ nodeChildText = _tvChildContent;

// Topmost node with no children
nodeChildText = node.shortcode.stringifyAsHtml();
nodeChildText = node.shortcode.stringifyAsHtml(null, options);
}

@@ -133,0 +133,0 @@ }

@@ -157,2 +157,3 @@ "use strict";

* @param {string|null} tagName Optional HTML tag name override.
* @param {object} options Formatter options
* @return {*}

@@ -163,4 +164,4 @@ */

key: "stringifyAsHtml",
value: function stringifyAsHtml(tagName) {
var config = {
value: function stringifyAsHtml(tagName, options) {
var optionsMerged = {
asHtml: true,

@@ -170,3 +171,7 @@ tagName: tagName ? tagName : null

return ShortcodeFormatter.stringify(this, config);
if (options) {
optionsMerged = Object.assign({}, options, optionsMerged);
}
return ShortcodeFormatter.stringify(this, optionsMerged);
}

@@ -173,0 +178,0 @@

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

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

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

});
it('generates html equiv text with config tag name map', function () {
let testInput = `[blah][image/][/blah]`;
let html = ShortcodeTree.generateHtmlEquivalent(testInput, {
tagNameMap: {
"blah": "div",
"image": "img"
}
});
expect(html).to.equal("<div><img/></div>");
});
});

@@ -140,0 +153,0 @@

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