@canopycanopycanopy/b-ber-grammar-logo 3.0.8-nav-memo.2 → 3.0.8-next.100
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.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +63 -48
- package/package.json +16 -18
package/README.md
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
|
-
#
|
|
1
|
+
# b-ber-grammar-logo
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Handles the `logo` inline directive. Emits a `<figure class="logo">` containing an `<img>` element with a fixed inline width of 120px. Requires a `source` attribute pointing to an image file in the project's `_images` directory; warns (but does not abort) if the file does not exist. The source path is converted to a relative `../images/` URL in the output HTML. 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 logo from '@canopycanopycanopy/b-ber-grammar-logo'
|
|
11
|
+
// { plugin, name: 'logo', 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.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/index.d.ts
|
|
2
|
+
declare const _default: {
|
|
3
|
+
plugin: (md: any, name: string, options?: any) => void;
|
|
4
|
+
name: string;
|
|
5
|
+
renderer: ({
|
|
6
|
+
context
|
|
7
|
+
}: {
|
|
8
|
+
context: any;
|
|
9
|
+
}) => {
|
|
10
|
+
marker: string;
|
|
11
|
+
minMarkers: number;
|
|
12
|
+
validate(params: any): any;
|
|
13
|
+
render(tokens: any, index: any): string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export = _default;
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":""}
|
package/dist/index.js
CHANGED
|
@@ -1,52 +1,67 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
//#endregion
|
|
23
|
+
let _canopycanopycanopy_b_ber_grammar_attributes = require("@canopycanopycanopy/b-ber-grammar-attributes");
|
|
24
|
+
let _canopycanopycanopy_b_ber_lib = require("@canopycanopycanopy/b-ber-lib");
|
|
25
|
+
let _canopycanopycanopy_b_ber_logger = require("@canopycanopycanopy/b-ber-logger");
|
|
26
|
+
_canopycanopycanopy_b_ber_logger = __toESM(_canopycanopycanopy_b_ber_logger);
|
|
27
|
+
let _canopycanopycanopy_b_ber_parser_figure = require("@canopycanopycanopy/b-ber-parser-figure");
|
|
28
|
+
_canopycanopycanopy_b_ber_parser_figure = __toESM(_canopycanopycanopy_b_ber_parser_figure);
|
|
29
|
+
let _canopycanopycanopy_b_ber_shapes_directives = require("@canopycanopycanopy/b-ber-shapes-directives");
|
|
30
|
+
let fs_extra = require("fs-extra");
|
|
31
|
+
fs_extra = __toESM(fs_extra);
|
|
32
|
+
//#region src/index.ts
|
|
17
33
|
const MARKER_RE = /^logo/;
|
|
18
34
|
const DIRECTIVE_RE = /(logo)(?::([^\s]+)(\s?.*)?)?$/;
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
delete attrsObj.source; // since we need the path relative to `images`
|
|
46
|
-
const attrString = (0, _bBerGrammarAttributes.attributesString)(attrsObj, type);
|
|
47
|
-
return `<figure id="${(0, _bBerGrammarAttributes.htmlId)(id)}" class="logo">
|
|
35
|
+
var src_default = {
|
|
36
|
+
plugin: _canopycanopycanopy_b_ber_parser_figure.default,
|
|
37
|
+
name: "logo",
|
|
38
|
+
renderer: ({ context }) => ({
|
|
39
|
+
marker: _canopycanopycanopy_b_ber_shapes_directives.INLINE_DIRECTIVE_MARKER,
|
|
40
|
+
minMarkers: _canopycanopycanopy_b_ber_shapes_directives.INLINE_DIRECTIVE_MARKER_MIN_LENGTH,
|
|
41
|
+
validate(params) {
|
|
42
|
+
return params.trim().match(MARKER_RE);
|
|
43
|
+
},
|
|
44
|
+
render(tokens, index) {
|
|
45
|
+
const match = tokens[index].info.trim().match(DIRECTIVE_RE);
|
|
46
|
+
if (!match) return "";
|
|
47
|
+
const fileName = `_markdown/${context.fileName}.md`;
|
|
48
|
+
const lineNumber = tokens[index].map ? tokens[index].map[0] : null;
|
|
49
|
+
const [, type, id, attrs] = match;
|
|
50
|
+
const attrsObj = (0, _canopycanopycanopy_b_ber_grammar_attributes.attributesObject)(attrs, type, {
|
|
51
|
+
fileName,
|
|
52
|
+
lineNumber
|
|
53
|
+
});
|
|
54
|
+
if (!attrsObj.source) _canopycanopycanopy_b_ber_logger.default.error("[source] attribute is required by [logo] directive, aborting");
|
|
55
|
+
const inputImagePath = _canopycanopycanopy_b_ber_lib.State.src.images(attrsObj.source);
|
|
56
|
+
const outputImagePath = `../images/${attrsObj.source}`;
|
|
57
|
+
if (!fs_extra.default.existsSync(inputImagePath)) _canopycanopycanopy_b_ber_logger.default.warn(`Image [${attrsObj.source}] does not exist`);
|
|
58
|
+
delete attrsObj.source;
|
|
59
|
+
const attrString = (0, _canopycanopycanopy_b_ber_grammar_attributes.attributesString)(attrsObj, type);
|
|
60
|
+
return `<figure id="${(0, _canopycanopycanopy_b_ber_grammar_attributes.htmlId)(id)}" class="logo">
|
|
48
61
|
<img style="width:120px;" src="${outputImagePath}" ${attrString}/>
|
|
49
62
|
</figure>`;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
};
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
};
|
|
66
|
+
//#endregion
|
|
67
|
+
module.exports = src_default;
|
package/package.json
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canopycanopycanopy/b-ber-grammar-logo",
|
|
3
|
-
"version": "3.0.8-
|
|
3
|
+
"version": "3.0.8-next.100+20b74691",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"prepare": "npm run clean && npm run prepare:dist",
|
|
10
|
-
"build": "npm run prepare",
|
|
11
|
-
"watch": "BABEL_ENV=production babel --config-file ../../babel.config.js -d dist/ src/ --watch src",
|
|
7
|
+
"build": "tsdown",
|
|
8
|
+
"typecheck": "tsc --noEmit",
|
|
12
9
|
"test": "jest"
|
|
13
10
|
},
|
|
14
11
|
"author": "Triple Canopy <b-ber@canopycanopycanopy.com> (https://triplecanopy.github.io/)",
|
|
@@ -17,19 +14,19 @@
|
|
|
17
14
|
"access": "public"
|
|
18
15
|
},
|
|
19
16
|
"devDependencies": {
|
|
20
|
-
"@
|
|
21
|
-
"@
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
17
|
+
"@swc/core": "^1.15.40",
|
|
18
|
+
"@swc/jest": "^0.2.39",
|
|
19
|
+
"jest": "^29.7.0",
|
|
20
|
+
"rimraf": "^2.7.1",
|
|
21
|
+
"tsdown": "^0.22.1",
|
|
22
|
+
"typescript": "^6.0.3"
|
|
26
23
|
},
|
|
27
24
|
"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-
|
|
25
|
+
"@canopycanopycanopy/b-ber-grammar-attributes": "3.0.8-next.100+20b74691",
|
|
26
|
+
"@canopycanopycanopy/b-ber-lib": "3.0.8-next.100+20b74691",
|
|
27
|
+
"@canopycanopycanopy/b-ber-logger": "3.0.8-next.100+20b74691",
|
|
28
|
+
"@canopycanopycanopy/b-ber-parser-figure": "3.0.8-next.100+20b74691",
|
|
29
|
+
"@canopycanopycanopy/b-ber-shapes-directives": "3.0.8-next.100+20b74691",
|
|
33
30
|
"fs-extra": "^8.1.0",
|
|
34
31
|
"lodash": "^4.17.21",
|
|
35
32
|
"tar": "^6.1.11"
|
|
@@ -51,5 +48,6 @@
|
|
|
51
48
|
"url": "https://maxwellsimmer.com"
|
|
52
49
|
}
|
|
53
50
|
],
|
|
54
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "20b746918e81513be00a2f04971b00b296850f61",
|
|
52
|
+
"types": "dist/index.d.ts"
|
|
55
53
|
}
|