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

shortcode-tree

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shortcode-tree - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

2

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

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

@@ -17,3 +17,3 @@ let ShortcodeParser = require('./shortcode-parser');

// Worse yet, in the case of malformatted shortcodes, this won't work reliably at all. That's a TODO: Figure out how to deal with malformatted input elegantly
const regex = /\[(.*)\]([\S\s]*)\[\/(.*)\]/g;
const regex = /\[(.*)(\]([\S\s]*)\[\/(.*)\]|\/\])/g;

@@ -20,0 +20,0 @@ let match;

@@ -196,8 +196,8 @@ let fs = require('fs');

shortcode.content = input.substr(openBlockStartIdx + openBlockTextFull.length, (input.length - openBlockTextFull.length - closingTagExpected.length - offsetFromEnd));
shortcode.codeText = input.substr(openBlockStartIdx, input.length - offsetFromEnd);
} else {
shortcode.content = null;
shortcode.codeText = input.substr(openBlockStartIdx, openBlockTextFull.length);
}
shortcode.codeText = input.substr(openBlockStartIdx, input.length - offsetFromEnd);
return shortcode;

@@ -204,0 +204,0 @@ }

@@ -25,2 +25,11 @@ let ShortcodeExtractor = require('../src').ShortcodeExtractor;

it('extracts a self-closing shortcode with text surrounding it', function () {
let testInput = "Check out [img src=abc.jpg/], a cool image";
let expectedOutput = [new Shortcode("img", null, {"src": "abc.jpg"}, true, "[img src=abc.jpg/]", 10)];
let actualOutput = ShortcodeExtractor.extractShortcodes(testInput) || null;
expect(actualOutput).to.deep.equal(expectedOutput);
});
it('extracts multiple simple shortcodes on the same level', function () {

@@ -27,0 +36,0 @@ let testInput = "[b]boldest text[/b][i]bats[/i]";

@@ -97,2 +97,10 @@ let ShortcodeParser = require('../src').ShortcodeParser;

it('calculates the correct code text for self-closing tags in an offset string', function () {
let testInput = `edge case [antics/] are here`;
let expectedOutput = new Shortcode("antics", null, {}, true, "[antics/]", 10);
let actualOutput = ShortcodeParser.parseShortcode(testInput, options) || null;
expect(actualOutput).to.deep.equal(expectedOutput);
});
it('throws an error for malformatted input: missing opening tag', function () {

@@ -99,0 +107,0 @@ let testInput = `no opening tag`;

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