Security News
New Proposed CISA Mandate Would Require Critical Infrastructure to Report Ransom Payments Within 24 Hours
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
meta-shortcodes
Advanced tools
Shortcode parser with support of arguments, key-value attributes and nesting.
Weekly downloads
Readme
#meta-shortcodes
Generic shortcodes parser with support of attributes and single/pair tags.
var should = require("should");
var ShortcodeParser = require("meta-shortcodes");
var parser = ShortcodeParser();
parser.add("test", function(opts, content){
return content.toUpperCase();
});
parser.add("nested", function(opts, content){
if(!opts.multiply) return "Missing multiply attribute!";
var out = [];
for(var i = 0; i < opts.length; i++)
out.push(opts[i] * parseFloat(opts.multiply));
return out.join(" ");
});
var input = "Sample [test]shortcode content [nested multiply=2 2 4/] is upper[/test] case!";
var output = parser.parse(input);
output.should.eql("Sample SHORTCODE CONTENT 4 8 IS UPPER case!");
npm install meta-shortcodes
opts = {
openPattern: '\\[',
closePattern: '\\]'
}
Registers new shortcode
Param | Type | Description |
---|---|---|
shortcodeName | string | Name of shortcode tag |
handlerFunction | function | Function that returns replacement for shortcode. Accepts two arguments - options object and content string. |
Registers new shortcode
Param | Type | Description |
---|---|---|
inputStr | string | Input string where shortcodes should be replaced. |
#Self-closing
[name argument1 argument2 key=value key=value/]
#Pair
[name]content[/name]
#Quoted arguments
[name "argument 1" 'argument 2' "key is"="long value"/]
#Escaping quotes in arguments
[name "argu\"ment" "ke\"y"='val\'ue']
#Escaping of entire shortcode
\\[this shortcode is not processed /]
npm install --dev
npm test
Current code-coverage 97%
var should = require("should");
var ShortcodeParser = require("meta-shortcodes");
var parser = ShortcodeParser({
openPattern: '\\{{',
closePattern: '\\}}'
});
parser.add("test", function(opts, content){
return content.toUpperCase();
});
var output = parser.parse("Sample {{test}}upper{{/test}} case!").should.eql("Sample UPPER case!");
MIT (c) 2015 META Platform team, Jiri Hybek
FAQs
Shortcode parser with support of arguments, key-value attributes and nesting.
The npm package meta-shortcodes receives a total of 34 weekly downloads. As such, meta-shortcodes popularity was classified as not popular.
We found that meta-shortcodes demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
Security News
Redis is no longer OSS, breaking its explicit commitment to remain under the BSD 3-Clause License forever. This has angered contributors who are now working to fork the software.
Product
Socket AI now enables 'AI detected potential malware' alerts by default, ensuring users benefit from AI-powered state-of-the-art malware detection without needing to opt-in.