rapier-markdown-kit 1.1.101 → 1.1.104

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 (60) hide show
  1. package/LICENSE +2 -2
  2. package/README.md +213 -53
  3. package/dist/agent/vendor/hyphen-en-us/LICENSE +14 -0
  4. package/dist/agent/vendor/hyphen-en-us/SOURCE.json +33 -0
  5. package/dist/agent/vendor/hyphen-en-us/hyph-en-us.hyp.txt +14 -0
  6. package/dist/agent/vendor/hyphen-en-us/hyph-en-us.pat.txt +4938 -0
  7. package/dist/agent/vendor/hyphen-en-us/patterns.js +25 -0
  8. package/dist/agent/vendor/pretext/LICENSE +208 -0
  9. package/dist/agent/vendor/pretext/NOTICE +26 -13
  10. package/dist/agent/vendor/pretext/SOURCE.json +213 -45
  11. package/dist/agent/vendor/pretext/analysis.js +675 -1224
  12. package/dist/agent/vendor/pretext/entry-geometry.js +183 -0
  13. package/dist/agent/vendor/pretext/gecko-line-breaks.js +688 -0
  14. package/dist/agent/vendor/pretext/generated/engine-break-data.js +57 -0
  15. package/dist/agent/vendor/pretext/generated/webkit-generic-families.js +80 -0
  16. package/dist/agent/vendor/pretext/graphemes.js +98 -0
  17. package/dist/agent/vendor/pretext/han-kerning.js +253 -0
  18. package/dist/agent/vendor/pretext/layout.js +352 -290
  19. package/dist/agent/vendor/pretext/line-break.js +1154 -588
  20. package/dist/agent/vendor/pretext/line-breaks.js +892 -0
  21. package/dist/agent/vendor/pretext/line-text.js +81 -39
  22. package/dist/agent/vendor/pretext/measurement.js +1105 -176
  23. package/dist/agent/vendor/pretext/prepare.js +807 -0
  24. package/dist/agent/vendor/pretext/rich-inline.js +1242 -273
  25. package/dist/agent/will.mjs +2 -0
  26. package/dist/kit/assets.mjs +5 -1
  27. package/dist/kit/conformance/run.mjs +4 -4
  28. package/dist/kit/export-fonts.mjs +26 -11
  29. package/dist/kit/index.mjs +1 -0
  30. package/dist/kit/ledger/carried.mjs +9 -7
  31. package/dist/kit/ledger/data.mjs +73 -13
  32. package/dist/kit/ledger/format.mjs +166 -53
  33. package/dist/kit/ledger/hash.mjs +75 -18
  34. package/dist/kit/ledger/history.mjs +143 -115
  35. package/dist/kit/ledger/inverse-source.mjs +158 -19
  36. package/dist/kit/ledger/journal-records.mjs +292 -67
  37. package/dist/kit/model.mjs +1 -1
  38. package/dist/kit/pdf-glyphs.mjs +4 -4
  39. package/dist/kit/render-markdown.mjs +259 -122
  40. package/dist/kit/render-sanitize.mjs +24 -4
  41. package/dist/kit/render-work.mjs +99 -20
  42. package/dist/kit/render.mjs +101 -65
  43. package/dist/kit/typography.mjs +2 -0
  44. package/dist/layout/hyphenation.mjs +127 -0
  45. package/dist/layout/line-plan.mjs +88 -96
  46. package/dist/layout/model.mjs +61 -80
  47. package/dist/layout/paragraph-fit.mjs +191 -0
  48. package/dist/layout/preparation.mjs +373 -0
  49. package/dist/layout/prepared-paragraph.mjs +223 -0
  50. package/dist/layout/typography.mjs +345 -111
  51. package/dist/packages/rapier-diff/index.mjs +288 -196
  52. package/dist/spec/document-fonts.mjs +13 -4
  53. package/dist/spec/md-assets.mjs +149 -30
  54. package/dist/spec/md-layout.mjs +5 -2
  55. package/dist/spec/md-marks.mjs +218 -3
  56. package/dist/spec/md-source.mjs +122 -0
  57. package/package.json +2 -1
  58. package/style.css +9 -0
  59. package/dist/agent/vendor/pretext/bidi.js +0 -151
  60. package/dist/agent/vendor/pretext/generated/bidi-data.js +0 -3831
@@ -1,44 +1,86 @@
1
- /*! Pretext 0.0.9 | MIT | Copyright (c) 2026 Pretext contributors */
2
- import { getSharedGraphemeSegmenter } from './analysis.js';
3
- import { isDiscretionaryLineEnd } from './line-break.js';
4
- let sharedLineTextCaches = new WeakMap();
5
- function getSegmentGraphemeOffsets(segmentIndex, segments, cache) {
6
- let offsets = cache.get(segmentIndex);
7
- if (offsets !== undefined) return offsets;
8
- offsets = [
9
- 0
10
- ];
11
- const graphemeSegmenter = getSharedGraphemeSegmenter();
12
- for (const gs of graphemeSegmenter.segment(segments[segmentIndex])){
13
- offsets.push(gs.index + gs.segment.length);
14
- }
15
- cache.set(segmentIndex, offsets);
16
- return offsets;
1
+ /*! Pretext Unreleased (bac1774c0) | MIT; BSD/Unicode/ICU notices in LICENSE | Copyright (c) 2026 Pretext contributors */
2
+ import { findGraphemeEnds } from './graphemes.js'
3
+ import { HARD_BREAK, KIND_BITS, SOFT_HYPHEN, ZERO_WIDTH_BREAK, ZERO_WIDTH_GLUE } from './analysis.js'
4
+ import { isDiscretionaryLineEnd, } from './line-break.js'
5
+ import { getEngineProfile } from './measurement.js'
6
+
7
+ // A handle with each segment's text, which line text is built from: prepareWithSegments()'s, or
8
+ // a rich-inline paragraph's.
9
+
10
+
11
+ // Per handle, the grapheme ends of each segment a line has started or ended inside.
12
+ const graphemeEndCaches = new WeakMap ()
13
+
14
+ // The offsets in a segment's text where its graphemes end, in order, then zeros.
15
+ export function getGraphemeEnds(prepared , segmentIndex ) {
16
+ let cache = graphemeEndCaches.get(prepared)
17
+ if (cache === undefined) {
18
+ cache = new Map ()
19
+ graphemeEndCaches.set(prepared, cache)
20
+ }
21
+ let ends = cache.get(segmentIndex)
22
+ if (ends === undefined) {
23
+ const segment = prepared.segments[segmentIndex]
24
+ ends = new Int32Array(segment.length)
25
+ findGraphemeEnds(getEngineProfile().graphemeTable, segment, 0, segment.length, ends)
26
+ cache.set(segmentIndex, ends)
27
+ }
28
+ return ends
17
29
  }
18
- export function getLineTextCache(prepared) {
19
- let cache = sharedLineTextCaches.get(prepared);
20
- if (cache !== undefined) return cache;
21
- cache = new Map();
22
- sharedLineTextCaches.set(prepared, cache);
23
- return cache;
30
+
31
+ // Where grapheme `graphemeIndex` of a segment starts in its text.
32
+ function getGraphemeStart(prepared , segmentIndex , graphemeIndex ) {
33
+ return graphemeIndex === 0 ? 0 : getGraphemeEnds(prepared, segmentIndex)[graphemeIndex - 1]
24
34
  }
25
- export function buildLineTextFromRange(prepared, cache, startSegmentIndex, startGraphemeIndex, endSegmentIndex, endGraphemeIndex) {
26
- let text = '';
27
- for(let i = startSegmentIndex; i < endSegmentIndex; i++){
28
- if (prepared.kinds[i] === 'soft-hyphen' || prepared.kinds[i] === 'hard-break') continue;
29
- if (i === startSegmentIndex && startGraphemeIndex > 0) {
30
- const offsets = getSegmentGraphemeOffsets(i, prepared.segments, cache);
31
- text += prepared.segments[i].slice(offsets[startGraphemeIndex]);
32
- } else {
33
- text += prepared.segments[i];
34
- }
35
- }
36
- if (endGraphemeIndex > 0) {
37
- const offsets = getSegmentGraphemeOffsets(endSegmentIndex, prepared.segments, cache);
38
- text += prepared.segments[endSegmentIndex].slice(offsets[startSegmentIndex === endSegmentIndex ? startGraphemeIndex : 0], offsets[endGraphemeIndex]);
35
+
36
+ // The text of a range of `prepared`'s segments, with no hyphen: that of a rich-inline fragment its
37
+ // line goes on after.
38
+ export function buildRangeText(
39
+ prepared ,
40
+ startSegmentIndex ,
41
+ startGraphemeIndex ,
42
+ endSegmentIndex ,
43
+ endGraphemeIndex ,
44
+ ) {
45
+ const { segmentFlags } = prepared
46
+ // A range kept from a longer text, such as one prepared again since, can end
47
+ // past this one, up to segment Infinity: its text stops at this text's end.
48
+ const segmentCount = prepared.segments.length
49
+ const segmentEnd = endSegmentIndex < segmentCount ? endSegmentIndex : segmentCount
50
+ let text = ''
51
+ for (let i = startSegmentIndex; i < segmentEnd; i++) {
52
+ // A soft hyphen shows only as the hyphen of a line that ends at it, and one the
53
+ // Gecko scan takes as a zero-width break never does.
54
+ const kind = segmentFlags[i] & KIND_BITS
55
+ if (
56
+ kind === SOFT_HYPHEN || kind === HARD_BREAK ||
57
+ ((kind === ZERO_WIDTH_GLUE || kind === ZERO_WIDTH_BREAK) && prepared.segments[i] .charCodeAt(0) === 0x00AD)
58
+ ) continue
59
+ if (i === startSegmentIndex && startGraphemeIndex > 0) {
60
+ text += prepared.segments[i] .slice(getGraphemeStart(prepared, i, startGraphemeIndex))
61
+ } else {
62
+ text += prepared.segments[i]
39
63
  }
40
- return isDiscretionaryLineEnd(prepared.kinds, endSegmentIndex, endGraphemeIndex) ? text + '-' : text;
64
+ }
65
+
66
+ if (endGraphemeIndex > 0 && endSegmentIndex < segmentCount) {
67
+ text += prepared.segments[endSegmentIndex] .slice(
68
+ getGraphemeStart(prepared, endSegmentIndex, startSegmentIndex === endSegmentIndex ? startGraphemeIndex : 0),
69
+ getGraphemeStart(prepared, endSegmentIndex, endGraphemeIndex),
70
+ )
71
+ }
72
+
73
+ return text
41
74
  }
42
- export function clearLineTextCaches() {
43
- sharedLineTextCaches = new WeakMap();
75
+
76
+ // A line's text: its range's, with a hyphen where it ends at a soft hyphen, whose width counted it.
77
+ export function buildLineTextFromRange(
78
+ prepared ,
79
+ startSegmentIndex ,
80
+ startGraphemeIndex ,
81
+ endSegmentIndex ,
82
+ endGraphemeIndex ,
83
+ ) {
84
+ const text = buildRangeText(prepared, startSegmentIndex, startGraphemeIndex, endSegmentIndex, endGraphemeIndex)
85
+ return isDiscretionaryLineEnd(prepared.segmentFlags, endSegmentIndex, endGraphemeIndex) ? text + '-' : text
44
86
  }