nizel-plugin-details 0.1.0

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 ADDED
@@ -0,0 +1,3 @@
1
+ # nizel-plugin-details
2
+
3
+ Adds `:::details Summary` disclosure blocks. The browser build exposes `NizelDetails` from `dist/details.iife.js`.
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var NizelDetails = (() => {
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/index.ts
22
+ var index_exports = {};
23
+ __export(index_exports, {
24
+ default: () => index_default,
25
+ detailsPlugin: () => detailsPlugin,
26
+ transformDetails: () => transformDetails
27
+ });
28
+ var detailsPlugin = (options = {}) => ({
29
+ name: "details",
30
+ blocks: {
31
+ details: detailsBlock(options)
32
+ },
33
+ hooks: {
34
+ beforeParse: transformDetails
35
+ }
36
+ });
37
+ var transformDetails = (markdown) => {
38
+ return markdown.replace(/^:::details\s*(.*?)\s*$/gm, (_match, summary) => `::details ${summary || "Details"}`).replace(/^:::\s*$/gm, "::");
39
+ };
40
+ var detailsBlock = (options) => ({
41
+ name: "details",
42
+ parse({ args }) {
43
+ return { summary: args.join(" ") || "Details" };
44
+ },
45
+ formats: {
46
+ html(node, ctx) {
47
+ if (node.type !== "customBlock") return "";
48
+ const summary = node.value?.summary ?? "Details";
49
+ return `<details class="${ctx.escape(options.className ?? "details")}"><summary>${ctx.escape(summary)}</summary>${ctx.render(node.children ?? [])}</details>`;
50
+ }
51
+ }
52
+ });
53
+ var index_default = detailsPlugin;
54
+ return __toCommonJS(index_exports);
55
+ })();
@@ -0,0 +1,8 @@
1
+ import type { NizelPlugin } from 'nizel';
2
+ export type DetailsPluginOptions = {
3
+ className?: string;
4
+ };
5
+ export declare const detailsPlugin: (options?: DetailsPluginOptions) => NizelPlugin;
6
+ export declare const transformDetails: (markdown: string) => string;
7
+ export default detailsPlugin;
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAwB,WAAW,EAAE,MAAM,OAAO,CAAC;AAE/D,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,UAAS,oBAAyB,KAAG,WAQjE,CAAC;AAEH,eAAO,MAAM,gBAAgB,GAAI,UAAU,MAAM,KAAG,MAInD,CAAC;AAgBF,eAAe,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,30 @@
1
+ export const detailsPlugin = (options = {}) => ({
2
+ name: 'details',
3
+ blocks: {
4
+ details: detailsBlock(options),
5
+ },
6
+ hooks: {
7
+ beforeParse: transformDetails,
8
+ },
9
+ });
10
+ export const transformDetails = (markdown) => {
11
+ return markdown
12
+ .replace(/^:::details\s*(.*?)\s*$/gm, (_match, summary) => `::details ${summary || 'Details'}`)
13
+ .replace(/^:::\s*$/gm, '::');
14
+ };
15
+ const detailsBlock = (options) => ({
16
+ name: 'details',
17
+ parse({ args }) {
18
+ return { summary: args.join(' ') || 'Details' };
19
+ },
20
+ formats: {
21
+ html(node, ctx) {
22
+ if (node.type !== 'customBlock')
23
+ return '';
24
+ const summary = node.value?.summary ?? 'Details';
25
+ return `<details class="${ctx.escape(options.className ?? 'details')}"><summary>${ctx.escape(summary)}</summary>${ctx.render(node.children ?? [])}</details>`;
26
+ },
27
+ },
28
+ });
29
+ export default detailsPlugin;
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,UAAgC,EAAE,EAAe,EAAE,CAAC,CAAC;IACjF,IAAI,EAAE,SAAS;IACf,MAAM,EAAE;QACN,OAAO,EAAE,YAAY,CAAC,OAAO,CAAC;KAC/B;IACD,KAAK,EAAE;QACL,WAAW,EAAE,gBAAgB;KAC9B;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,QAAgB,EAAU,EAAE;IAC3D,OAAO,QAAQ;SACZ,OAAO,CAAC,2BAA2B,EAAE,CAAC,MAAM,EAAE,OAAe,EAAE,EAAE,CAAC,aAAa,OAAO,IAAI,SAAS,EAAE,CAAC;SACtG,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;AACjC,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,OAA6B,EAAwB,EAAE,CAAC,CAAC;IAC7E,IAAI,EAAE,SAAS;IACf,KAAK,CAAC,EAAE,IAAI,EAAE;QACZ,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,SAAS,EAAE,CAAC;IAClD,CAAC;IACD,OAAO,EAAE;QACP,IAAI,CAAC,IAAI,EAAE,GAAG;YACZ,IAAI,IAAI,CAAC,IAAI,KAAK,aAAa;gBAAE,OAAO,EAAE,CAAC;YAC3C,MAAM,OAAO,GAAI,IAAI,CAAC,KAA0C,EAAE,OAAO,IAAI,SAAS,CAAC;YACvF,OAAO,mBAAmB,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,IAAI,SAAS,CAAC,cAAc,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC,YAAY,CAAC;QAChK,CAAC;KACF;CACF,CAAC,CAAC;AAEH,eAAe,aAAa,CAAC"}
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "nizel-plugin-details",
3
+ "version": "0.1.0",
4
+ "description": "Details disclosure block plugin for Nizel.",
5
+ "repository": { "type": "git", "url": "https://github.com/silvandiepen/nizel" },
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" },
11
+ "./browser": { "types": "./dist/index.d.ts", "import": "./dist/index.js" }
12
+ },
13
+ "files": ["dist", "README.md"],
14
+ "scripts": {
15
+ "build": "tsc -p tsconfig.json && npm run build:browser",
16
+ "build:browser": "esbuild src/index.ts --bundle --platform=browser --format=iife --global-name=NizelDetails --target=safari14 --outfile=dist/details.iife.js",
17
+ "typecheck": "tsc -p tsconfig.json --noEmit",
18
+ "test": "npm run build && vitest run test/*.mjs"
19
+ },
20
+ "peerDependencies": { "nizel": "^0.1.0" },
21
+ "devDependencies": { "esbuild": "^0.27.3" },
22
+ "publishConfig": { "access": "public", "provenance": true }
23
+ }