shortcode-tree
Advanced tools
Comparing version 1.4.2 to 1.4.3
@@ -58,2 +58,10 @@ "use strict"; | ||
var predictedAsSelfClosing = input.indexOf(closingTagExpected) === -1; | ||
if (predictedAsSelfClosing) { | ||
shortcode.isSelfClosing = true; | ||
} else { | ||
shortcode.isSelfClosing = false; | ||
} | ||
if (shortcode.isSelfClosing && input.substr(openBlockTextFull.length, closingTagExpected.length) === closingTagExpected) { | ||
@@ -67,2 +75,4 @@ // Special case: misbehaving little bugger claims to be improperly self-closing, but decided to close itself | ||
shortcode.codeText = input.substr(openBlockStartIdx, input.length - offsetFromEnd); | ||
shortcode.isSelfClosing = false; | ||
} else if (options.precise && !shortcode.isSelfClosing) { | ||
@@ -69,0 +79,0 @@ var stackLevel = 0; |
{ | ||
"name": "shortcode-tree", | ||
"version": "1.4.2", | ||
"version": "1.4.3", | ||
"description": "Parser library for reading short codes (BB codes) into a tree structure", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -113,8 +113,9 @@ let ShortcodeParser = require('../src').ShortcodeParser; | ||
it('throws an error for malformatted input: invalid closing tag', function () { | ||
it('does not error / performs best guess for malformatted input: invalid/missing closing tag', function () { | ||
let testInput = `we [open] but no [/close]`; | ||
expect(function () { | ||
ShortcodeParser.parseShortcode(testInput, options) | ||
}).to.throw("closing tag"); | ||
let expectedOutput = new Shortcode("open", null, {}, true, "[open]", 3); | ||
let actualOutput = ShortcodeParser.parseShortcode(testInput, options) || null; | ||
expect(actualOutput).to.deep.equal(expectedOutput); | ||
}); | ||
@@ -171,3 +172,3 @@ | ||
it('does not throw errors if "throwErrors" is set to false', function () { | ||
let testInput = "this might be [b]invalid"; | ||
let testInput = "this might be [invalid"; | ||
let expectedOutput = false; | ||
@@ -189,3 +190,3 @@ let actualOutput = ShortcodeParser.parseShortcode(testInput, { throwErrors: false }); | ||
let testInput = `[img src="what.jpg" standards="no"][/img] asdf`; | ||
let expectedOutput = new Shortcode('img', "", {"src": "what.jpg", "standards": "no"}, true, `[img src="what.jpg" standards="no"][/img]`, 0); | ||
let expectedOutput = new Shortcode('img', "", {"src": "what.jpg", "standards": "no"}, false, `[img src="what.jpg" standards="no"][/img]`, 0); | ||
let actualOutput = ShortcodeParser.parseShortcode(testInput, { selfClosingTags: ["img"] }) || null; | ||
@@ -192,0 +193,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
67887
1189