markdown-codec 6.7.4 → 6.7.5

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 (56) hide show
  1. package/README.md +2 -1
  2. package/dist/block/definitions.cjs +1 -5
  3. package/dist/block/definitions.js +1 -5
  4. package/dist/block/line.cjs +2 -2
  5. package/dist/block/line.js +2 -2
  6. package/dist/block/list.cjs +7 -14
  7. package/dist/block/list.js +7 -14
  8. package/dist/block/table.cjs +3 -4
  9. package/dist/block/table.js +3 -4
  10. package/dist/codec.d.cts +9 -9
  11. package/dist/codec.d.ts +9 -9
  12. package/dist/emit/emit.cjs +35 -37
  13. package/dist/emit/emit.js +35 -37
  14. package/dist/emit/table.cjs +2 -2
  15. package/dist/emit/table.js +2 -2
  16. package/dist/html/html.cjs +0 -2
  17. package/dist/html/html.js +0 -2
  18. package/dist/html/render.cjs +3 -11
  19. package/dist/html/render.js +3 -11
  20. package/dist/image/image.cjs +0 -49
  21. package/dist/image/image.d.cts +2 -2
  22. package/dist/image/image.d.ts +2 -2
  23. package/dist/image/image.js +1 -48
  24. package/dist/{image-BtmTG4_a.d.cts → image-83yql5ES.d.cts} +1 -3
  25. package/dist/{image-BtmTG4_a.d.ts → image-83yql5ES.d.ts} +1 -3
  26. package/dist/{image-B5L0HpAJ.d.cts → image-B6p0Ovgy.d.cts} +1 -1
  27. package/dist/{image-C390OIB3.d.ts → image-gR1vISI0.d.ts} +1 -1
  28. package/dist/index.d.cts +1 -1
  29. package/dist/index.d.ts +1 -1
  30. package/dist/inline/chars.cjs +3 -6
  31. package/dist/inline/chars.js +3 -6
  32. package/dist/inline/delimiter.cjs +5 -12
  33. package/dist/inline/delimiter.d.cts +2 -1
  34. package/dist/inline/delimiter.d.ts +2 -1
  35. package/dist/inline/delimiter.js +5 -13
  36. package/dist/inline/entity.cjs +6 -10
  37. package/dist/inline/entity.js +6 -10
  38. package/dist/inline/link.cjs +4 -5
  39. package/dist/inline/link.js +4 -5
  40. package/dist/lower/front-matter.cjs +4 -8
  41. package/dist/lower/front-matter.js +4 -8
  42. package/dist/lower/image.cjs +3 -2
  43. package/dist/lower/image.d.cts +1 -1
  44. package/dist/lower/image.d.ts +1 -1
  45. package/dist/lower/image.js +2 -1
  46. package/dist/lower/inline.cjs +0 -2
  47. package/dist/lower/inline.js +0 -2
  48. package/dist/options/options.d.cts +1 -1
  49. package/dist/options/options.d.ts +1 -1
  50. package/dist/read.cjs +2 -2
  51. package/dist/read.js +2 -2
  52. package/dist/scan/scan.cjs +1 -3
  53. package/dist/scan/scan.js +1 -3
  54. package/dist/shared/list-id.cjs +1 -1
  55. package/dist/shared/list-id.js +1 -1
  56. package/package.json +2 -1
@@ -1,52 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  //#region src/image/image.ts
3
- const BASE64_TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
4
- const BASE64_DECODE = (() => {
5
- const map = (/* @__PURE__ */ new Uint8Array(256)).fill(255);
6
- for (let index = 0; index < 64; index += 1) map[BASE64_TABLE.charCodeAt(index)] = index;
7
- return map;
8
- })();
9
- const BASE64_PADDING_CODE = 61;
10
- function bytesToBase64(bytes) {
11
- let out = "";
12
- const { length } = bytes;
13
- for (let index = 0; index < length; index += 3) {
14
- const b0 = bytes[index];
15
- const b1 = index + 1 < length ? bytes[index + 1] : 0;
16
- const b2 = index + 2 < length ? bytes[index + 2] : 0;
17
- out += BASE64_TABLE.charAt(b0 >> 2);
18
- out += BASE64_TABLE.charAt((b0 & 3) << 4 | b1 >> 4);
19
- out += index + 1 < length ? BASE64_TABLE.charAt((b1 & 15) << 2 | b2 >> 6) : "=";
20
- out += index + 2 < length ? BASE64_TABLE.charAt(b2 & 63) : "=";
21
- }
22
- return out;
23
- }
24
- function base64ToBytes(base64) {
25
- const clean = base64.replace(/[^A-Za-z0-9+/=]/g, "");
26
- const { length } = clean;
27
- const out = new Uint8Array(Math.floor(length * 3 / 4));
28
- let position = 0;
29
- for (let index = 0; index < length; index += 4) {
30
- const c0 = BASE64_DECODE[clean.charCodeAt(index)];
31
- const c1 = BASE64_DECODE[clean.charCodeAt(index + 1)];
32
- const code2 = clean.charCodeAt(index + 2);
33
- const code3 = clean.charCodeAt(index + 3);
34
- if (c0 === 255 || c1 === 255) throw new Error("invalid base64 input");
35
- out[position] = c0 << 2 | c1 >> 4;
36
- position += 1;
37
- if (code2 !== BASE64_PADDING_CODE) {
38
- const d2 = BASE64_DECODE[code2];
39
- out[position] = (c1 & 15) << 4 | d2 >> 2;
40
- position += 1;
41
- if (code3 !== BASE64_PADDING_CODE) {
42
- const d3 = BASE64_DECODE[code3];
43
- out[position] = (d2 & 3) << 6 | d3;
44
- position += 1;
45
- }
46
- }
47
- }
48
- return out.subarray(0, position);
49
- }
50
3
  function readUint16BE(bytes, offset) {
51
4
  return (bytes[offset] << 8 | bytes[offset + 1]) & 65535;
52
5
  }
@@ -123,7 +76,5 @@ function readImageDimensions(bytes) {
123
76
  return readJpegDimensions(bytes);
124
77
  }
125
78
  //#endregion
126
- exports.base64ToBytes = base64ToBytes;
127
- exports.bytesToBase64 = bytesToBase64;
128
79
  exports.detectImageFormat = detectImageFormat;
129
80
  exports.readImageDimensions = readImageDimensions;
@@ -1,2 +1,2 @@
1
- import { a as detectImageFormat, i as bytesToBase64, n as ImageFormat, o as readImageDimensions, r as base64ToBytes, t as ImageDimensions } from "../image-BtmTG4_a.cjs";
2
- export { ImageDimensions, ImageFormat, base64ToBytes, bytesToBase64, detectImageFormat, readImageDimensions };
1
+ import { i as readImageDimensions, n as ImageFormat, r as detectImageFormat, t as ImageDimensions } from "../image-83yql5ES.cjs";
2
+ export { ImageDimensions, ImageFormat, detectImageFormat, readImageDimensions };
@@ -1,2 +1,2 @@
1
- import { a as detectImageFormat, i as bytesToBase64, n as ImageFormat, o as readImageDimensions, r as base64ToBytes, t as ImageDimensions } from "../image-BtmTG4_a.js";
2
- export { ImageDimensions, ImageFormat, base64ToBytes, bytesToBase64, detectImageFormat, readImageDimensions };
1
+ import { i as readImageDimensions, n as ImageFormat, r as detectImageFormat, t as ImageDimensions } from "../image-83yql5ES.js";
2
+ export { ImageDimensions, ImageFormat, detectImageFormat, readImageDimensions };
@@ -1,51 +1,4 @@
1
1
  //#region src/image/image.ts
2
- const BASE64_TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
3
- const BASE64_DECODE = (() => {
4
- const map = (/* @__PURE__ */ new Uint8Array(256)).fill(255);
5
- for (let index = 0; index < 64; index += 1) map[BASE64_TABLE.charCodeAt(index)] = index;
6
- return map;
7
- })();
8
- const BASE64_PADDING_CODE = 61;
9
- function bytesToBase64(bytes) {
10
- let out = "";
11
- const { length } = bytes;
12
- for (let index = 0; index < length; index += 3) {
13
- const b0 = bytes[index];
14
- const b1 = index + 1 < length ? bytes[index + 1] : 0;
15
- const b2 = index + 2 < length ? bytes[index + 2] : 0;
16
- out += BASE64_TABLE.charAt(b0 >> 2);
17
- out += BASE64_TABLE.charAt((b0 & 3) << 4 | b1 >> 4);
18
- out += index + 1 < length ? BASE64_TABLE.charAt((b1 & 15) << 2 | b2 >> 6) : "=";
19
- out += index + 2 < length ? BASE64_TABLE.charAt(b2 & 63) : "=";
20
- }
21
- return out;
22
- }
23
- function base64ToBytes(base64) {
24
- const clean = base64.replace(/[^A-Za-z0-9+/=]/g, "");
25
- const { length } = clean;
26
- const out = new Uint8Array(Math.floor(length * 3 / 4));
27
- let position = 0;
28
- for (let index = 0; index < length; index += 4) {
29
- const c0 = BASE64_DECODE[clean.charCodeAt(index)];
30
- const c1 = BASE64_DECODE[clean.charCodeAt(index + 1)];
31
- const code2 = clean.charCodeAt(index + 2);
32
- const code3 = clean.charCodeAt(index + 3);
33
- if (c0 === 255 || c1 === 255) throw new Error("invalid base64 input");
34
- out[position] = c0 << 2 | c1 >> 4;
35
- position += 1;
36
- if (code2 !== BASE64_PADDING_CODE) {
37
- const d2 = BASE64_DECODE[code2];
38
- out[position] = (c1 & 15) << 4 | d2 >> 2;
39
- position += 1;
40
- if (code3 !== BASE64_PADDING_CODE) {
41
- const d3 = BASE64_DECODE[code3];
42
- out[position] = (d2 & 3) << 6 | d3;
43
- position += 1;
44
- }
45
- }
46
- }
47
- return out.subarray(0, position);
48
- }
49
2
  function readUint16BE(bytes, offset) {
50
3
  return (bytes[offset] << 8 | bytes[offset + 1]) & 65535;
51
4
  }
@@ -122,4 +75,4 @@ function readImageDimensions(bytes) {
122
75
  return readJpegDimensions(bytes);
123
76
  }
124
77
  //#endregion
125
- export { base64ToBytes, bytesToBase64, detectImageFormat, readImageDimensions };
78
+ export { detectImageFormat, readImageDimensions };
@@ -4,9 +4,7 @@ interface ImageDimensions {
4
4
  readonly heightPx: number;
5
5
  }
6
6
  type ImageFormat = "png" | "jpeg";
7
- declare function bytesToBase64(bytes: Uint8Array): string;
8
- declare function base64ToBytes(base64: string): Uint8Array;
9
7
  declare function detectImageFormat(bytes: Uint8Array): ImageFormat | undefined;
10
8
  declare function readImageDimensions(bytes: Uint8Array): ImageDimensions | undefined;
11
9
  //#endregion
12
- export { detectImageFormat as a, bytesToBase64 as i, ImageFormat as n, readImageDimensions as o, base64ToBytes as r, ImageDimensions as t };
10
+ export { readImageDimensions as i, ImageFormat as n, detectImageFormat as r, ImageDimensions as t };
@@ -4,9 +4,7 @@ interface ImageDimensions {
4
4
  readonly heightPx: number;
5
5
  }
6
6
  type ImageFormat = "png" | "jpeg";
7
- declare function bytesToBase64(bytes: Uint8Array): string;
8
- declare function base64ToBytes(base64: string): Uint8Array;
9
7
  declare function detectImageFormat(bytes: Uint8Array): ImageFormat | undefined;
10
8
  declare function readImageDimensions(bytes: Uint8Array): ImageDimensions | undefined;
11
9
  //#endregion
12
- export { detectImageFormat as a, bytesToBase64 as i, ImageFormat as n, readImageDimensions as o, base64ToBytes as r, ImageDimensions as t };
10
+ export { readImageDimensions as i, ImageFormat as n, detectImageFormat as r, ImageDimensions as t };
@@ -1,4 +1,4 @@
1
- import { n as ImageFormat } from "./image-BtmTG4_a.cjs";
1
+ import { n as ImageFormat } from "./image-83yql5ES.cjs";
2
2
  //#region src/lower/image.d.ts
3
3
  interface MarkdownImageResolveContext {
4
4
  readonly alt: string;
@@ -1,4 +1,4 @@
1
- import { n as ImageFormat } from "./image-BtmTG4_a.js";
1
+ import { n as ImageFormat } from "./image-83yql5ES.js";
2
2
  //#region src/lower/image.d.ts
3
3
  interface MarkdownImageResolveContext {
4
4
  readonly alt: string;
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { a as MarkdownInputTooLargeError, c as MarkdownNestingLimitExceededError, d as MarkdownUnbalancedConstructMarkersError, f as MarkdownUnsupportedDocumentKindError, i as MarkdownDiagnosticSink, m as NOOP_MARKDOWN_DIAGNOSTIC_SINK, n as MarkdownDiagnosticCodes, o as MarkdownInvalidRunConstructExtentError, p as MarkdownWriteError, r as MarkdownDiagnosticSeverity, s as MarkdownInvalidUtf8Error, t as MarkdownDiagnostic, u as MarkdownParseError } from "./diagnostics-CjfBoW4K.cjs";
2
2
  import { MarkdownBytesSchema, markdownCodec, markdownContentCodec } from "./codec.cjs";
3
- import { n as MarkdownImageResolver, r as MarkdownResolvedImageBytes, t as MarkdownImageResolveContext } from "./image-B5L0HpAJ.cjs";
3
+ import { n as MarkdownImageResolver, r as MarkdownResolvedImageBytes, t as MarkdownImageResolveContext } from "./image-B6p0Ovgy.cjs";
4
4
  import { MarkdownBulletListMarker, MarkdownCodeFenceChar, MarkdownEmphasisMarker, MarkdownHeadingStyle, MarkdownLineEnding, MarkdownOrderedListDelimiter, MarkdownThematicBreakChar, ReadMarkdownOptions, WriteMarkdownOptions, WriteMarkdownStyleOptions } from "./options/options.cjs";
5
5
  import { ReadMarkdownContentResult, ReadMarkdownResult, readMarkdown, readMarkdownContent } from "./read.cjs";
6
6
  import { writeMarkdown, writeMarkdownContent } from "./write.cjs";
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { a as MarkdownInputTooLargeError, c as MarkdownNestingLimitExceededError, d as MarkdownUnbalancedConstructMarkersError, f as MarkdownUnsupportedDocumentKindError, i as MarkdownDiagnosticSink, m as NOOP_MARKDOWN_DIAGNOSTIC_SINK, n as MarkdownDiagnosticCodes, o as MarkdownInvalidRunConstructExtentError, p as MarkdownWriteError, r as MarkdownDiagnosticSeverity, s as MarkdownInvalidUtf8Error, t as MarkdownDiagnostic, u as MarkdownParseError } from "./diagnostics-CjfBoW4K.js";
2
2
  import { MarkdownBytesSchema, markdownCodec, markdownContentCodec } from "./codec.js";
3
- import { n as MarkdownImageResolver, r as MarkdownResolvedImageBytes, t as MarkdownImageResolveContext } from "./image-C390OIB3.js";
3
+ import { n as MarkdownImageResolver, r as MarkdownResolvedImageBytes, t as MarkdownImageResolveContext } from "./image-gR1vISI0.js";
4
4
  import { MarkdownBulletListMarker, MarkdownCodeFenceChar, MarkdownEmphasisMarker, MarkdownHeadingStyle, MarkdownLineEnding, MarkdownOrderedListDelimiter, MarkdownThematicBreakChar, ReadMarkdownOptions, WriteMarkdownOptions, WriteMarkdownStyleOptions } from "./options/options.js";
5
5
  import { ReadMarkdownContentResult, ReadMarkdownResult, readMarkdown, readMarkdownContent } from "./read.js";
6
6
  import { writeMarkdown, writeMarkdownContent } from "./write.js";
@@ -18,8 +18,7 @@ function isAsciiControl(char) {
18
18
  return code <= 31 || code === 127;
19
19
  }
20
20
  function containsAsciiControlOrSpace(text) {
21
- for (let index = 0; index < text.length; index += 1) if (isAsciiControl(text.charAt(index)) || text.charAt(index) === " ") return true;
22
- return false;
21
+ return text.split("").some((char) => isAsciiControl(char) || char === " ");
23
22
  }
24
23
  function isMarkdownSpace(char) {
25
24
  return char === " " || char === " " || char === "\n" || char === "\r";
@@ -27,7 +26,7 @@ function isMarkdownSpace(char) {
27
26
  function codePointBefore(text, index) {
28
27
  if (index <= 0) return "\n";
29
28
  const low = text.charCodeAt(index - 1);
30
- if (index >= 2 && low >= 56320 && low <= 57343) {
29
+ if (low >= 56320 && low <= 57343) {
31
30
  const high = text.charCodeAt(index - 2);
32
31
  if (high >= 55296 && high <= 56319) return text.slice(index - 2, index);
33
32
  }
@@ -35,9 +34,7 @@ function codePointBefore(text, index) {
35
34
  }
36
35
  function codePointAt(text, index) {
37
36
  if (index >= text.length) return "\n";
38
- const code = text.codePointAt(index);
39
- if (code === void 0) return "\n";
40
- return String.fromCodePoint(code);
37
+ return String.fromCodePoint(text.codePointAt(index));
41
38
  }
42
39
  //#endregion
43
40
  exports.codePointAt = codePointAt;
@@ -17,8 +17,7 @@ function isAsciiControl(char) {
17
17
  return code <= 31 || code === 127;
18
18
  }
19
19
  function containsAsciiControlOrSpace(text) {
20
- for (let index = 0; index < text.length; index += 1) if (isAsciiControl(text.charAt(index)) || text.charAt(index) === " ") return true;
21
- return false;
20
+ return text.split("").some((char) => isAsciiControl(char) || char === " ");
22
21
  }
23
22
  function isMarkdownSpace(char) {
24
23
  return char === " " || char === " " || char === "\n" || char === "\r";
@@ -26,7 +25,7 @@ function isMarkdownSpace(char) {
26
25
  function codePointBefore(text, index) {
27
26
  if (index <= 0) return "\n";
28
27
  const low = text.charCodeAt(index - 1);
29
- if (index >= 2 && low >= 56320 && low <= 57343) {
28
+ if (low >= 56320 && low <= 57343) {
30
29
  const high = text.charCodeAt(index - 2);
31
30
  if (high >= 55296 && high <= 56319) return text.slice(index - 2, index);
32
31
  }
@@ -34,9 +33,7 @@ function codePointBefore(text, index) {
34
33
  }
35
34
  function codePointAt(text, index) {
36
35
  if (index >= text.length) return "\n";
37
- const code = text.codePointAt(index);
38
- if (code === void 0) return "\n";
39
- return String.fromCodePoint(code);
36
+ return String.fromCodePoint(text.codePointAt(index));
40
37
  }
41
38
  //#endregion
42
39
  export { codePointAt, codePointBefore, containsAsciiControlOrSpace, isAsciiControl, isAsciiPunctuation, isMarkdownSpace, isUnicodePunctuation, isUnicodeWhitespace };
@@ -63,7 +63,6 @@ function canMatch(opener, closer) {
63
63
  return !isRuleOfThreeBlocked(opener, closer);
64
64
  }
65
65
  function delimitersConsumedByMatch(opener, closer) {
66
- if (closer.char === "~") return closer.count;
67
66
  return closer.count >= 2 && opener.count >= 2 ? 2 : 1;
68
67
  }
69
68
  function wrapperKindFor(closer, used) {
@@ -83,7 +82,7 @@ function processEmphasis(stack, stackBottom, createWrapper) {
83
82
  const floor = openersFloor.has(signature) ? openersFloor.get(signature) : stackBottom;
84
83
  let opener = closer.previous;
85
84
  let matchedOpener;
86
- while (opener !== void 0 && opener !== stackBottom && opener !== floor) {
85
+ while (opener !== void 0 && opener !== floor) {
87
86
  if (canMatch(opener, closer)) {
88
87
  matchedOpener = opener;
89
88
  break;
@@ -94,7 +93,6 @@ function processEmphasis(stack, stackBottom, createWrapper) {
94
93
  if (matchedOpener === void 0) {
95
94
  closer = closer.next;
96
95
  openersFloor.set(signature, failedCloser.previous);
97
- if (!failedCloser.canOpen) stack.remove(failedCloser);
98
96
  continue;
99
97
  }
100
98
  const used = delimitersConsumedByMatch(matchedOpener, closer);
@@ -112,16 +110,10 @@ function processEmphasis(stack, stackBottom, createWrapper) {
112
110
  moving = following;
113
111
  }
114
112
  openerNode.insertAfter(wrapper);
115
- if (matchedOpener.next !== closer) {
116
- matchedOpener.next = closer;
117
- closer.previous = matchedOpener;
118
- }
119
- if (matchedOpener.count === 0) {
120
- openerNode.unlink();
121
- stack.remove(matchedOpener);
122
- }
113
+ matchedOpener.next = closer;
114
+ closer.previous = matchedOpener;
115
+ if (matchedOpener.count === 0) stack.remove(matchedOpener);
123
116
  if (closer.count === 0) {
124
- closerNode.unlink();
125
117
  const following = closer.next;
126
118
  stack.remove(closer);
127
119
  closer = following;
@@ -131,6 +123,7 @@ function processEmphasis(stack, stackBottom, createWrapper) {
131
123
  }
132
124
  //#endregion
133
125
  exports.DelimiterStack = DelimiterStack;
126
+ exports.closerSignature = closerSignature;
134
127
  exports.isDelimiterChar = isDelimiterChar;
135
128
  exports.processEmphasis = processEmphasis;
136
129
  exports.scanDelimiterRun = scanDelimiterRun;
@@ -23,7 +23,8 @@ declare class DelimiterStack {
23
23
  push(char: DelimiterChar, run: DelimiterRun, node: InlineNode): void;
24
24
  remove(delimiter: Delimiter): void;
25
25
  }
26
+ declare function closerSignature(closer: Delimiter): string;
26
27
  type EmphasisWrapperFactory = (kind: "emphasis" | "strong" | "strikethrough", marker: DelimiterChar) => InlineNode;
27
28
  declare function processEmphasis(stack: DelimiterStack, stackBottom: Delimiter | undefined, createWrapper: EmphasisWrapperFactory): void;
28
29
  //#endregion
29
- export { Delimiter, DelimiterChar, DelimiterRun, DelimiterStack, EmphasisWrapperFactory, isDelimiterChar, processEmphasis, scanDelimiterRun };
30
+ export { Delimiter, DelimiterChar, DelimiterRun, DelimiterStack, EmphasisWrapperFactory, closerSignature, isDelimiterChar, processEmphasis, scanDelimiterRun };
@@ -23,7 +23,8 @@ declare class DelimiterStack {
23
23
  push(char: DelimiterChar, run: DelimiterRun, node: InlineNode): void;
24
24
  remove(delimiter: Delimiter): void;
25
25
  }
26
+ declare function closerSignature(closer: Delimiter): string;
26
27
  type EmphasisWrapperFactory = (kind: "emphasis" | "strong" | "strikethrough", marker: DelimiterChar) => InlineNode;
27
28
  declare function processEmphasis(stack: DelimiterStack, stackBottom: Delimiter | undefined, createWrapper: EmphasisWrapperFactory): void;
28
29
  //#endregion
29
- export { Delimiter, DelimiterChar, DelimiterRun, DelimiterStack, EmphasisWrapperFactory, isDelimiterChar, processEmphasis, scanDelimiterRun };
30
+ export { Delimiter, DelimiterChar, DelimiterRun, DelimiterStack, EmphasisWrapperFactory, closerSignature, isDelimiterChar, processEmphasis, scanDelimiterRun };
@@ -62,7 +62,6 @@ function canMatch(opener, closer) {
62
62
  return !isRuleOfThreeBlocked(opener, closer);
63
63
  }
64
64
  function delimitersConsumedByMatch(opener, closer) {
65
- if (closer.char === "~") return closer.count;
66
65
  return closer.count >= 2 && opener.count >= 2 ? 2 : 1;
67
66
  }
68
67
  function wrapperKindFor(closer, used) {
@@ -82,7 +81,7 @@ function processEmphasis(stack, stackBottom, createWrapper) {
82
81
  const floor = openersFloor.has(signature) ? openersFloor.get(signature) : stackBottom;
83
82
  let opener = closer.previous;
84
83
  let matchedOpener;
85
- while (opener !== void 0 && opener !== stackBottom && opener !== floor) {
84
+ while (opener !== void 0 && opener !== floor) {
86
85
  if (canMatch(opener, closer)) {
87
86
  matchedOpener = opener;
88
87
  break;
@@ -93,7 +92,6 @@ function processEmphasis(stack, stackBottom, createWrapper) {
93
92
  if (matchedOpener === void 0) {
94
93
  closer = closer.next;
95
94
  openersFloor.set(signature, failedCloser.previous);
96
- if (!failedCloser.canOpen) stack.remove(failedCloser);
97
95
  continue;
98
96
  }
99
97
  const used = delimitersConsumedByMatch(matchedOpener, closer);
@@ -111,16 +109,10 @@ function processEmphasis(stack, stackBottom, createWrapper) {
111
109
  moving = following;
112
110
  }
113
111
  openerNode.insertAfter(wrapper);
114
- if (matchedOpener.next !== closer) {
115
- matchedOpener.next = closer;
116
- closer.previous = matchedOpener;
117
- }
118
- if (matchedOpener.count === 0) {
119
- openerNode.unlink();
120
- stack.remove(matchedOpener);
121
- }
112
+ matchedOpener.next = closer;
113
+ closer.previous = matchedOpener;
114
+ if (matchedOpener.count === 0) stack.remove(matchedOpener);
122
115
  if (closer.count === 0) {
123
- closerNode.unlink();
124
116
  const following = closer.next;
125
117
  stack.remove(closer);
126
118
  closer = following;
@@ -129,4 +121,4 @@ function processEmphasis(stack, stackBottom, createWrapper) {
129
121
  while (stack.top !== void 0 && stack.top !== stackBottom) stack.remove(stack.top);
130
122
  }
131
123
  //#endregion
132
- export { DelimiterStack, isDelimiterChar, processEmphasis, scanDelimiterRun };
124
+ export { DelimiterStack, closerSignature, isDelimiterChar, processEmphasis, scanDelimiterRun };
@@ -12,7 +12,6 @@ function codepointToString(codepoint) {
12
12
  return String.fromCodePoint(codepoint);
13
13
  }
14
14
  function matchEntity(text, start) {
15
- if (text.charAt(start) !== "&") return;
16
15
  const match = ENTITY_PATTERN.exec(text.slice(start));
17
16
  if (match === null) return;
18
17
  const [raw, hex, decimal, name] = match;
@@ -33,10 +32,9 @@ function matchEntity(text, start) {
33
32
  };
34
33
  }
35
34
  function unescapeString(text) {
36
- if (!text.includes("\\") && !text.includes("&")) return text;
37
35
  let result = "";
38
36
  let index = 0;
39
- while (index < text.length) {
37
+ while (text.charAt(index) !== "") {
40
38
  const char = text.charAt(index);
41
39
  if (char === "\\") {
42
40
  const next = text.charAt(index + 1);
@@ -49,13 +47,11 @@ function unescapeString(text) {
49
47
  index += 1;
50
48
  continue;
51
49
  }
52
- if (char === "&") {
53
- const entity = matchEntity(text, index);
54
- if (entity !== void 0) {
55
- result += entity.value;
56
- index += entity.raw.length;
57
- continue;
58
- }
50
+ const entity = matchEntity(text, index);
51
+ if (entity !== void 0) {
52
+ result += entity.value;
53
+ index += entity.raw.length;
54
+ continue;
59
55
  }
60
56
  result += char;
61
57
  index += 1;
@@ -11,7 +11,6 @@ function codepointToString(codepoint) {
11
11
  return String.fromCodePoint(codepoint);
12
12
  }
13
13
  function matchEntity(text, start) {
14
- if (text.charAt(start) !== "&") return;
15
14
  const match = ENTITY_PATTERN.exec(text.slice(start));
16
15
  if (match === null) return;
17
16
  const [raw, hex, decimal, name] = match;
@@ -32,10 +31,9 @@ function matchEntity(text, start) {
32
31
  };
33
32
  }
34
33
  function unescapeString(text) {
35
- if (!text.includes("\\") && !text.includes("&")) return text;
36
34
  let result = "";
37
35
  let index = 0;
38
- while (index < text.length) {
36
+ while (text.charAt(index) !== "") {
39
37
  const char = text.charAt(index);
40
38
  if (char === "\\") {
41
39
  const next = text.charAt(index + 1);
@@ -48,13 +46,11 @@ function unescapeString(text) {
48
46
  index += 1;
49
47
  continue;
50
48
  }
51
- if (char === "&") {
52
- const entity = matchEntity(text, index);
53
- if (entity !== void 0) {
54
- result += entity.value;
55
- index += entity.raw.length;
56
- continue;
57
- }
49
+ const entity = matchEntity(text, index);
50
+ if (entity !== void 0) {
51
+ result += entity.value;
52
+ index += entity.raw.length;
53
+ continue;
58
54
  }
59
55
  result += char;
60
56
  index += 1;
@@ -9,7 +9,7 @@ function normalizeLinkLabel(labelWithBrackets) {
9
9
  function matchLinkLabel(text, start) {
10
10
  if (text.charAt(start) !== "[") return 0;
11
11
  let index = start + 1;
12
- while (index < text.length) {
12
+ while (text.charAt(index) !== "") {
13
13
  const char = text.charAt(index);
14
14
  if (char === "\\") {
15
15
  index += 2;
@@ -27,7 +27,7 @@ function matchLinkLabel(text, start) {
27
27
  function parseLinkDestination(text, start) {
28
28
  if (text.charAt(start) === "<") {
29
29
  let index = start + 1;
30
- while (index < text.length) {
30
+ while (text.charAt(index) !== "") {
31
31
  const char = text.charAt(index);
32
32
  if (char === "\\") {
33
33
  index += 2;
@@ -79,9 +79,8 @@ const TITLE_DELIMITERS = /* @__PURE__ */ new Map([
79
79
  function parseLinkTitle(text, start) {
80
80
  const opener = text.charAt(start);
81
81
  const closer = TITLE_DELIMITERS.get(opener);
82
- if (closer === void 0) return;
83
82
  let index = start + 1;
84
- while (index < text.length) {
83
+ while (text.charAt(index) !== "") {
85
84
  const char = text.charAt(index);
86
85
  if (char === "\\") {
87
86
  index += 2;
@@ -98,7 +97,7 @@ function parseLinkTitle(text, start) {
98
97
  function skipInlineWhitespace(text, start) {
99
98
  let index = start;
100
99
  let seenLineEnding = false;
101
- while (index < text.length) {
100
+ for (;;) {
102
101
  const char = text.charAt(index);
103
102
  if (char === "\n") {
104
103
  if (seenLineEnding) break;
@@ -8,7 +8,7 @@ function normalizeLinkLabel(labelWithBrackets) {
8
8
  function matchLinkLabel(text, start) {
9
9
  if (text.charAt(start) !== "[") return 0;
10
10
  let index = start + 1;
11
- while (index < text.length) {
11
+ while (text.charAt(index) !== "") {
12
12
  const char = text.charAt(index);
13
13
  if (char === "\\") {
14
14
  index += 2;
@@ -26,7 +26,7 @@ function matchLinkLabel(text, start) {
26
26
  function parseLinkDestination(text, start) {
27
27
  if (text.charAt(start) === "<") {
28
28
  let index = start + 1;
29
- while (index < text.length) {
29
+ while (text.charAt(index) !== "") {
30
30
  const char = text.charAt(index);
31
31
  if (char === "\\") {
32
32
  index += 2;
@@ -78,9 +78,8 @@ const TITLE_DELIMITERS = /* @__PURE__ */ new Map([
78
78
  function parseLinkTitle(text, start) {
79
79
  const opener = text.charAt(start);
80
80
  const closer = TITLE_DELIMITERS.get(opener);
81
- if (closer === void 0) return;
82
81
  let index = start + 1;
83
- while (index < text.length) {
82
+ while (text.charAt(index) !== "") {
84
83
  const char = text.charAt(index);
85
84
  if (char === "\\") {
86
85
  index += 2;
@@ -97,7 +96,7 @@ function parseLinkTitle(text, start) {
97
96
  function skipInlineWhitespace(text, start) {
98
97
  let index = start;
99
98
  let seenLineEnding = false;
100
- while (index < text.length) {
99
+ for (;;) {
101
100
  const char = text.charAt(index);
102
101
  if (char === "\n") {
103
102
  if (seenLineEnding) break;
@@ -73,20 +73,16 @@ function extractFrontMatter(source, sink = require_diagnostics_diagnostics.NOOP_
73
73
  rest: source,
74
74
  source: void 0
75
75
  };
76
- let closingIndex = -1;
77
- for (let index = 1; index < lines.length; index += 1) if (CLOSING_DELIMITER_PATTERN.test(lines[index] ?? "")) {
78
- closingIndex = index;
79
- break;
80
- }
76
+ const closingOffset = lines.slice(1).findIndex((line) => CLOSING_DELIMITER_PATTERN.test(line));
77
+ const closingIndex = closingOffset === -1 ? -1 : closingOffset + 1;
81
78
  if (closingIndex === -1) return {
82
79
  metadata: {},
83
80
  rest: source,
84
81
  source: void 0
85
82
  };
86
83
  const metadata = {};
87
- for (let index = 1; index < closingIndex; index += 1) {
88
- const line = lines[index] ?? "";
89
- if (line.trim().length === 0) continue;
84
+ for (const [offset, line] of lines.slice(1, closingIndex).entries()) {
85
+ const index = offset + 1;
90
86
  const match = KEY_VALUE_LINE_PATTERN.exec(line);
91
87
  const key = match?.[1];
92
88
  const value = match?.[2];
@@ -72,20 +72,16 @@ function extractFrontMatter(source, sink = NOOP_MARKDOWN_DIAGNOSTIC_SINK) {
72
72
  rest: source,
73
73
  source: void 0
74
74
  };
75
- let closingIndex = -1;
76
- for (let index = 1; index < lines.length; index += 1) if (CLOSING_DELIMITER_PATTERN.test(lines[index] ?? "")) {
77
- closingIndex = index;
78
- break;
79
- }
75
+ const closingOffset = lines.slice(1).findIndex((line) => CLOSING_DELIMITER_PATTERN.test(line));
76
+ const closingIndex = closingOffset === -1 ? -1 : closingOffset + 1;
80
77
  if (closingIndex === -1) return {
81
78
  metadata: {},
82
79
  rest: source,
83
80
  source: void 0
84
81
  };
85
82
  const metadata = {};
86
- for (let index = 1; index < closingIndex; index += 1) {
87
- const line = lines[index] ?? "";
88
- if (line.trim().length === 0) continue;
83
+ for (const [offset, line] of lines.slice(1, closingIndex).entries()) {
84
+ const index = offset + 1;
89
85
  const match = KEY_VALUE_LINE_PATTERN.exec(line);
90
86
  const key = match?.[1];
91
87
  const value = match?.[2];
@@ -1,5 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_image_image = require("../image/image.cjs");
3
+ let byte_codec = require("byte-codec");
3
4
  //#region src/lower/image.ts
4
5
  const POINTS_PER_PIXEL = 72 / 96;
5
6
  const DATA_URI_PATTERN = /^data:image\/(?:png|jpe?g);base64,(.+)$/is;
@@ -7,7 +8,7 @@ function decodeDataUriImage(destination) {
7
8
  const base64 = DATA_URI_PATTERN.exec(destination)?.[1];
8
9
  if (base64 === void 0) return;
9
10
  try {
10
- return require_image_image.base64ToBytes(base64);
11
+ return (0, byte_codec.base64ToBytes)(base64);
11
12
  } catch {
12
13
  return;
13
14
  }
@@ -20,7 +21,7 @@ function resolveMarkdownImage(destination, context, resolver) {
20
21
  if (format === void 0 || dimensions === void 0) return;
21
22
  return {
22
23
  format,
23
- base64: require_image_image.bytesToBase64(bytes),
24
+ base64: (0, byte_codec.bytesToBase64)(bytes),
24
25
  widthPt: dimensions.widthPx * POINTS_PER_PIXEL,
25
26
  heightPt: dimensions.heightPx * POINTS_PER_PIXEL
26
27
  };
@@ -1,2 +1,2 @@
1
- import { a as resolveMarkdownImage, i as ResolvedMarkdownImage, n as MarkdownImageResolver, r as MarkdownResolvedImageBytes, t as MarkdownImageResolveContext } from "../image-B5L0HpAJ.cjs";
1
+ import { a as resolveMarkdownImage, i as ResolvedMarkdownImage, n as MarkdownImageResolver, r as MarkdownResolvedImageBytes, t as MarkdownImageResolveContext } from "../image-B6p0Ovgy.cjs";
2
2
  export { MarkdownImageResolveContext, MarkdownImageResolver, MarkdownResolvedImageBytes, ResolvedMarkdownImage, resolveMarkdownImage };
@@ -1,2 +1,2 @@
1
- import { a as resolveMarkdownImage, i as ResolvedMarkdownImage, n as MarkdownImageResolver, r as MarkdownResolvedImageBytes, t as MarkdownImageResolveContext } from "../image-C390OIB3.js";
1
+ import { a as resolveMarkdownImage, i as ResolvedMarkdownImage, n as MarkdownImageResolver, r as MarkdownResolvedImageBytes, t as MarkdownImageResolveContext } from "../image-gR1vISI0.js";
2
2
  export { MarkdownImageResolveContext, MarkdownImageResolver, MarkdownResolvedImageBytes, ResolvedMarkdownImage, resolveMarkdownImage };
@@ -1,4 +1,5 @@
1
- import { base64ToBytes, bytesToBase64, detectImageFormat, readImageDimensions } from "../image/image.js";
1
+ import { detectImageFormat, readImageDimensions } from "../image/image.js";
2
+ import { base64ToBytes, bytesToBase64 } from "byte-codec";
2
3
  //#region src/lower/image.ts
3
4
  const POINTS_PER_PIXEL = 72 / 96;
4
5
  const DATA_URI_PATTERN = /^data:image\/(?:png|jpe?g);base64,(.+)$/is;
@@ -27,8 +27,6 @@ function lowerNestedEmphasisLike(kind, node, style, context, runs, extents) {
27
27
  function lowerInlineNodeInto(node, style, context, runs, extents) {
28
28
  switch (node.type) {
29
29
  case "text":
30
- if (node.value.length > 0) runs.push(buildRun(node.value, style));
31
- return;
32
30
  case "entity":
33
31
  if (node.value.length > 0) runs.push(buildRun(node.value, style));
34
32
  return;
@@ -26,8 +26,6 @@ function lowerNestedEmphasisLike(kind, node, style, context, runs, extents) {
26
26
  function lowerInlineNodeInto(node, style, context, runs, extents) {
27
27
  switch (node.type) {
28
28
  case "text":
29
- if (node.value.length > 0) runs.push(buildRun(node.value, style));
30
- return;
31
29
  case "entity":
32
30
  if (node.value.length > 0) runs.push(buildRun(node.value, style));
33
31
  return;