@canopycanopycanopy/b-ber-parser-figure 3.0.8-nav-memo.4 → 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 +18 -4
- package/dist/index.js +3 -3
- package/package.json +7 -9
package/README.md
CHANGED
|
@@ -1,9 +1,23 @@
|
|
|
1
|
-
#
|
|
1
|
+
# b-ber-parser-figure
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A markdown-it block-container plugin that parses b-ber `figure` directives into HTML. It recognises colon-fenced blocks (`:::`) with the name `figure` and emits `container_figure_open` / `container_figure_close` tokens. The plugin handles optional inline captions delimited by `::` on the line immediately following the directive open, slicing the caption body out of the source and attaching it to the open token's `children` property so the `render` callback can produce a `<figure>` / `<figcaption>` structure.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Usage
|
|
6
6
|
|
|
7
|
+
This plugin is registered on a markdown-it instance by the b-ber build pipeline. A higher-level directive handler supplies `validate` and `render` callbacks:
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
import figurePlugin from '@canopycanopycanopy/b-ber-parser-figure'
|
|
11
|
+
|
|
12
|
+
md.use(figurePlugin, 'figure', { validate, render })
|
|
7
13
|
```
|
|
8
|
-
|
|
14
|
+
|
|
15
|
+
The plugin is consumed during the `render` build step. The render callback is responsible for producing the final `<figure>` HTML including image, video, or audio elements and any caption.
|
|
16
|
+
|
|
17
|
+
## Dev
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
npm test
|
|
9
21
|
```
|
|
22
|
+
|
|
23
|
+
The test suite currently contains only a `test.todo` placeholder — no assertions are implemented yet.
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
|
|
10
10
|
var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
|
|
11
|
-
var
|
|
11
|
+
var _isUndefined = _interopRequireDefault(require("lodash/isUndefined"));
|
|
12
12
|
/* eslint-disable no-param-reassign */
|
|
13
13
|
|
|
14
14
|
const figurePlugin = (md, name, options = {}) => {
|
|
@@ -90,9 +90,9 @@ const figurePlugin = (md, name, options = {}) => {
|
|
|
90
90
|
|
|
91
91
|
// two markers on the next line mean that there's a caption
|
|
92
92
|
if (_currChar === markerChar && _nextChar === markerChar) {
|
|
93
|
-
if ((0,
|
|
93
|
+
if ((0, _isUndefined.default)(_capStartPos)) {
|
|
94
94
|
_capStartPos = _cursor + _capMarkerLen; // state the start index
|
|
95
|
-
} else if (!(0,
|
|
95
|
+
} else if (!(0, _isUndefined.default)(_capStartPos)) {
|
|
96
96
|
// a caption is being captured, so we know we're still in the
|
|
97
97
|
// opening image marker
|
|
98
98
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canopycanopycanopy/b-ber-parser-figure",
|
|
3
|
-
"version": "3.0.8-
|
|
3
|
+
"version": "3.0.8-next.61+2bbec564",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -25,13 +25,11 @@
|
|
|
25
25
|
"rimraf": "^2.7.1"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@canopycanopycanopy/b-ber-lib": "3.0.8-
|
|
29
|
-
"@canopycanopycanopy/b-ber-logger": "3.0.8-
|
|
30
|
-
"@canopycanopycanopy/b-ber-shapes-directives": "3.0.8-
|
|
31
|
-
"@canopycanopycanopy/b-ber-templates": "3.0.8-
|
|
32
|
-
"lodash": "^4.17.21"
|
|
33
|
-
"lodash.isundefined": "^3.0.1",
|
|
34
|
-
"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
|
+
"@canopycanopycanopy/b-ber-templates": "3.0.8-next.61+2bbec564",
|
|
32
|
+
"lodash": "^4.17.21"
|
|
35
33
|
},
|
|
36
34
|
"files": [
|
|
37
35
|
"dist"
|
|
@@ -50,5 +48,5 @@
|
|
|
50
48
|
"url": "https://maxwellsimmer.com"
|
|
51
49
|
}
|
|
52
50
|
],
|
|
53
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "2bbec5643278f53becb0d2ba1f55edfe379d5587"
|
|
54
52
|
}
|