@canopycanopycanopy/b-ber-grammar-renderer 1.2.16 → 2.0.2

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.
Files changed (2) hide show
  1. package/dist/index.js +14 -31
  2. package/package.json +7 -6
package/dist/index.js CHANGED
@@ -1,28 +1,18 @@
1
1
  "use strict";
2
2
 
3
3
  var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
-
5
4
  var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
6
-
7
5
  _Object$defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
-
11
8
  exports.default = void 0;
12
-
13
9
  var _trim = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/trim"));
14
-
15
10
  var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
16
-
17
11
  var _lodash = _interopRequireDefault(require("lodash.isundefined"));
18
-
19
12
  var _State = _interopRequireDefault(require("@canopycanopycanopy/b-ber-lib/State"));
20
-
21
13
  var _bBerLogger = _interopRequireDefault(require("@canopycanopycanopy/b-ber-logger"));
22
-
23
14
  var _bBerShapesDirectives = require("@canopycanopycanopy/b-ber-shapes-directives");
24
-
25
- // we assign a default object to the `context` argument, since we'll refer to
15
+ // Assign a default object to the `context` argument, since we'll refer to
26
16
  // some of its properties during tests. the properties themselves don't
27
17
  // need to be defined, though
28
18
  const renderer = ({
@@ -36,59 +26,52 @@ const renderer = ({
36
26
  minMarkers: _bBerShapesDirectives.BLOCK_DIRECTIVE_MARKER_MIN_LENGTH,
37
27
  markerOpen,
38
28
  markerClose,
39
-
40
29
  validateOpen(params, line) {
41
- // check to see if we've hit an opening/exit token, i.e., `::: <name>:<id>`
30
+ // Check to see if we've hit an opening/exit token, i.e., `::: <name>:<id>`
42
31
  const match = (0, _trim.default)(params).call(params).match(markerOpen);
43
- if (!match || !match.length) return false; // it's a directive! now check to see if it's well-formed.
32
+ if (!match || !match.length) return false;
44
33
 
34
+ // It's a directive - check to see if it's well-formed.
45
35
  const [, type, id] = match;
46
-
47
36
  if ((0, _lodash.default)(id)) {
48
- // the directive's missing an `id` attribute, so we extract the
37
+ // The directive's missing an `id` attribute, so we extract the
49
38
  // fileName from `context` which we've stored in back in
50
39
  // `md/index.es6`, and passed into our `renderer`
51
- _bBerLogger.default.error(`Missing [id] for [${exports.default.name}:start] at ${context.fileName}.md:${line}`); // let the parser know that this wasn't a match
52
-
40
+ _bBerLogger.default.error(`Missing [id] for [${exports.default.name}:start] at ${context.fileName}.md:${line}`);
53
41
 
42
+ // Let the parser know that this wasn't a match
54
43
  return false;
55
- } // we add the `id` to the global state so that we can verify that the
56
- // container is being properly closed in our `validateClose` method
57
-
44
+ }
58
45
 
46
+ // Add the `id` to the global state so that we can verify that the
47
+ // container is being properly closed in our `validateClose` method
59
48
  const index = (0, _indexOf.default)(_State.default).call(_State.default, 'cursor', {
60
49
  id
61
50
  });
62
51
  const isOpening = type && type !== 'exit';
63
52
  const isClosing = type && type === 'exit';
64
53
  const inStore = index > -1;
65
-
66
54
  _bBerLogger.default.debug(`id: ${id}; isOpening: ${isOpening}; isClosing: ${isClosing}; type: ${type}, inStore: ${inStore}`);
67
-
68
55
  const location = `${context.fileName}.md:${line}`;
69
-
70
56
  if (isOpening && inStore) {
71
- // it's a duplicate `id`, throw
57
+ // It's a duplicate `id`
72
58
  _bBerLogger.default.error(`Duplicate [id] [${id}]. [id] must be unique at [${location}]`);
73
59
  } else if (isClosing && !inStore) {
74
- // trying to close an un-opened directive, but it might belong to a
60
+ // Trying to close an un-opened directive, but it might belong to a
75
61
  // different directive type
76
62
  return false;
77
63
  } else if (isOpening && !inStore) {
78
- // it's a brand new directive
64
+ // It's a new directive
79
65
  _State.default.add('cursor', {
80
66
  id,
81
67
  type
82
68
  });
83
-
84
69
  return true;
85
70
  } else if (isClosing && inStore) {
86
- // it's the end of a directive, handle close in section.js
71
+ // It's the end of a directive, handle close in section.js
87
72
  return true;
88
73
  }
89
74
  }
90
-
91
75
  });
92
-
93
76
  var _default = renderer;
94
77
  exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canopycanopycanopy/b-ber-grammar-renderer",
3
- "version": "1.2.16",
3
+ "version": "2.0.2",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -20,13 +20,14 @@
20
20
  "@babel/cli": "^7.10.5",
21
21
  "@babel/core": "^7.10.5",
22
22
  "@babel/preset-env": "^7.10.4",
23
+ "browserslist": "^4.17.4",
23
24
  "jest": "^26.6.3",
24
- "rimraf": "^2.6.3"
25
+ "rimraf": "^2.7.1"
25
26
  },
26
27
  "dependencies": {
27
- "@canopycanopycanopy/b-ber-lib": "1.2.16",
28
- "@canopycanopycanopy/b-ber-logger": "1.2.16",
29
- "@canopycanopycanopy/b-ber-shapes-directives": "1.2.16",
28
+ "@canopycanopycanopy/b-ber-lib": "2.0.2",
29
+ "@canopycanopycanopy/b-ber-logger": "2.0.2",
30
+ "@canopycanopycanopy/b-ber-shapes-directives": "2.0.2",
30
31
  "lodash": "^4.17.21",
31
32
  "lodash.isundefined": "^3.0.1",
32
33
  "tar": "^6.1.11"
@@ -48,5 +49,5 @@
48
49
  "url": "https://maxwellsimmer.com"
49
50
  }
50
51
  ],
51
- "gitHead": "b4d9c563beb349a32c19e0f65447f7c7dbc8ea52"
52
+ "gitHead": "9b13185f21f602f8a2bf3a4cf503b1fd644d6432"
52
53
  }