shortcode-tree
Advanced tools
Comparing version 1.3.1 to 1.4.0
@@ -26,3 +26,2 @@ 'use strict'; | ||
/** | ||
@@ -71,2 +70,6 @@ * Traverses a tree node: extracts short codes from the node text, and traverses its child nodes. | ||
} | ||
}, | ||
extractTextContent(input) { | ||
} | ||
@@ -73,0 +76,0 @@ }; |
{ | ||
"name": "shortcode-tree", | ||
"version": "1.3.1", | ||
"version": "1.4.0", | ||
"description": "Parser library for reading short codes (BB codes) into a tree structure", | ||
@@ -9,3 +9,3 @@ "main": "dist/index.js", | ||
"build": "babel src --presets babel-preset-es2015 --out-dir dist", | ||
"prepublish": "npm run build" | ||
"prepublishOnly": "npm run build" | ||
}, | ||
@@ -12,0 +12,0 @@ "author": "Roy de Jong <roy@softwarepunt.nl>", |
@@ -121,2 +121,38 @@ let ShortcodeTree = require('../src').ShortcodeTree; | ||
}); | ||
}); | ||
describe('ShortcodeTree.extractTextContent()', function () { | ||
it ('leaves plain text alone', function () { | ||
let testInput = `blah blah`; | ||
let expectedOutput = testInput; | ||
let actualOutput = ShortcodeTree.extractTextContent(testInput); | ||
expect(actualOutput).to.equal(expectedOutput); | ||
}); | ||
it ('strips code text from a simple shortcode', function () { | ||
let testInputInner = 'blah <b>blah</b> blah'; | ||
let testInput = `[b]${testInputInner}[/b]`; | ||
let expectedOutput = testInputInner; | ||
let actualOutput = ShortcodeTree.extractTextContent(testInput); | ||
expect(actualOutput).to.equal(expectedOutput); | ||
}); | ||
it ('strips code text from deep nested shortcodes', function () { | ||
let testInput = `root [row][column]deep[/column][/row]`; | ||
let expectedOutput = "root deep"; | ||
let actualOutput = ShortcodeTree.extractTextContent(testInput); | ||
expect(actualOutput).to.equal(expectedOutput); | ||
}); | ||
it ('adds automatic spaces between text from different nesting levels', function () { | ||
let testInput = `[page][row][col]<h1>some text</h1>[img/][sub]bla[/sub]w[/col]a[/row]w[/page]`; | ||
let expectedOutput = "<h1>some text</h1> bla w a w"; | ||
let actualOutput = ShortcodeTree.extractTextContent(testInput); | ||
expect(actualOutput).to.equal(expectedOutput); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
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
1144
64765
17