@leadertechie/md2html 0.1.0-alpha.19 → 0.1.0-alpha.20

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 CHANGED
@@ -1,5 +1,4 @@
1
1
  import { LoggerInterface } from '@leadertechie/telemetry';
2
- import { TemplateResult } from 'lit';
3
2
 
4
3
  /**
5
4
  * Handles 'blockquote' tokens.
@@ -328,118 +327,6 @@ export declare class ListHandler implements TokenHandler {
328
327
  };
329
328
  }
330
329
 
331
- export declare class LitCodeStrategy implements LitNodeRendererStrategy {
332
- readonly type = "code";
333
- render(node: ContentNode, _renderChild: (child: ContentNode) => TemplateResult): TemplateResult;
334
- }
335
-
336
- export declare class LitContainerStrategy implements LitNodeRendererStrategy {
337
- readonly type = "container";
338
- render(node: ContentNode, renderChild: (child: ContentNode) => TemplateResult): TemplateResult;
339
- }
340
-
341
- export declare class LitEmphasisStrategy implements LitNodeRendererStrategy {
342
- readonly type = "emphasis";
343
- render(node: ContentNode, _renderChild: (child: ContentNode) => TemplateResult): TemplateResult;
344
- }
345
-
346
- export declare class LitFallbackStrategy implements LitNodeRendererStrategy {
347
- readonly type = "*";
348
- render(_node: ContentNode, _renderChild: (child: ContentNode) => TemplateResult): TemplateResult;
349
- }
350
-
351
- export declare class LitHeadingStrategy implements LitNodeRendererStrategy {
352
- readonly type = "heading";
353
- render(node: ContentNode, _renderChild: (child: ContentNode) => TemplateResult): TemplateResult;
354
- }
355
-
356
- export declare class LitImageStrategy implements LitNodeRendererStrategy {
357
- readonly type = "image";
358
- render(node: ContentNode, _renderChild: (child: ContentNode) => TemplateResult): TemplateResult;
359
- }
360
-
361
- export declare class LitLinkStrategy implements LitNodeRendererStrategy {
362
- readonly type = "link";
363
- render(node: ContentNode, _renderChild: (child: ContentNode) => TemplateResult): TemplateResult;
364
- }
365
-
366
- export declare class LitListItemStrategy implements LitNodeRendererStrategy {
367
- readonly type = "list-item";
368
- render(node: ContentNode, _renderChild: (child: ContentNode) => TemplateResult): TemplateResult;
369
- }
370
-
371
- export declare class LitListStrategy implements LitNodeRendererStrategy {
372
- readonly type = "list";
373
- render(node: ContentNode, renderChild: (child: ContentNode) => TemplateResult): TemplateResult;
374
- }
375
-
376
- export declare interface LitNodeRendererStrategy {
377
- /** The ContentNode type this strategy handles */
378
- readonly type: string;
379
- /** Render a node to a Lit TemplateResult */
380
- render(node: ContentNode, renderChild: (child: ContentNode) => TemplateResult): TemplateResult;
381
- }
382
-
383
- export declare class LitParagraphStrategy implements LitNodeRendererStrategy {
384
- readonly type = "paragraph";
385
- render(node: ContentNode, renderChild: (child: ContentNode) => TemplateResult): TemplateResult;
386
- }
387
-
388
- export declare class LitRenderer {
389
- private strategyRegistry;
390
- /** Lazily created HTMLRenderer for string output, sharing the same config */
391
- private htmlRenderer?;
392
- constructor();
393
- /** Access the strategy registry for customization. */
394
- get strategies(): LitStrategyRegistry;
395
- /**
396
- * Render a single node to a Lit TemplateResult.
397
- */
398
- renderNode(node: ContentNode): TemplateResult;
399
- /**
400
- * Render an array of nodes to a single Lit TemplateResult.
401
- */
402
- renderNodes(nodes: ContentNode[]): TemplateResult;
403
- /**
404
- * Render nodes to a plain HTML string.
405
- * Delegates to HTMLRenderer to avoid duplicating string rendering logic.
406
- *
407
- * Note: Uses default HTMLRenderer config (no classPrefix, scope anchors,
408
- * or heading IDs). For full HTML rendering with those features,
409
- * use HTMLRenderer directly.
410
- */
411
- renderToHTMLString(nodes: ContentNode[]): string;
412
- }
413
-
414
- /**
415
- * Registry of Lit renderer strategies.
416
- *
417
- * Two-tier lookup:
418
- * 1. Dedicated strategy by node type
419
- * 2. Fallback to a catch-all strategy (default: renders empty)
420
- */
421
- export declare class LitStrategyRegistry {
422
- private strategies;
423
- private fallback;
424
- constructor();
425
- register(strategy: LitNodeRendererStrategy): void;
426
- unregister(type: string): void;
427
- get(type: string): LitNodeRendererStrategy;
428
- has(type: string): boolean;
429
- get types(): string[];
430
- setFallback(strategy: LitNodeRendererStrategy): void;
431
- }
432
-
433
- export declare class LitStrongStrategy implements LitNodeRendererStrategy {
434
- readonly type = "strong";
435
- render(node: ContentNode, _renderChild: (child: ContentNode) => TemplateResult): TemplateResult;
436
- }
437
-
438
- export declare class LitTextStrategy implements LitNodeRendererStrategy {
439
- readonly type = "text";
440
- render(node: ContentNode, _renderChild: (child: ContentNode) => TemplateResult): TemplateResult;
441
- }
442
-
443
330
  export declare interface MarkdownContent {
444
331
  title: string;
445
332
  metadata?: Record<string, unknown>;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { d as defaultAllowedHTMLTags, H as HTMLRenderer } from "./lit-renderer-Bp1Q6wYL.js";
2
- import { L, a, b, c, e, f, g, h, i, j, k, l, m, n, R, o } from "./lit-renderer-Bp1Q6wYL.js";
1
+ import { d as defaultAllowedHTMLTags, H as HTMLRenderer } from "./renderer-Ba-j0YEq.js";
2
+ import { R, n } from "./renderer-Ba-j0YEq.js";
3
3
  import { marked } from "marked";
4
4
  class HeadingHandler {
5
5
  constructor() {
@@ -233,7 +233,7 @@ class ContainerBlockHandler {
233
233
  const classMatches = [...specifier.matchAll(/\.([\w-]+)/g)];
234
234
  const tag = tagMatch?.[1] || "div";
235
235
  const id = idMatch?.[1] || "";
236
- const classes = classMatches.map((m2) => m2[1]);
236
+ const classes = classMatches.map((m) => m[1]);
237
237
  const children = ctx.parseTokens(childTokens, 0);
238
238
  return {
239
239
  type: "container",
@@ -294,7 +294,7 @@ class TokenHandlerRegistry {
294
294
  return this.catchAll;
295
295
  }
296
296
  }
297
- var h2 = /* @__PURE__ */ ((t) => (t[t.DEBUG = 1] = "DEBUG", t[t.INFO = 9] = "INFO", t[t.WARN = 13] = "WARN", t[t.ERROR = 17] = "ERROR", t))(h2 || {});
297
+ var h = /* @__PURE__ */ ((t) => (t[t.DEBUG = 1] = "DEBUG", t[t.INFO = 9] = "INFO", t[t.WARN = 13] = "WARN", t[t.ERROR = 17] = "ERROR", t))(h || {});
298
298
  const S = {
299
299
  1: "DEBUG",
300
300
  9: "INFO",
@@ -306,60 +306,60 @@ const S = {
306
306
  "/telemetry/src/index.ts"
307
307
  ];
308
308
  function N() {
309
- const e2 = new Error().stack;
310
- if (!e2) return;
311
- const s = e2.split(`
309
+ const e = new Error().stack;
310
+ if (!e) return;
311
+ const s = e.split(`
312
312
  `);
313
313
  for (let r = 1; r < s.length; r++) {
314
- const o2 = s[r].trim(), n2 = $(o2);
314
+ const o = s[r].trim(), n2 = $(o);
315
315
  if (!n2) continue;
316
- const { file: l2 } = n2;
317
- if (!(l2 && E.some((m2) => l2.includes(m2))) && !(l2 && l2.includes("/node_modules/")) && l2)
316
+ const { file: l } = n2;
317
+ if (!(l && E.some((m) => l.includes(m))) && !(l && l.includes("/node_modules/")) && l)
318
318
  return n2;
319
319
  }
320
320
  }
321
321
  function $(t) {
322
- const e2 = t.match(
322
+ const e = t.match(
323
323
  /at\s+(?:(?:async\s+)?(?:(.+?)\s+\()?)?(?:(.+?):(\d+):(\d+)\)?)$/
324
324
  );
325
- if (!e2) return null;
326
- const s = e2[1] || "<anonymous>", r = e2[2], o2 = parseInt(e2[3], 10), n2 = parseInt(e2[4], 10);
327
- return r ? { file: r, line: o2, column: n2, functionName: s } : null;
325
+ if (!e) return null;
326
+ const s = e[1] || "<anonymous>", r = e[2], o = parseInt(e[3], 10), n2 = parseInt(e[4], 10);
327
+ return r ? { file: r, line: o, column: n2, functionName: s } : null;
328
328
  }
329
- class g2 {
330
- constructor(e2 = [], s, r = {}) {
331
- this.processors = [...e2], this.resource = s ?? { serviceName: "unknown" }, this.baseAttributes = { ...r };
329
+ class g {
330
+ constructor(e = [], s, r = {}) {
331
+ this.processors = [...e], this.resource = s ?? { serviceName: "unknown" }, this.baseAttributes = { ...r };
332
332
  }
333
333
  // ── Public API ───────────────────────────────────────────────────────────
334
- debug(e2, s) {
335
- this.emit(h2.DEBUG, e2, void 0, s);
334
+ debug(e, s) {
335
+ this.emit(h.DEBUG, e, void 0, s);
336
336
  }
337
- info(e2, s) {
338
- this.emit(h2.INFO, e2, void 0, s);
337
+ info(e, s) {
338
+ this.emit(h.INFO, e, void 0, s);
339
339
  }
340
- warn(e2, s) {
341
- this.emit(h2.WARN, e2, void 0, s);
340
+ warn(e, s) {
341
+ this.emit(h.WARN, e, void 0, s);
342
342
  }
343
- error(e2, s, r) {
344
- this.emit(h2.ERROR, e2, s, r);
343
+ error(e, s, r) {
344
+ this.emit(h.ERROR, e, s, r);
345
345
  }
346
346
  /**
347
347
  * Create a child logger with merged base attributes.
348
348
  * Returns a NEW Logger — original is immutable.
349
349
  */
350
- withContext(e2) {
351
- return new g2(this.processors, this.resource, {
350
+ withContext(e) {
351
+ return new g(this.processors, this.resource, {
352
352
  ...this.baseAttributes,
353
- ...e2
353
+ ...e
354
354
  });
355
355
  }
356
356
  /**
357
357
  * Append a processor to the pipeline.
358
358
  * Returns a NEW Logger — original is immutable.
359
359
  */
360
- withProcessor(e2) {
361
- return new g2(
362
- [...this.processors, e2],
360
+ withProcessor(e) {
361
+ return new g(
362
+ [...this.processors, e],
363
363
  this.resource,
364
364
  this.baseAttributes
365
365
  );
@@ -369,45 +369,45 @@ class g2 {
369
369
  * Await before the end of a CF Worker request (inside ctx.waitUntil).
370
370
  */
371
371
  async flush() {
372
- await Promise.all(this.processors.map((e2) => e2.forceFlush()));
372
+ await Promise.all(this.processors.map((e) => e.forceFlush()));
373
373
  }
374
374
  /**
375
375
  * Shutdown: flush + release resources. No logging after shutdown.
376
376
  */
377
377
  async shutdown() {
378
- await this.flush(), await Promise.all(this.processors.map((e2) => e2.shutdown()));
378
+ await this.flush(), await Promise.all(this.processors.map((e) => e.shutdown()));
379
379
  }
380
380
  // ── Internal ────────────────────────────────────────────────────────────
381
- emit(e2, s, r, o2) {
381
+ emit(e, s, r, o) {
382
382
  if (this.processors.length === 0) return;
383
- const n2 = (/* @__PURE__ */ new Date()).toISOString(), l2 = {
384
- severityNumber: e2,
385
- severityText: S[e2],
383
+ const n2 = (/* @__PURE__ */ new Date()).toISOString(), l = {
384
+ severityNumber: e,
385
+ severityText: S[e],
386
386
  body: s,
387
387
  timestamp: n2,
388
388
  observedTimestamp: n2,
389
- attributes: { ...this.baseAttributes, ...o2 },
389
+ attributes: { ...this.baseAttributes, ...o },
390
390
  caller: N(),
391
391
  ...r ? { error: r } : {},
392
392
  resource: { ...this.resource }
393
393
  };
394
- for (const m2 of this.processors)
394
+ for (const m of this.processors)
395
395
  try {
396
- m2.onEmit(l2);
397
- } catch (f2) {
396
+ m.onEmit(l);
397
+ } catch (f) {
398
398
  console.error(
399
399
  "[telemetry] Processor threw in onEmit:",
400
- f2
400
+ f
401
401
  );
402
402
  }
403
403
  }
404
404
  }
405
405
  class T {
406
- constructor(e2) {
407
- this.shutdownFlag = false, this.pendingExport = Promise.resolve(), this.adapter = e2;
406
+ constructor(e) {
407
+ this.shutdownFlag = false, this.pendingExport = Promise.resolve(), this.adapter = e;
408
408
  }
409
- onEmit(e2) {
410
- this.shutdownFlag || (this.pendingExport = this.pendingExport.then(() => this.adapter.export([e2])).catch((s) => {
409
+ onEmit(e) {
410
+ this.shutdownFlag || (this.pendingExport = this.pendingExport.then(() => this.adapter.export([e])).catch((s) => {
411
411
  console.error(
412
412
  `[telemetry] SimpleLogProcessor: adapter "${this.adapter.name}" export failed:`,
413
413
  s
@@ -422,73 +422,73 @@ class T {
422
422
  }
423
423
  }
424
424
  class M {
425
- constructor(e2) {
425
+ constructor(e) {
426
426
  this.processors = [], this.resource = {
427
- serviceName: e2?.serviceName ?? "unknown",
428
- environment: e2?.environment,
429
- version: e2?.version,
430
- processName: e2?.processName
427
+ serviceName: e?.serviceName ?? "unknown",
428
+ environment: e?.environment,
429
+ version: e?.version,
430
+ processName: e?.processName
431
431
  };
432
432
  }
433
433
  /**
434
434
  * Register an adapter via a SimpleLogProcessor (immediate export).
435
435
  * For batching, use addProcessor(new BatchLogProcessor(adapter, opts)).
436
436
  */
437
- addAdapter(e2) {
438
- return this.addProcessor(new T(e2));
437
+ addAdapter(e) {
438
+ return this.addProcessor(new T(e));
439
439
  }
440
440
  /**
441
441
  * Register a custom processor (SimpleLogProcessor, BatchLogProcessor,
442
442
  * or your own implementation).
443
443
  */
444
- addProcessor(e2) {
445
- return this.processors.push(e2), this;
444
+ addProcessor(e) {
445
+ return this.processors.push(e), this;
446
446
  }
447
447
  /**
448
448
  * Get a named Logger instance.
449
449
  * The logger inherits the provider's resource and processors.
450
450
  * Optionally provide initial context attributes.
451
451
  */
452
- getLogger(e2, s) {
452
+ getLogger(e, s) {
453
453
  const r = {
454
454
  ...this.resource,
455
- ...e2 ? { processName: e2 } : {}
455
+ ...e ? { processName: e } : {}
456
456
  };
457
- return new g2(this.processors, r, s);
457
+ return new g(this.processors, r, s);
458
458
  }
459
459
  /**
460
460
  * Force-flush all registered processors.
461
461
  */
462
462
  async flush() {
463
- await Promise.all(this.processors.map((e2) => e2.forceFlush()));
463
+ await Promise.all(this.processors.map((e) => e.forceFlush()));
464
464
  }
465
465
  /**
466
466
  * Shutdown: flush + release all processor resources.
467
467
  */
468
468
  async shutdown() {
469
- await this.flush(), await Promise.all(this.processors.map((e2) => e2.shutdown()));
469
+ await this.flush(), await Promise.all(this.processors.map((e) => e.shutdown()));
470
470
  }
471
471
  }
472
472
  function U(t) {
473
- const e2 = t?.level ?? h2.DEBUG, s = t?.json ?? false;
473
+ const e = t?.level ?? h.DEBUG, s = t?.json ?? false;
474
474
  return {
475
475
  name: "console",
476
476
  async export(r) {
477
- for (const o2 of r)
478
- o2.severityNumber < e2 || (s ? I(o2) : R2(o2));
477
+ for (const o of r)
478
+ o.severityNumber < e || (s ? I(o) : R2(o));
479
479
  }
480
480
  };
481
481
  }
482
482
  function R2(t) {
483
- const e2 = F(t.severityNumber), s = t.timestamp, r = t.severityText, o2 = t.caller ? ` (${t.caller.file}:${t.caller.line})` : "", n2 = Object.keys(t.attributes).length > 0;
484
- !!t.error ? e2(
485
- `[${s}] [${r}]${o2} ${t.body}`,
483
+ const e = F(t.severityNumber), s = t.timestamp, r = t.severityText, o = t.caller ? ` (${t.caller.file}:${t.caller.line})` : "", n2 = Object.keys(t.attributes).length > 0;
484
+ !!t.error ? e(
485
+ `[${s}] [${r}]${o} ${t.body}`,
486
486
  t.attributes,
487
487
  t.error
488
- ) : n2 ? e2(`[${s}] [${r}]${o2} ${t.body}`, t.attributes) : e2(`[${s}] [${r}]${o2} ${t.body}`);
488
+ ) : n2 ? e(`[${s}] [${r}]${o} ${t.body}`, t.attributes) : e(`[${s}] [${r}]${o} ${t.body}`);
489
489
  }
490
490
  function I(t) {
491
- const e2 = {
491
+ const e = {
492
492
  timestamp: t.timestamp,
493
493
  level: t.severityText,
494
494
  message: t.body,
@@ -497,21 +497,21 @@ function I(t) {
497
497
  attributes: t.attributes,
498
498
  caller: t.caller
499
499
  };
500
- t.error && (e2.error = {
500
+ t.error && (e.error = {
501
501
  name: t.error.name,
502
502
  message: t.error.message,
503
503
  stack: t.error.stack
504
- }), console.log(JSON.stringify(e2));
504
+ }), console.log(JSON.stringify(e));
505
505
  }
506
506
  function F(t) {
507
507
  switch (t) {
508
- case h2.ERROR:
508
+ case h.ERROR:
509
509
  return console.error.bind(console);
510
- case h2.WARN:
510
+ case h.WARN:
511
511
  return console.warn.bind(console);
512
- case h2.INFO:
512
+ case h.INFO:
513
513
  return console.log.bind(console);
514
- case h2.DEBUG:
514
+ case h.DEBUG:
515
515
  default:
516
516
  return console.debug.bind(console);
517
517
  }
@@ -521,7 +521,7 @@ function getDefaultLogger(serviceName) {
521
521
  let log = defaultLoggers.get(serviceName);
522
522
  if (!log) {
523
523
  const provider = new M({ serviceName });
524
- provider.addAdapter(U({ level: h2.WARN }));
524
+ provider.addAdapter(U({ level: h.WARN }));
525
525
  log = provider.getLogger();
526
526
  defaultLoggers.set(serviceName, log);
527
527
  }
@@ -1096,20 +1096,6 @@ export {
1096
1096
  ImageHandler,
1097
1097
  LinkHandler,
1098
1098
  ListHandler,
1099
- L as LitCodeStrategy,
1100
- a as LitContainerStrategy,
1101
- b as LitEmphasisStrategy,
1102
- c as LitFallbackStrategy,
1103
- e as LitHeadingStrategy,
1104
- f as LitImageStrategy,
1105
- g as LitLinkStrategy,
1106
- h as LitListItemStrategy,
1107
- i as LitListStrategy,
1108
- j as LitParagraphStrategy,
1109
- k as LitRenderer,
1110
- l as LitStrategyRegistry,
1111
- m as LitStrongStrategy,
1112
- n as LitTextStrategy,
1113
1099
  MarkdownParser,
1114
1100
  MarkdownPipeline,
1115
1101
  NodeFactory,
@@ -1124,7 +1110,7 @@ export {
1124
1110
  createDefaultPreprocessor,
1125
1111
  createParseContext,
1126
1112
  defaultAllowedHTMLTags,
1127
- o as nodeTypeToScope,
1113
+ n as nodeTypeToScope,
1128
1114
  walkTree
1129
1115
  };
1130
1116
  //# sourceMappingURL=index.js.map