Skip to content

Commit

Permalink
2.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
arve0 committed May 24, 2019
1 parent 2a57263 commit 3a60e73
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
18 changes: 16 additions & 2 deletions markdown-it-attrs.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ var patternsConfig = require('./patterns.js');

var defaultOptions = {
leftDelimiter: '{',
rightDelimiter: '}'
rightDelimiter: '}',
allowedAttributes: []
};

module.exports = function attributes(md, options) {
Expand Down Expand Up @@ -658,7 +659,20 @@ exports.getAttrs = function (str, start, options) {
value += char_;
}

return attrs;
if (options.allowedAttributes && options.allowedAttributes.length) {
var allowedAttributes = options.allowedAttributes;
return attrs.filter(function (attrPair) {
var attr = attrPair[0];

function isAllowedAttribute(allowedAttribute) {
return attr === allowedAttribute || allowedAttribute instanceof RegExp && allowedAttribute.test(attr);
}

return allowedAttributes.some(isAllowedAttribute);
});
} else {
return attrs;
}
};
/**
* add attributes from [['key', 'val']] list
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "markdown-it-attrs",
"version": "2.3.4",
"version": "2.4.0",
"description": "Add classes, identifiers and attributes to your markdown with {} curly brackets, similar to pandoc's header attributes",
"main": "index.js",
"license": "MIT",
Expand Down

0 comments on commit 3a60e73

Please sign in to comment.