text-doc-ir 0.2.0 → 0.3.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.
Files changed (2) hide show
  1. package/dist/index.js +33 -26
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1,33 +1,33 @@
1
1
  var w = Object.defineProperty;
2
- var B = (C, m, t) => m in C ? w(C, m, { enumerable: !0, configurable: !0, writable: !0, value: t }) : C[m] = t;
3
- var y = (C, m, t) => B(C, typeof m != "symbol" ? m + "" : m, t);
2
+ var B = (y, m, t) => m in y ? w(y, m, { enumerable: !0, configurable: !0, writable: !0, value: t }) : y[m] = t;
3
+ var C = (y, m, t) => B(y, typeof m != "symbol" ? m + "" : m, t);
4
4
  import { NodeVisitor as b } from "document-ir";
5
- function d(C, m, t) {
5
+ function d(y, m, t) {
6
6
  const e = [];
7
7
  if (m == 0)
8
8
  return "";
9
9
  do {
10
- const s = m % C.length;
11
- let n = Math.floor((m - s) / C.length);
12
- s == 0 ? (n--, e.push(C[C.length - 1])) : e.push(C[s - 1]), m = n;
10
+ const s = m % y.length;
11
+ let n = Math.floor((m - s) / y.length);
12
+ s == 0 ? (n--, e.push(y[y.length - 1])) : e.push(y[s - 1]), m = n;
13
13
  } while (m > 0);
14
14
  return e.reverse().join("");
15
15
  }
16
16
  const S = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split(""), T = "abcdefghijklmnopqrstuvwxyz".split("");
17
- function f(C) {
18
- return Math.max(0, C);
17
+ function f(y) {
18
+ return Math.max(0, y);
19
19
  }
20
20
  class c extends b {
21
21
  constructor(t) {
22
22
  super();
23
- y(this, "width");
24
- y(this, "lines");
25
- y(this, "lazyLines");
26
- y(this, "breakLazy");
27
- y(this, "spaceLazy");
28
- y(this, "breakCount");
29
- y(this, "eatSpaces");
30
- y(this, "state");
23
+ C(this, "width");
24
+ C(this, "lines");
25
+ C(this, "lazyLines");
26
+ C(this, "breakLazy");
27
+ C(this, "spaceLazy");
28
+ C(this, "breakCount");
29
+ C(this, "eatSpaces");
30
+ C(this, "state");
31
31
  this.width = t, this.lines = [], this.lazyLines = [], this.breakLazy = !1, this.spaceLazy = !1, this.breakCount = 0, this.eatSpaces = !0, this.state = {
32
32
  images: /* @__PURE__ */ new Map(),
33
33
  imagesReverse: /* @__PURE__ */ new Map(),
@@ -115,8 +115,8 @@ class c extends b {
115
115
  this.pushText("/" + "-".repeat(p) + " " + i + " " + "-".repeat(u) + "\\");
116
116
  for (const g of a) {
117
117
  this.pushLine(), this.eatSpaces = !1;
118
- const L = f(l - 4 - g.length);
119
- this.pushText("| " + g + " ".repeat(L) + " |");
118
+ const k = f(l - 4 - g.length);
119
+ this.pushText("| " + g + " ".repeat(k) + " |");
120
120
  }
121
121
  this.pushLine(), this.pushText("\\" + "-".repeat(l - 2) + "/"), this.pushBlockContentEnd();
122
122
  }
@@ -350,6 +350,13 @@ class c extends b {
350
350
  content: [{ type: "text", text: "Toot" }]
351
351
  });
352
352
  break;
353
+ case "bluesky":
354
+ this.link({
355
+ type: "link",
356
+ url: `https://bsky.app/post/${t.id}`,
357
+ content: [{ type: "text", text: "Bluesky Post" }]
358
+ });
359
+ break;
353
360
  case "vimeo":
354
361
  this.link({
355
362
  type: "link",
@@ -387,10 +394,10 @@ class c extends b {
387
394
  Math.floor((this.width - s * 3 - 1) / s)
388
395
  ), g = new c(u);
389
396
  g.setState({ ...this.state, numericDepth: 0 }), g.visit({ type: "array", content: p.content });
390
- const L = [...g.getLines()];
391
- o.push(L);
392
- const k = Math.max(...L.map((x) => x.length), 0);
393
- n[r] = Math.max(n[r], k), g.restoreState(this);
397
+ const k = [...g.getLines()];
398
+ o.push(k);
399
+ const L = Math.max(...k.map((x) => x.length), 0);
400
+ n[r] = Math.max(n[r], L), g.restoreState(this);
394
401
  }
395
402
  e.push(o), i.push(l);
396
403
  }
@@ -404,8 +411,8 @@ class c extends b {
404
411
  this.pushLine();
405
412
  let p = "|";
406
413
  for (let u = 0; u < s; u++) {
407
- const L = (o[u] || [])[r] || "", k = n[u];
408
- p += " " + L + " ".repeat(f(k - L.length)) + " |";
414
+ const k = (o[u] || [])[r] || "", L = n[u];
415
+ p += " " + k + " ".repeat(f(L - k.length)) + " |";
409
416
  }
410
417
  this.pushText(p);
411
418
  }
@@ -788,8 +795,8 @@ class c extends b {
788
795
  if (s && e) {
789
796
  const o = h.reduce((u, g) => Math.max(u, g.oldNo ?? 0), 0), l = h.reduce((u, g) => Math.max(u, g.newNo ?? 0), 0), r = Math.max(String(o).length, 1), p = Math.max(String(l).length, 1);
790
797
  for (const u of h) {
791
- const g = u.oldNo !== null ? String(u.oldNo).padStart(r) : " ".repeat(r), L = u.newNo !== null ? String(u.newNo).padStart(p) : " ".repeat(p);
792
- a.push(`${g} ${L} ${u.prefix} ${u.text}`);
798
+ const g = u.oldNo !== null ? String(u.oldNo).padStart(r) : " ".repeat(r), k = u.newNo !== null ? String(u.newNo).padStart(p) : " ".repeat(p);
799
+ a.push(`${g} ${k} ${u.prefix} ${u.text}`);
793
800
  }
794
801
  } else if (s) {
795
802
  const o = h.length, l = String(o).length;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "text-doc-ir",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Transforms a document intermediate representation into plain text with formatting",
@@ -44,7 +44,7 @@
44
44
  "to-text": "bun src/to-text.ts"
45
45
  },
46
46
  "dependencies": {
47
- "document-ir": "0.4.0"
47
+ "document-ir": "0.5.0"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@types/bun": "latest",