@the_dissidents/libemmm 0.0.10 → 0.0.12

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.cjs CHANGED
@@ -3204,63 +3204,65 @@ var HTMLRenderState = class {
3204
3204
  });
3205
3205
  }
3206
3206
  render(elems, cxt) {
3207
- const document$1 = cxt.config.options.document;
3207
+ const document$1 = cxt.config.options.window.document;
3208
3208
  (0, minimal_jsx_runtime_jsx_runtime.useDocument)(document$1);
3209
3209
  let fragment = document$1.createDocumentFragment();
3210
3210
  elems.flatMap((x) => cxt.renderEntity(x)).flat().forEach((x) => fragment.appendChild(x));
3211
3211
  return fragment;
3212
3212
  }
3213
3213
  };
3214
- const htmlConfig = new RenderConfiguration({
3215
- document: globalThis.window.document,
3216
- headPlugins: [],
3217
- headerPlugins: [],
3218
- footerPlugins: [NotesFooterPlugin],
3219
- postprocessPlugins: [],
3220
- transformAsset: () => void 0
3221
- }, (results, cxt) => {
3222
- let styles = cxt.state.stylesheet.replaceAll(/var\(--(.*?)\)/g, (m, c) => cxt.state.cssVariables.get(c) ?? m);
3223
- let doc = document.implementation.createHTMLDocument(cxt.state.title);
3224
- doc.head.append(/* @__PURE__ */ (0, minimal_jsx_runtime_jsx_runtime.jsx)("meta", { charset: "UTF-8" }), /* @__PURE__ */ (0, minimal_jsx_runtime_jsx_runtime.jsx)("style", { children: styles }), ...cxt.config.options.headPlugins.map((x) => x(cxt)).filter((x) => x !== void 0).flat());
3225
- doc.body.append(/* @__PURE__ */ (0, minimal_jsx_runtime_jsx_runtime.jsx)("section", {
3226
- class: "article-container",
3227
- children: /* @__PURE__ */ (0, minimal_jsx_runtime_jsx_runtime.jsxs)("section", {
3228
- class: "article-body",
3229
- children: [
3230
- cxt.config.options.headerPlugins.map((x) => x(cxt)).filter((x) => x !== void 0),
3231
- results,
3232
- cxt.config.options.footerPlugins.map((x) => x(cxt)).filter((x) => x !== void 0)
3233
- ]
3234
- })
3235
- }));
3236
- for (const p of cxt.config.options.postprocessPlugins) p(cxt, doc);
3237
- return doc;
3238
- });
3239
- htmlConfig.paragraphRenderer = (node, cxt) => /* @__PURE__ */ (0, minimal_jsx_runtime_jsx_runtime.jsx)("p", { children: node.content.flatMap((x) => cxt.renderEntity(x)) });
3240
- htmlConfig.textRenderer = (node, cxt) => {
3241
- switch (node.type) {
3242
- case NodeType.Preformatted: return new Text(node.content.text);
3243
- case NodeType.Text:
3244
- case NodeType.Escaped:
3245
- const split = node.content.split("\n");
3246
- const result = [];
3247
- for (let i = 0; i < split.length; i++) {
3248
- result.push(new Text(split[i]));
3249
- if (i < split.length - 1) result.push(/* @__PURE__ */ (0, minimal_jsx_runtime_jsx_runtime.jsx)("br", {}));
3250
- }
3251
- return result;
3252
- default: return debug.never(node);
3253
- }
3254
- };
3255
- htmlConfig.undefinedBlockRenderer = (node, cxt) => {
3256
- return cxt.state.invalidBlock(node, `No renderer defined! for ${node.mod.name}`);
3257
- };
3258
- htmlConfig.undefinedInlineRenderer = (node, cxt) => {
3259
- return cxt.state.invalidInline(node, `No renderer defined! for ${node.mod.name}`);
3260
- };
3261
- htmlConfig.addBlockRenderer(...HeadingBlockRenderersHTML, ...BulletBlockRenderersHTML, CodeBlockRendererHTML, ...QuoteBlockRenderersHTML, ...MiscBlockRenderersHTML, ...NoteBlockRenderersHTML, ...TableBlockRenderers, GalleryBlockRendererHTML);
3262
- htmlConfig.addInlineRenderer(CodeInlineRendererHTML, ...InlineStyleRenderersHTML, ...MiscInlineRenderersHTML, ...NoteInlineRenderersHTML, ...TableInlineRenderers);
3263
- const HTMLRenderConfiguration = htmlConfig;
3214
+ function createHTMLRenderConfiguration(window) {
3215
+ const htmlConfig = new RenderConfiguration({
3216
+ window,
3217
+ headPlugins: [],
3218
+ headerPlugins: [],
3219
+ footerPlugins: [NotesFooterPlugin],
3220
+ postprocessPlugins: [],
3221
+ transformAsset: () => void 0
3222
+ }, (results, cxt) => {
3223
+ let styles = cxt.state.stylesheet.replaceAll(/var\(--(.*?)\)/g, (m, c) => cxt.state.cssVariables.get(c) ?? m);
3224
+ let doc = document.implementation.createHTMLDocument(cxt.state.title);
3225
+ doc.head.append(/* @__PURE__ */ (0, minimal_jsx_runtime_jsx_runtime.jsx)("meta", { charset: "UTF-8" }), /* @__PURE__ */ (0, minimal_jsx_runtime_jsx_runtime.jsx)("style", { children: styles }), ...cxt.config.options.headPlugins.map((x) => x(cxt)).filter((x) => x !== void 0).flat());
3226
+ doc.body.append(/* @__PURE__ */ (0, minimal_jsx_runtime_jsx_runtime.jsx)("section", {
3227
+ class: "article-container",
3228
+ children: /* @__PURE__ */ (0, minimal_jsx_runtime_jsx_runtime.jsxs)("section", {
3229
+ class: "article-body",
3230
+ children: [
3231
+ cxt.config.options.headerPlugins.map((x) => x(cxt)).filter((x) => x !== void 0),
3232
+ results,
3233
+ cxt.config.options.footerPlugins.map((x) => x(cxt)).filter((x) => x !== void 0)
3234
+ ]
3235
+ })
3236
+ }));
3237
+ for (const p of cxt.config.options.postprocessPlugins) p(cxt, doc);
3238
+ return doc;
3239
+ });
3240
+ htmlConfig.paragraphRenderer = (node, cxt) => /* @__PURE__ */ (0, minimal_jsx_runtime_jsx_runtime.jsx)("p", { children: node.content.flatMap((x) => cxt.renderEntity(x)) });
3241
+ htmlConfig.textRenderer = (node, cxt) => {
3242
+ switch (node.type) {
3243
+ case NodeType.Preformatted: return new Text(node.content.text);
3244
+ case NodeType.Text:
3245
+ case NodeType.Escaped:
3246
+ const split = node.content.split("\n");
3247
+ const result = [];
3248
+ for (let i = 0; i < split.length; i++) {
3249
+ result.push(new Text(split[i]));
3250
+ if (i < split.length - 1) result.push(/* @__PURE__ */ (0, minimal_jsx_runtime_jsx_runtime.jsx)("br", {}));
3251
+ }
3252
+ return result;
3253
+ default: return debug.never(node);
3254
+ }
3255
+ };
3256
+ htmlConfig.undefinedBlockRenderer = (node, cxt) => {
3257
+ return cxt.state.invalidBlock(node, `No renderer defined! for ${node.mod.name}`);
3258
+ };
3259
+ htmlConfig.undefinedInlineRenderer = (node, cxt) => {
3260
+ return cxt.state.invalidInline(node, `No renderer defined! for ${node.mod.name}`);
3261
+ };
3262
+ htmlConfig.addBlockRenderer(...HeadingBlockRenderersHTML, ...BulletBlockRenderersHTML, CodeBlockRendererHTML, ...QuoteBlockRenderersHTML, ...MiscBlockRenderersHTML, ...NoteBlockRenderersHTML, ...TableBlockRenderers, GalleryBlockRendererHTML);
3263
+ htmlConfig.addInlineRenderer(CodeInlineRendererHTML, ...InlineStyleRenderersHTML, ...MiscInlineRenderersHTML, ...NoteInlineRenderersHTML, ...TableInlineRenderers);
3264
+ return htmlConfig;
3265
+ }
3264
3266
 
3265
3267
  //#endregion
3266
3268
  //#region src/index.ts
@@ -3277,7 +3279,6 @@ exports.Configuration = Configuration;
3277
3279
  exports.DebugLevel = DebugLevel;
3278
3280
  exports.DefaultConfiguration = DefaultConfiguration;
3279
3281
  exports.Document = Document;
3280
- exports.HTMLRenderConfiguration = HTMLRenderConfiguration;
3281
3282
  exports.HTMLRenderState = HTMLRenderState;
3282
3283
  exports.InlineModifierDefinition = InlineModifierDefinition;
3283
3284
  exports.MessageSeverity = MessageSeverity;
@@ -3292,6 +3293,7 @@ exports.StringSource = StringSource;
3292
3293
  exports.SystemModifierDefinition = SystemModifierDefinition;
3293
3294
  exports.cloneNode = cloneNode;
3294
3295
  exports.cloneNodes = cloneNodes;
3296
+ exports.createHTMLRenderConfiguration = createHTMLRenderConfiguration;
3295
3297
  exports.debugPrint = debugPrint;
3296
3298
  exports.emmmVersion = emmmVersion;
3297
3299
  Object.defineProperty(exports, 'helper', {