@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.
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +81 -75
- package/package.json +13 -15
package/dist/index.d.ts
ADDED
|
@@ -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
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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>—${escapeHtml(citations[idx2])}</cite>` :
|
|
70
|
-
</div>`).join(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
61
|
+
${citations[idx2] ? `<cite>—${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.
|
|
3
|
+
"version": "3.0.8-next.97+2e9748e6",
|
|
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,16 +14,16 @@
|
|
|
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-logger": "3.0.8-next.
|
|
29
|
-
"@canopycanopycanopy/b-ber-parser-figure": "3.0.8-next.
|
|
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": "
|
|
47
|
+
"gitHead": "2e9748e6f00446cd35dc8f933e049d8200fc24dd",
|
|
48
|
+
"types": "dist/index.d.ts"
|
|
51
49
|
}
|