@canopycanopycanopy/b-ber-grammar-attributes 1.2.16 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +36 -34
- package/package.json +7 -6
package/dist/index.js
CHANGED
|
@@ -40,15 +40,13 @@ var _lodash = _interopRequireDefault(require("lodash.has"));
|
|
|
40
40
|
|
|
41
41
|
var _bBerLib = require("@canopycanopycanopy/b-ber-lib");
|
|
42
42
|
|
|
43
|
-
var _utils = require("@canopycanopycanopy/b-ber-lib/utils");
|
|
44
|
-
|
|
45
43
|
var _bBerLogger = _interopRequireDefault(require("@canopycanopycanopy/b-ber-logger"));
|
|
46
44
|
|
|
47
45
|
var _bBerShapesDirectives = require("@canopycanopycanopy/b-ber-shapes-directives");
|
|
48
46
|
|
|
49
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object);
|
|
47
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
50
48
|
|
|
51
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
49
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
52
50
|
|
|
53
51
|
//
|
|
54
52
|
// Querying hierarchies gets confusing, so we're using biological taxonomic
|
|
@@ -68,11 +66,11 @@ const _isUnsupportedAttribute = (genus, attr) => {
|
|
|
68
66
|
let key;
|
|
69
67
|
|
|
70
68
|
if (_bBerShapesDirectives.BLOCK_DIRECTIVES.has(genus)) {
|
|
71
|
-
//
|
|
69
|
+
// These are all containers which share the same attributes, so they're
|
|
72
70
|
// grouped under a single property
|
|
73
71
|
key = 'block';
|
|
74
72
|
} else {
|
|
75
|
-
//
|
|
73
|
+
// This will be the directive name, e.g., figure, video, etc
|
|
76
74
|
key = genus;
|
|
77
75
|
}
|
|
78
76
|
|
|
@@ -133,25 +131,25 @@ const parseAttrs = s => {
|
|
|
133
131
|
if (!open && char === 58
|
|
134
132
|
/* : */
|
|
135
133
|
) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
continue;
|
|
134
|
+
// char is a token, we set `open` so that we don't misinterpret literals inside quotations
|
|
135
|
+
open = true;
|
|
136
|
+
key = str;
|
|
137
|
+
str = '';
|
|
138
|
+
delim = 32;
|
|
139
|
+
/* */
|
|
140
|
+
|
|
141
|
+
if (next === 34
|
|
142
|
+
/* " */
|
|
143
|
+
|| next === 39
|
|
144
|
+
/* ' */
|
|
145
|
+
) {
|
|
146
|
+
i++;
|
|
147
|
+
delim = next;
|
|
153
148
|
}
|
|
154
149
|
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
|
|
155
153
|
if (char === delim) {
|
|
156
154
|
// token is ending delimiter since we've advanced our pointer
|
|
157
155
|
key = (0, _trim.default)(key).call(key); // trim whitespace, allowing for multiple spaces
|
|
@@ -246,13 +244,13 @@ const _extendWithDefaults = (obj, genus) => {
|
|
|
246
244
|
}; // Create an object from attributes in the given directive
|
|
247
245
|
|
|
248
246
|
|
|
249
|
-
const attributesObject = (attrs,
|
|
247
|
+
const attributesObject = (attrs, origGenus, context = {}) => {
|
|
250
248
|
const {
|
|
251
249
|
fileName,
|
|
252
250
|
lineNumber
|
|
253
251
|
} = context;
|
|
254
252
|
const attrsObject = {};
|
|
255
|
-
let genus =
|
|
253
|
+
let genus = origGenus;
|
|
256
254
|
|
|
257
255
|
if (!genus || typeof genus !== 'string') {
|
|
258
256
|
_bBerLogger.default.error(`No directive provided: ${fileName}:${lineNumber}`);
|
|
@@ -275,23 +273,27 @@ const attributesObject = (attrs, _genus, context = {}) => {
|
|
|
275
273
|
}
|
|
276
274
|
|
|
277
275
|
if (attrs && typeof attrs === 'string') {
|
|
278
|
-
(0,
|
|
279
|
-
|
|
280
|
-
|
|
276
|
+
const parsedAttrs = (0, _entries.default)(parseAttrs((0, _trim.default)(attrs).call(attrs))); // eslint-disable-next-line no-unused-vars
|
|
277
|
+
|
|
278
|
+
for (const [key, val] of parsedAttrs) {
|
|
279
|
+
if (_isUnsupportedAttribute(genus, key)) {
|
|
280
|
+
_bBerLogger.default.warn(`render omitting unsupported attribute [${key}] at [${fileName}:${lineNumber}]`);
|
|
281
|
+
|
|
282
|
+
continue;
|
|
281
283
|
}
|
|
282
284
|
|
|
283
|
-
attrsObject[
|
|
284
|
-
}
|
|
285
|
-
} // Add original `
|
|
285
|
+
attrsObject[key] = val;
|
|
286
|
+
}
|
|
287
|
+
} // Add original `origGenus` as a class to the attrs object in case it's
|
|
286
288
|
// different from the current `genus` (which might've changed due to it's
|
|
287
289
|
// specification). do this to keep styling consistent
|
|
288
290
|
|
|
289
291
|
|
|
290
|
-
if (genus !==
|
|
292
|
+
if (genus !== origGenus) {
|
|
291
293
|
if ((0, _lodash.default)(attrsObject, 'classes')) {
|
|
292
|
-
attrsObject.classes += ` ${
|
|
294
|
+
attrsObject.classes += ` ${origGenus}`;
|
|
293
295
|
} else {
|
|
294
|
-
attrsObject.classes =
|
|
296
|
+
attrsObject.classes = origGenus;
|
|
295
297
|
}
|
|
296
298
|
}
|
|
297
299
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canopycanopycanopy/b-ber-grammar-attributes",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"access": "public"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@canopycanopycanopy/b-ber-lib": "
|
|
21
|
-
"@canopycanopycanopy/b-ber-logger": "
|
|
22
|
-
"@canopycanopycanopy/b-ber-shapes-directives": "
|
|
20
|
+
"@canopycanopycanopy/b-ber-lib": "3.0.0",
|
|
21
|
+
"@canopycanopycanopy/b-ber-logger": "3.0.0",
|
|
22
|
+
"@canopycanopycanopy/b-ber-shapes-directives": "3.0.0",
|
|
23
23
|
"lodash": "^4.17.21",
|
|
24
24
|
"lodash.has": "latest",
|
|
25
25
|
"tar": "^6.1.11"
|
|
@@ -28,8 +28,9 @@
|
|
|
28
28
|
"@babel/cli": "^7.10.5",
|
|
29
29
|
"@babel/core": "^7.10.5",
|
|
30
30
|
"@babel/preset-env": "^7.10.4",
|
|
31
|
+
"browserslist": "^4.17.4",
|
|
31
32
|
"jest": "^26.6.3",
|
|
32
|
-
"rimraf": "^2.
|
|
33
|
+
"rimraf": "^2.7.1"
|
|
33
34
|
},
|
|
34
35
|
"files": [
|
|
35
36
|
"dist"
|
|
@@ -48,5 +49,5 @@
|
|
|
48
49
|
"url": "https://maxwellsimmer.com"
|
|
49
50
|
}
|
|
50
51
|
],
|
|
51
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "676dbec7fbdcc46eb8168f1d437d294ed549e2e8"
|
|
52
53
|
}
|