@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 CHANGED
@@ -1,9 +1,20 @@
1
- # `@canopycanopycanopy/b-ber-grammar-logo`
1
+ # b-ber-grammar-logo
2
2
 
3
- The `b-ber-grammar-logo` package renders b-ber's custom `logo` Markdown extension (directive) 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
+ 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
- ## Install
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
- $ npm i -g @canopycanopycanopy/b-ber-grammar-logo
13
+
14
+ ## Dev
15
+
9
16
  ```
17
+ npm test
18
+ ```
19
+
20
+ Tests are in `__tests__/index.test.js`.
@@ -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
- "use strict";
2
-
3
- var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
- var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
5
- _Object$defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
- var _trim = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/trim"));
10
- var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
11
- var _fsExtra = _interopRequireDefault(require("fs-extra"));
12
- var _State = _interopRequireDefault(require("@canopycanopycanopy/b-ber-lib/State"));
13
- var _bBerLogger = _interopRequireDefault(require("@canopycanopycanopy/b-ber-logger"));
14
- var _bBerShapesDirectives = require("@canopycanopycanopy/b-ber-shapes-directives");
15
- var _bBerParserFigure = _interopRequireDefault(require("@canopycanopycanopy/b-ber-parser-figure"));
16
- var _bBerGrammarAttributes = require("@canopycanopycanopy/b-ber-grammar-attributes");
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 _default = exports.default = {
20
- plugin: _bBerParserFigure.default,
21
- name: 'logo',
22
- renderer: ({
23
- context
24
- }) => ({
25
- marker: _bBerShapesDirectives.INLINE_DIRECTIVE_MARKER,
26
- minMarkers: _bBerShapesDirectives.INLINE_DIRECTIVE_MARKER_MIN_LENGTH,
27
- validate(params) {
28
- return (0, _trim.default)(params).call(params).match(MARKER_RE);
29
- },
30
- render(tokens, index) {
31
- var _context;
32
- const match = (0, _trim.default)(_context = tokens[index].info).call(_context).match(DIRECTIVE_RE);
33
- if (!match) return '';
34
- const fileName = `_markdown/${context.fileName}.md`;
35
- const lineNumber = (0, _map.default)(tokens[index]) ? (0, _map.default)(tokens[index])[0] : null;
36
- const [, type, id, attrs] = match;
37
- const attrsObj = (0, _bBerGrammarAttributes.attributesObject)(attrs, type, {
38
- fileName,
39
- lineNumber
40
- });
41
- if (!attrsObj.source) _bBerLogger.default.error('[source] attribute is required by [logo] directive, aborting');
42
- const inputImagePath = _State.default.src.images(attrsObj.source);
43
- const outputImagePath = `../images/${attrsObj.source}`;
44
- if (!_fsExtra.default.existsSync(inputImagePath)) _bBerLogger.default.warn(`Image [${attrsObj.source}] does not exist`);
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-nav-memo.2+63b04c68",
3
+ "version": "3.0.8-next.100+20b74691",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
7
- "prepare:dist": "BABEL_ENV=production babel --config-file ../../babel.config.js -d dist/ src/ --ignore **/__tests__/**",
8
- "clean": "rimraf dist",
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
- "@babel/cli": "^7.10.5",
21
- "@babel/core": "^7.10.5",
22
- "@babel/preset-env": "^7.10.4",
23
- "browserslist": "^4.17.4",
24
- "jest": "^26.6.3",
25
- "rimraf": "^2.7.1"
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-nav-memo.2+63b04c68",
29
- "@canopycanopycanopy/b-ber-lib": "3.0.8-nav-memo.2+63b04c68",
30
- "@canopycanopycanopy/b-ber-logger": "3.0.8-nav-memo.2+63b04c68",
31
- "@canopycanopycanopy/b-ber-parser-figure": "3.0.8-nav-memo.2+63b04c68",
32
- "@canopycanopycanopy/b-ber-shapes-directives": "3.0.8-nav-memo.2+63b04c68",
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": "63b04c68746dd40114a3718c6bef65710649a688"
51
+ "gitHead": "20b746918e81513be00a2f04971b00b296850f61",
52
+ "types": "dist/index.d.ts"
55
53
  }