@canopycanopycanopy/b-ber-grammar-image 3.0.8-nav-memo.2 → 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 +15 -4
- package/dist/index.js +4 -2
- package/package.json +9 -11
package/README.md
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
|
-
#
|
|
1
|
+
# b-ber-grammar-image
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Handles the `figure` and `figure-inline` custom Markdown directives for single image embeds. The `figure` form reads the image file from disk (using `image-size` to get dimensions), registers a figure entry in global state (for List of Illustrations generation), and emits a small linked thumbnail `<div>` with a `<figure>` pointing to the generated figure page. The `figure-inline` form emits a full inline figure using the `b-ber-templates` figure template, which renders the image at its natural or classified orientation (portrait/landscape) with an optional caption. Both forms require `id` and `source` attributes. Uses `b-ber-parser-figure` as the MarkdownIt plugin.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Usage
|
|
6
6
|
|
|
7
|
+
Registered as a MarkdownIt plugin by the rendering engine:
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
import image from '@canopycanopycanopy/b-ber-grammar-image'
|
|
11
|
+
// { plugin, name: 'figure', renderer }
|
|
7
12
|
```
|
|
8
|
-
|
|
13
|
+
|
|
14
|
+
## Dev
|
|
15
|
+
|
|
9
16
|
```
|
|
17
|
+
npm test
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Tests are in `__tests__/index.test.js`.
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ var _trim = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stabl
|
|
|
11
11
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
|
12
12
|
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
13
13
|
var _imageSize = _interopRequireDefault(require("image-size"));
|
|
14
|
-
var
|
|
14
|
+
var _isUndefined = _interopRequireDefault(require("lodash/isUndefined"));
|
|
15
15
|
var _bBerLogger = _interopRequireDefault(require("@canopycanopycanopy/b-ber-logger"));
|
|
16
16
|
var _bBerLib = require("@canopycanopycanopy/b-ber-lib");
|
|
17
17
|
var _State = _interopRequireDefault(require("@canopycanopycanopy/b-ber-lib/State"));
|
|
@@ -19,6 +19,8 @@ var _bBerShapesDirectives = require("@canopycanopycanopy/b-ber-shapes-directives
|
|
|
19
19
|
var _bBerGrammarAttributes = require("@canopycanopycanopy/b-ber-grammar-attributes");
|
|
20
20
|
var _bBerParserFigure = _interopRequireDefault(require("@canopycanopycanopy/b-ber-parser-figure"));
|
|
21
21
|
var _image = require("./image");
|
|
22
|
+
// eslint-disable-line import/no-unresolved
|
|
23
|
+
|
|
22
24
|
const MARKER_OPEN_RE = /(figure(?:-inline)?)(?::([^\s]+)(\s?.*)?)?$/;
|
|
23
25
|
function prepare({
|
|
24
26
|
token,
|
|
@@ -67,7 +69,7 @@ const validate = ({
|
|
|
67
69
|
const match = (0, _trim.default)(params).call(params).match(MARKER_OPEN_RE);
|
|
68
70
|
if (!match) return false;
|
|
69
71
|
const [,, id, source] = match;
|
|
70
|
-
if ((0,
|
|
72
|
+
if ((0, _isUndefined.default)(id) || (0, _isUndefined.default)(source)) {
|
|
71
73
|
// Images require `id` and `source`
|
|
72
74
|
_bBerLogger.default.error(`Missing [id] or [source] attribute for [figure] directive${context.fileName}.md:${line}`);
|
|
73
75
|
return false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canopycanopycanopy/b-ber-grammar-image",
|
|
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,18 +25,16 @@
|
|
|
25
25
|
"rimraf": "^2.7.1"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@canopycanopycanopy/b-ber-grammar-attributes": "3.0.8-
|
|
29
|
-
"@canopycanopycanopy/b-ber-lib": "3.0.8-
|
|
30
|
-
"@canopycanopycanopy/b-ber-logger": "3.0.8-
|
|
31
|
-
"@canopycanopycanopy/b-ber-parser-figure": "3.0.8-
|
|
32
|
-
"@canopycanopycanopy/b-ber-shapes-directives": "3.0.8-
|
|
33
|
-
"@canopycanopycanopy/b-ber-templates": "3.0.8-
|
|
28
|
+
"@canopycanopycanopy/b-ber-grammar-attributes": "3.0.8-next.61+2bbec564",
|
|
29
|
+
"@canopycanopycanopy/b-ber-lib": "3.0.8-next.61+2bbec564",
|
|
30
|
+
"@canopycanopycanopy/b-ber-logger": "3.0.8-next.61+2bbec564",
|
|
31
|
+
"@canopycanopycanopy/b-ber-parser-figure": "3.0.8-next.61+2bbec564",
|
|
32
|
+
"@canopycanopycanopy/b-ber-shapes-directives": "3.0.8-next.61+2bbec564",
|
|
33
|
+
"@canopycanopycanopy/b-ber-templates": "3.0.8-next.61+2bbec564",
|
|
34
34
|
"fs-extra": "^8.1.0",
|
|
35
35
|
"image-size": "^0.8.3",
|
|
36
36
|
"lodash": "^4.17.21",
|
|
37
|
-
"
|
|
38
|
-
"mime-types": "^2.1.24",
|
|
39
|
-
"tar": "^6.1.11"
|
|
37
|
+
"mime-types": "^2.1.24"
|
|
40
38
|
},
|
|
41
39
|
"files": [
|
|
42
40
|
"dist"
|
|
@@ -55,5 +53,5 @@
|
|
|
55
53
|
"url": "https://maxwellsimmer.com"
|
|
56
54
|
}
|
|
57
55
|
],
|
|
58
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "2bbec5643278f53becb0d2ba1f55edfe379d5587"
|
|
59
57
|
}
|