@canopycanopycanopy/b-ber-grammar-epigraph 3.0.8-next.61 → 3.0.8-next.97

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.
@@ -0,0 +1,21 @@
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
+ instance,
7
+ context
8
+ }: {
9
+ instance: any;
10
+ context?: {
11
+ fileName: string;
12
+ } | undefined;
13
+ }) => {
14
+ marker: string;
15
+ minMarkers: number;
16
+ validate(params: any): any;
17
+ render(tokens: any, idx: any): string;
18
+ };
19
+ };
20
+ export = _default;
21
+ //# 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,78 +1,84 @@
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 _bBerLogger = _interopRequireDefault(require("@canopycanopycanopy/b-ber-logger"));
12
- var _bBerParserFigure = _interopRequireDefault(require("@canopycanopycanopy/b-ber-parser-figure"));
13
- /* eslint-disable max-len */
14
- /*
15
-
16
- @type: epigraph
17
- @usage:
18
- + epigraph image "image.jpg"
19
-
20
- + epigraph caption "This is the first caption | This is the second caption" citation "first citation | second citation"
21
-
22
- @output: <section epub:type="epigraph" class="epigraph chapter"> ... </section>
23
-
24
- */
25
-
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_logger = require("@canopycanopycanopy/b-ber-logger");
24
+ _canopycanopycanopy_b_ber_logger = __toESM(_canopycanopycanopy_b_ber_logger);
25
+ let _canopycanopycanopy_b_ber_parser_figure = require("@canopycanopycanopy/b-ber-parser-figure");
26
+ _canopycanopycanopy_b_ber_parser_figure = __toESM(_canopycanopycanopy_b_ber_parser_figure);
27
+ //#region src/index.ts
26
28
  const markerRe = /^epigraph/;
27
29
  const attrsRe = /(?:(image|caption|citation)\s["]([^"]+)["])/g;
28
- var _default = exports.default = {
29
- plugin: _bBerParserFigure.default,
30
- name: 'epigraph',
31
- renderer: ({
32
- instance,
33
- context = {
34
- fileName: ''
35
- }
36
- }) => ({
37
- marker: ':',
38
- minMarkers: 3,
39
- validate(params) {
40
- return (0, _trim.default)(params).call(params).match(markerRe);
41
- },
42
- render(tokens, idx) {
43
- const {
44
- escapeHtml
45
- } = instance.escapeHtml;
46
- const attrs = {
47
- image: '',
48
- caption: '',
49
- citation: ''
50
- };
51
- let result = '';
52
- if (tokens[idx].nesting === 1) {
53
- // opening tag
54
- let matches;
55
- while ((matches = attrsRe.exec((0, _trim.default)(_context = tokens[idx].info).call(_context))) !== null) {
56
- var _context;
57
- // eslint-disable-next-line prefer-destructuring
58
- attrs[matches[1]] = matches[2];
59
- }
60
- if (!attrs.image && !attrs.caption) {
61
- _bBerLogger.default.error(`[${context.fileName}.md] <epigraph> Malformed directive.`);
62
- result = '';
63
- } else if (!attrs.image && attrs.caption) {
64
- var _context2, _context3;
65
- const captions = (0, _map.default)(_context2 = attrs.caption.split('|')).call(_context2, _ => (0, _trim.default)(_).call(_));
66
- const citations = (0, _map.default)(_context3 = attrs.citation.split('|')).call(_context3, _ => (0, _trim.default)(_).call(_));
67
- result = ['<section epub:type="epigraph" class="epigraph chapter">', '<section epub:type="chapter" class="subchapter">', (0, _map.default)(captions).call(captions, (caption, idx2) => `<div class="pullquote full-width">
30
+ var src_default = {
31
+ plugin: _canopycanopycanopy_b_ber_parser_figure.default,
32
+ name: "epigraph",
33
+ renderer: ({ instance, context = { fileName: "" } }) => ({
34
+ marker: ":",
35
+ minMarkers: 3,
36
+ validate(params) {
37
+ return params.trim().match(markerRe);
38
+ },
39
+ render(tokens, idx) {
40
+ const { escapeHtml } = instance.escapeHtml;
41
+ const attrs = {
42
+ image: "",
43
+ caption: "",
44
+ citation: ""
45
+ };
46
+ let result = "";
47
+ if (tokens[idx].nesting === 1) {
48
+ let matches;
49
+ while ((matches = attrsRe.exec(tokens[idx].info.trim())) !== null) attrs[matches[1]] = matches[2];
50
+ if (!attrs.image && !attrs.caption) {
51
+ _canopycanopycanopy_b_ber_logger.default.error(`[${context.fileName}.md] <epigraph> Malformed directive.`);
52
+ result = "";
53
+ } else if (!attrs.image && attrs.caption) {
54
+ const captions = attrs.caption.split("|").map((_) => _.trim());
55
+ const citations = attrs.citation.split("|").map((_) => _.trim());
56
+ result = [
57
+ "<section epub:type=\"epigraph\" class=\"epigraph chapter\">",
58
+ "<section epub:type=\"chapter\" class=\"subchapter\">",
59
+ captions.map((caption, idx2) => `<div class="pullquote full-width">
68
60
  <p>${escapeHtml(caption)}</p>
69
- ${citations[idx2] ? `<cite>&#x2014;${escapeHtml(citations[idx2])}</cite>` : ''}
70
- </div>`).join(''), '</section>', '</section>'].join('');
71
- } else {
72
- result = ['<section epub:type="epigraph" class="epigraph chapter">', '<div class="figure-lg" style="height: auto;">', '<figure style="height: auto;">', '<div class="figure__items" style="width: 100%; margin: 0 auto;">', `<img class="landscape" alt="${attrs.image}" src="../images/${escapeHtml(attrs.image)}" style="width: 100%; max-width: 100%; height: auto;"/>`, attrs.caption ? `<div class="figcaption" style="width: 100%; max-width: 100%; height: auto;"><p class="small">${escapeHtml(attrs.caption)}</p></div>` : '', '</div>', '</figure>', '</div>', '</section>'].join('');
73
- }
74
- }
75
- return result;
76
- }
77
- })
78
- };
61
+ ${citations[idx2] ? `<cite>&#x2014;${escapeHtml(citations[idx2])}</cite>` : ""}
62
+ </div>`).join(""),
63
+ "</section>",
64
+ "</section>"
65
+ ].join("");
66
+ } else result = [
67
+ "<section epub:type=\"epigraph\" class=\"epigraph chapter\">",
68
+ "<div class=\"figure-lg\" style=\"height: auto;\">",
69
+ "<figure style=\"height: auto;\">",
70
+ "<div class=\"figure__items\" style=\"width: 100%; margin: 0 auto;\">",
71
+ `<img class="landscape" alt="${attrs.image}" src="../images/${escapeHtml(attrs.image)}" style="width: 100%; max-width: 100%; height: auto;"/>`,
72
+ attrs.caption ? `<div class="figcaption" style="width: 100%; max-width: 100%; height: auto;"><p class="small">${escapeHtml(attrs.caption)}</p></div>` : "",
73
+ "</div>",
74
+ "</figure>",
75
+ "</div>",
76
+ "</section>"
77
+ ].join("");
78
+ }
79
+ return result;
80
+ }
81
+ })
82
+ };
83
+ //#endregion
84
+ module.exports = src_default;
package/package.json CHANGED
@@ -1,14 +1,11 @@
1
1
  {
2
2
  "name": "@canopycanopycanopy/b-ber-grammar-epigraph",
3
- "version": "3.0.8-next.61+2bbec564",
3
+ "version": "3.0.8-next.97+2e9748e6",
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,16 +14,16 @@
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-logger": "3.0.8-next.61+2bbec564",
29
- "@canopycanopycanopy/b-ber-parser-figure": "3.0.8-next.61+2bbec564",
25
+ "@canopycanopycanopy/b-ber-logger": "3.0.8-next.97+2e9748e6",
26
+ "@canopycanopycanopy/b-ber-parser-figure": "3.0.8-next.97+2e9748e6",
30
27
  "lodash": "^4.17.21",
31
28
  "tar": "^6.1.11"
32
29
  },
@@ -47,5 +44,6 @@
47
44
  "url": "https://maxwellsimmer.com"
48
45
  }
49
46
  ],
50
- "gitHead": "2bbec5643278f53becb0d2ba1f55edfe379d5587"
47
+ "gitHead": "2e9748e6f00446cd35dc8f933e049d8200fc24dd",
48
+ "types": "dist/index.d.ts"
51
49
  }