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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rapier-markdown-kit",
3
- "version": "1.1.101",
3
+ "version": "1.1.104",
4
4
  "description": "Read, render and write Self-contained Markdown: one .md file that carries its pictures, drawings and layout, and that any Markdown app can read. HTML renderer, stylesheet, text layout, Will/1 agent permissions, and an edit history with authorship and offline merge. MIT, no dependencies.",
5
5
  "keywords": [
6
6
  "markdown",
@@ -43,6 +43,7 @@
43
43
  "./layout": "./dist/kit/layout.mjs",
44
44
  "./marks": "./dist/kit/marks.mjs",
45
45
  "./model": "./dist/kit/model.mjs",
46
+ "./typography": "./dist/kit/typography.mjs",
46
47
  "./will": "./dist/kit/will.mjs",
47
48
  "./assets": "./dist/kit/assets.mjs",
48
49
  "./style.css": "./style.css",
package/style.css CHANGED
@@ -138,6 +138,10 @@
138
138
  .md-render p[data-md-hyphens="auto"]{hyphens:auto;text-wrap:pretty}
139
139
  .md-render p[data-md-hyphens="auto"] :is(code,kbd,samp,math){hyphens:none;text-wrap:wrap;text-justify:none}
140
140
  .md-render [data-rapier-typography-break]::after{content:'\A';white-space:pre}
141
+ .md-render p[data-rapier-typography-fit]{text-align:justify!important;text-align-last:start;text-wrap:nowrap;hyphens:none;hanging-punctuation:none}
142
+ .md-render p[data-rapier-typography-fit] :is(a,span,em,i,strong,b,del,s,mark,code,kbd,samp,u,ins,abbr){text-wrap:nowrap;hyphens:none;hanging-punctuation:none}
143
+ .md-render [data-rapier-typography-separator]{font-size:0;line-height:0;word-spacing:0!important;letter-spacing:0!important}
144
+ .md-render [data-rapier-typography-break="hyphen"]::before{content:var(--md-fit-hyphen,'-')}
141
145
  .md-render p[data-rapier-typography-ragged]{text-align:start!important}
142
146
  .md-render p[data-md-lines]:not([data-rapier-typography-protected-initial])::first-letter{
143
147
  initial-letter:var(--md-drop-lines,normal);
@@ -638,6 +642,8 @@
638
642
  font-size: var(--md-text-sm);
639
643
  color: var(--md-color-text-secondary);
640
644
  }
645
+ /* A view preference can keep embedded SVGs on their original light-paper colours. */
646
+ html[data-invert-image-alpha="off"] :is(img,.md-render svg.rapier-native-flowchart){color-scheme:light}
641
647
  .md-render img{
642
648
  max-width:100%;height:auto;
643
649
  border:0;
@@ -787,3 +793,6 @@
787
793
  @media print{
788
794
  :is(.md-render[data-md-space],[data-md-space] .md-render) pre[data-rapier-code-lines]{padding-block-start:calc(var(--md-line) / 2 - 1px)!important}
789
795
  }
796
+
797
+ /* Authored run sizes supply their own line box; surrounding block rhythm is unchanged. */
798
+ .md-render [data-md-size]{line-height:normal}
@@ -1,151 +0,0 @@
1
- /*! Pretext 0.0.9 | MIT | Copyright (c) 2026 Pretext contributors */
2
- import { latin1BidiTypes, nonLatin1BidiRanges } from './generated/bidi-data.js';
3
- function classifyCodePoint(codePoint) {
4
- if (codePoint <= 0x00FF) return latin1BidiTypes[codePoint];
5
- let lo = 0;
6
- let hi = nonLatin1BidiRanges.length - 1;
7
- while(lo <= hi){
8
- const mid = lo + hi >> 1;
9
- const range = nonLatin1BidiRanges[mid];
10
- if (codePoint < range[0]) {
11
- hi = mid - 1;
12
- continue;
13
- }
14
- if (codePoint > range[1]) {
15
- lo = mid + 1;
16
- continue;
17
- }
18
- return range[2];
19
- }
20
- return 'L';
21
- }
22
- function computeBidiLevels(str) {
23
- const len = str.length;
24
- if (len === 0) return null;
25
- const types = new Array(len);
26
- let paragraphHasBidi = false;
27
- let paragraphStart = 0;
28
- let levels = null;
29
- for(let i = 0; i < len;){
30
- const first = str.charCodeAt(i);
31
- let codePoint = first;
32
- let codeUnitLength = 1;
33
- if (first >= 0xD800 && first <= 0xDBFF && i + 1 < len) {
34
- const second = str.charCodeAt(i + 1);
35
- if (second >= 0xDC00 && second <= 0xDFFF) {
36
- codePoint = (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
37
- codeUnitLength = 2;
38
- }
39
- }
40
- const t = classifyCodePoint(codePoint);
41
- if (t === 'R' || t === 'AL' || t === 'AN') paragraphHasBidi = true;
42
- for(let j = 0; j < codeUnitLength; j++){
43
- types[i + j] = t;
44
- }
45
- if (t === 'B') {
46
- if (paragraphHasBidi) {
47
- levels ??= new Int8Array(len);
48
- levels[i] = resolveParagraphLevels(types, levels, paragraphStart, i);
49
- }
50
- paragraphStart = i + codeUnitLength;
51
- paragraphHasBidi = false;
52
- }
53
- i += codeUnitLength;
54
- }
55
- if (paragraphHasBidi) {
56
- levels ??= new Int8Array(len);
57
- resolveParagraphLevels(types, levels, paragraphStart, len);
58
- }
59
- return levels;
60
- }
61
- function resolveParagraphLevels(types, levels, start, end) {
62
- let startLevel = 0;
63
- for(let i = start; i < end; i++){
64
- const t = types[i];
65
- if (t === 'L') {
66
- startLevel = 0;
67
- break;
68
- }
69
- if (t === 'R' || t === 'AL') {
70
- startLevel = 1;
71
- break;
72
- }
73
- }
74
- const e = startLevel & 1 ? 'R' : 'L';
75
- const sor = e;
76
- let lastType = sor;
77
- for(let i = start; i < end; i++){
78
- if (types[i] === 'NSM') types[i] = lastType;
79
- else lastType = types[i];
80
- }
81
- lastType = sor;
82
- for(let i = start; i < end; i++){
83
- const t = types[i];
84
- if (t === 'EN') types[i] = lastType === 'AL' ? 'AN' : 'EN';
85
- else if (t === 'R' || t === 'L' || t === 'AL') lastType = t;
86
- }
87
- for(let i = start; i < end; i++){
88
- if (types[i] === 'AL') types[i] = 'R';
89
- }
90
- for(let i = start + 1; i < end - 1; i++){
91
- if (types[i] === 'ES' && types[i - 1] === 'EN' && types[i + 1] === 'EN') {
92
- types[i] = 'EN';
93
- }
94
- if (types[i] === 'CS' && (types[i - 1] === 'EN' || types[i - 1] === 'AN') && types[i + 1] === types[i - 1]) {
95
- types[i] = types[i - 1];
96
- }
97
- }
98
- for(let i = start; i < end; i++){
99
- if (types[i] !== 'EN') continue;
100
- let j;
101
- for(j = i - 1; j >= start && types[j] === 'ET'; j--)types[j] = 'EN';
102
- for(j = i + 1; j < end && types[j] === 'ET'; j++)types[j] = 'EN';
103
- }
104
- for(let i = start; i < end; i++){
105
- const t = types[i];
106
- if (t === 'WS' || t === 'ES' || t === 'ET' || t === 'CS') types[i] = 'ON';
107
- }
108
- lastType = sor;
109
- for(let i = start; i < end; i++){
110
- const t = types[i];
111
- if (t === 'EN') types[i] = lastType === 'L' ? 'L' : 'EN';
112
- else if (t === 'R' || t === 'L') lastType = t;
113
- }
114
- for(let i = start; i < end; i++){
115
- if (types[i] !== 'ON') continue;
116
- let runEnd = i + 1;
117
- while(runEnd < end && types[runEnd] === 'ON')runEnd++;
118
- const before = i > start ? types[i - 1] : sor;
119
- const after = runEnd < end ? types[runEnd] : sor;
120
- const bDir = before !== 'L' ? 'R' : 'L';
121
- const aDir = after !== 'L' ? 'R' : 'L';
122
- if (bDir === aDir) {
123
- for(let j = i; j < runEnd; j++)types[j] = bDir;
124
- }
125
- i = runEnd - 1;
126
- }
127
- for(let i = start; i < end; i++){
128
- if (types[i] === 'ON') types[i] = e;
129
- }
130
- for(let i = start; i < end; i++){
131
- const t = types[i];
132
- let level = startLevel;
133
- if ((startLevel & 1) === 0) {
134
- if (t === 'R') level++;
135
- else if (t === 'AN' || t === 'EN') level += 2;
136
- } else if (t === 'L' || t === 'AN' || t === 'EN') {
137
- level++;
138
- }
139
- levels[i] = level;
140
- }
141
- return startLevel;
142
- }
143
- export function computeSegmentLevels(normalized, segStarts) {
144
- const bidiLevels = computeBidiLevels(normalized);
145
- if (bidiLevels === null) return null;
146
- const segLevels = new Int8Array(segStarts.length);
147
- for(let i = 0; i < segStarts.length; i++){
148
- segLevels[i] = bidiLevels[segStarts[i]];
149
- }
150
- return segLevels;
151
- }