Skip to content

Commit

Permalink
4.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
arve0 committed May 8, 2022
1 parent 0c7be92 commit ad79f52
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
26 changes: 16 additions & 10 deletions markdown-it-attrs.browser.js
Expand Up @@ -81,7 +81,9 @@ function test(tokens, i, t) {
return res;
}

var _loop2 = function _loop2(key) {
var _loop2 = function _loop2() {
var key = _Object$keys[_i];

if (key === 'shift' || key === 'position') {
return "continue";
}
Expand Down Expand Up @@ -198,8 +200,8 @@ function test(tokens, i, t) {
}
};

for (var key in t) {
var _ret = _loop2(key);
for (var _i = 0, _Object$keys = Object.keys(t); _i < _Object$keys.length; _i++) {
var _ret = _loop2();

if (_ret === "continue") continue;
if (_typeof(_ret) === "object") return _ret.v;
Expand Down Expand Up @@ -564,14 +566,14 @@ function last(arr) {
}

},{"./utils.js":3}],3:[function(require,module,exports){
'use strict';
"use strict";

/**
* parse {.class #id key=val} strings
* @param {string} str: string to parse
* @param {int} start: where to start parsing (including {)
* @returns {2d array}: [['key', 'val'], ['class', 'red']]
*/

exports.getAttrs = function (str, start, options) {
// not tab, line feed, form feed, space, solidus, greater than sign, quotation mark, apostrophe and equals sign
var allowedKeyChars = /[^\t\n\f />"'=]/;
Expand Down Expand Up @@ -673,9 +675,9 @@ exports.getAttrs = function (str, start, options) {

return allowedAttributes.some(isAllowedAttribute);
});
} else {
return attrs;
}

return attrs;
};
/**
* add attributes from [['key', 'val']] list
Expand Down Expand Up @@ -704,18 +706,17 @@ exports.addAttrs = function (attrs, token) {
* Does string have properly formatted curly?
*
* start: '{.a} asdf'
* middle: 'a{.b}c'
* end: 'asdf {.a}'
* only: '{.a}'
*
* @param {string} where to expect {} curly. start, middle, end or only.
* @param {string} where to expect {} curly. start, end or only.
* @return {function(string)} Function which testes if string has curly.
*/


exports.hasDelimiters = function (where, options) {
if (!where) {
throw new Error('Parameter `where` not passed. Should be "start", "middle", "end" or "only".');
throw new Error('Parameter `where` not passed. Should be "start", "end" or "only".');
}
/**
* @param {string} str
Expand Down Expand Up @@ -769,6 +770,9 @@ exports.hasDelimiters = function (where, options) {
slice = str.slice(str.length - options.rightDelimiter.length);
end = slice === options.rightDelimiter ? str.length - options.rightDelimiter.length : -1;
break;

default:
throw new Error("Unexpected case ".concat(where, ", expected 'start', 'end' or 'only'"));
}

return start !== -1 && end !== -1 && validCurlyLength(str.substring(start, end + options.rightDelimiter.length));
Expand Down Expand Up @@ -822,6 +826,8 @@ exports.getMatchingOpeningToken = function (tokens, i) {
return tokens[i];
}
}

return false;
};
/**
* from https://github.com/markdown-it/markdown-it/blob/master/lib/common/utils.js
Expand Down
4 changes: 2 additions & 2 deletions 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
@@ -1,6 +1,6 @@
{
"name": "markdown-it-attrs",
"version": "4.1.3",
"version": "4.1.4",
"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 ad79f52

Please sign in to comment.