@canopycanopycanopy/b-ber-grammar-renderer 3.0.8-nav.0 → 3.0.8-next.61

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/README.md CHANGED
@@ -1,9 +1,20 @@
1
- # `@canopycanopycanopy/b-ber-grammar-renderer`
1
+ # b-ber-grammar-renderer
2
2
 
3
- The `b-ber-grammar-renderer` package is used internally by b-ber to render containing custom Markdown extensions (directives) into HTML. More information about b-ber directives can be found in the [All directives](https://github.com/triplecanopy/b-ber/wiki/all-directives) page in the b-ber [Wiki](https://github.com/triplecanopy/b-ber/wiki).
3
+ The shared MarkdownIt container renderer factory used by block-level grammar packages. Exports a single `createRenderer` function that takes a `render` function, `markerOpen` and `markerClose` regexes, and a `context` object, and returns a MarkdownIt container plugin configuration object with `marker`, `minMarkers`, `markerOpen`, `markerClose`, and a `validateOpen` method. The `validateOpen` method enforces that every opening directive has a unique `id`, tracks open directive ids in global state (`state.cursor`), and validates that exit directives match a previously opened directive. Packages that need custom close-time behaviour (e.g. `b-ber-grammar-pullquote`) do not use this factory and implement their own renderer.
4
4
 
5
- ## Install
5
+ ## Usage
6
6
 
7
+ Imported by `b-ber-grammar-dialogue`, `b-ber-grammar-gallery`, `b-ber-grammar-section`, and `b-ber-grammar-spread`:
8
+
9
+ ```js
10
+ import createRenderer from '@canopycanopycanopy/b-ber-grammar-renderer'
11
+ // Returns a MarkdownIt container plugin config object
7
12
  ```
8
- $ npm i -g @canopycanopycanopy/b-ber-grammar-renderer
13
+
14
+ ## Dev
15
+
9
16
  ```
17
+ npm test
18
+ ```
19
+
20
+ Tests are in `__tests__/index.test.js`.
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ _Object$defineProperty(exports, "__esModule", {
8
8
  exports.default = void 0;
9
9
  var _trim = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/trim"));
10
10
  var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
11
- var _lodash = _interopRequireDefault(require("lodash.isundefined"));
11
+ var _isUndefined = _interopRequireDefault(require("lodash/isUndefined"));
12
12
  var _State = _interopRequireDefault(require("@canopycanopycanopy/b-ber-lib/State"));
13
13
  var _bBerLogger = _interopRequireDefault(require("@canopycanopycanopy/b-ber-logger"));
14
14
  var _bBerShapesDirectives = require("@canopycanopycanopy/b-ber-shapes-directives");
@@ -33,11 +33,11 @@ const renderer = ({
33
33
 
34
34
  // It's a directive - check to see if it's well-formed.
35
35
  const [, type, id] = match;
36
- if ((0, _lodash.default)(id)) {
36
+ if ((0, _isUndefined.default)(id)) {
37
37
  // The directive's missing an `id` attribute, so we extract the
38
38
  // fileName from `context` which we've stored in back in
39
39
  // `md/index.es6`, and passed into our `renderer`
40
- _bBerLogger.default.error(`Missing [id] for [${exports.default.name}:start] at ${context.fileName}.md:${line}`);
40
+ _bBerLogger.default.error(`Missing [id] for [${type}:start] at ${context.fileName}.md:${line}`);
41
41
 
42
42
  // Let the parser know that this wasn't a match
43
43
  return false;
@@ -73,5 +73,4 @@ const renderer = ({
73
73
  }
74
74
  }
75
75
  });
76
- var _default = renderer;
77
- exports.default = _default;
76
+ var _default = exports.default = renderer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canopycanopycanopy/b-ber-grammar-renderer",
3
- "version": "3.0.8-nav.0+24db1e6b",
3
+ "version": "3.0.8-next.61+2bbec564",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -25,12 +25,10 @@
25
25
  "rimraf": "^2.7.1"
26
26
  },
27
27
  "dependencies": {
28
- "@canopycanopycanopy/b-ber-lib": "3.0.8-nav.0+24db1e6b",
29
- "@canopycanopycanopy/b-ber-logger": "3.0.8-nav.0+24db1e6b",
30
- "@canopycanopycanopy/b-ber-shapes-directives": "3.0.8-nav.0+24db1e6b",
31
- "lodash": "^4.17.21",
32
- "lodash.isundefined": "^3.0.1",
33
- "tar": "^6.1.11"
28
+ "@canopycanopycanopy/b-ber-lib": "3.0.8-next.61+2bbec564",
29
+ "@canopycanopycanopy/b-ber-logger": "3.0.8-next.61+2bbec564",
30
+ "@canopycanopycanopy/b-ber-shapes-directives": "3.0.8-next.61+2bbec564",
31
+ "lodash": "^4.17.21"
34
32
  },
35
33
  "files": [
36
34
  "dist"
@@ -49,5 +47,5 @@
49
47
  "url": "https://maxwellsimmer.com"
50
48
  }
51
49
  ],
52
- "gitHead": "24db1e6bb491faae0d52c6dadc09d974a5a31cf5"
50
+ "gitHead": "2bbec5643278f53becb0d2ba1f55edfe379d5587"
53
51
  }