postext 0.0.1 → 0.0.3
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/LICENSE +21 -0
- package/README.md +203 -0
- package/dist/__tests__/createLayout.test.d.ts +2 -0
- package/dist/__tests__/createLayout.test.d.ts.map +1 -0
- package/dist/__tests__/createLayout.test.js +141 -0
- package/dist/__tests__/createLayout.test.js.map +1 -0
- package/dist/__tests__/exports.test.d.ts +2 -0
- package/dist/__tests__/exports.test.d.ts.map +1 -0
- package/dist/__tests__/exports.test.js +14 -0
- package/dist/__tests__/exports.test.js.map +1 -0
- package/package.json +8 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Postext contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
# postext
|
|
2
|
+
|
|
3
|
+
**A programmable typesetter for the web.**
|
|
4
|
+
|
|
5
|
+
postext is a layout engine that takes semantic content — enriched markdown with referenced resources — and applies professional editorial layout rules to produce publication-grade output. Built on top of [`@chenglou/pretext`](https://github.com/chenglou/pretext) for DOM-free, pixel-perfect text measurement.
|
|
6
|
+
|
|
7
|
+
> **Early stage** — postext is at v0.0.1. The API is under active design and not yet stable.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install postext
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Requires React >= 18 as a peer dependency.
|
|
16
|
+
|
|
17
|
+
## Quick Example
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
import { createLayout } from 'postext';
|
|
21
|
+
import type { PostextContent, PostextConfig } from 'postext';
|
|
22
|
+
|
|
23
|
+
const content: PostextContent = {
|
|
24
|
+
markdown: '# My Article\n\nFirst paragraph of the article...',
|
|
25
|
+
resources: [
|
|
26
|
+
{
|
|
27
|
+
id: 'hero',
|
|
28
|
+
type: 'image',
|
|
29
|
+
src: '/images/hero.jpg',
|
|
30
|
+
alt: 'Hero image',
|
|
31
|
+
caption: 'Photo by Jane Doe',
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
notes: [
|
|
35
|
+
{
|
|
36
|
+
id: 'note-1',
|
|
37
|
+
type: 'footnote',
|
|
38
|
+
content: 'See the original study for details.',
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const config: PostextConfig = {
|
|
44
|
+
columns: 3,
|
|
45
|
+
gutter: '24px',
|
|
46
|
+
typography: {
|
|
47
|
+
orphans: 2,
|
|
48
|
+
widows: 2,
|
|
49
|
+
hyphenation: true,
|
|
50
|
+
},
|
|
51
|
+
references: {
|
|
52
|
+
footnotes: { placement: 'columnBottom', marker: 'number' },
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const Layout = createLayout(content, config);
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## With pretext
|
|
60
|
+
|
|
61
|
+
postext is designed to work alongside [`@chenglou/pretext`](https://github.com/chenglou/pretext). **pretext** measures how much space text needs (DOM-free, 300-600x faster than DOM measurement). **postext** uses those measurements to make editorial layout decisions.
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
import { prepare, layout } from '@chenglou/pretext';
|
|
65
|
+
import { createLayout } from 'postext';
|
|
66
|
+
|
|
67
|
+
// pretext: measure text dimensions
|
|
68
|
+
const prepared = prepare(paragraphText, '16px/1.5 Inter');
|
|
69
|
+
const { height } = layout(prepared, columnWidth, 24);
|
|
70
|
+
|
|
71
|
+
// postext: apply layout rules
|
|
72
|
+
const Layout = createLayout(content, config);
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## API
|
|
76
|
+
|
|
77
|
+
### `createLayout(content, config?)`
|
|
78
|
+
|
|
79
|
+
Returns a React component that renders the laid-out content.
|
|
80
|
+
|
|
81
|
+
| Parameter | Type | Description |
|
|
82
|
+
|---|---|---|
|
|
83
|
+
| `content` | `PostextContent` | The semantic content to lay out |
|
|
84
|
+
| `config` | `PostextConfig` | Optional layout configuration |
|
|
85
|
+
|
|
86
|
+
### Types
|
|
87
|
+
|
|
88
|
+
#### `PostextContent`
|
|
89
|
+
|
|
90
|
+
The input content structure.
|
|
91
|
+
|
|
92
|
+
| Field | Type | Description |
|
|
93
|
+
|---|---|---|
|
|
94
|
+
| `markdown` | `string` | Main content in enriched markdown |
|
|
95
|
+
| `resources?` | `PostextResource[]` | Images, tables, figures, pull quotes |
|
|
96
|
+
| `notes?` | `PostextNote[]` | Footnotes, endnotes, margin notes |
|
|
97
|
+
|
|
98
|
+
#### `PostextResource`
|
|
99
|
+
|
|
100
|
+
An embeddable resource referenced within the content.
|
|
101
|
+
|
|
102
|
+
| Field | Type | Description |
|
|
103
|
+
|---|---|---|
|
|
104
|
+
| `id` | `string` | Unique identifier |
|
|
105
|
+
| `type` | `'image' \| 'table' \| 'figure' \| 'pullQuote'` | Resource type |
|
|
106
|
+
| `src?` | `string` | Source URL (for images) |
|
|
107
|
+
| `alt?` | `string` | Alt text |
|
|
108
|
+
| `caption?` | `string` | Caption text |
|
|
109
|
+
| `content?` | `string` | Inline content (for tables/pull quotes) |
|
|
110
|
+
| `width?` | `number` | Width in pixels |
|
|
111
|
+
| `height?` | `number` | Height in pixels |
|
|
112
|
+
|
|
113
|
+
#### `PostextNote`
|
|
114
|
+
|
|
115
|
+
A reference note attached to the content.
|
|
116
|
+
|
|
117
|
+
| Field | Type | Description |
|
|
118
|
+
|---|---|---|
|
|
119
|
+
| `id` | `string` | Unique identifier |
|
|
120
|
+
| `type` | `'footnote' \| 'endnote' \| 'marginNote'` | Note type |
|
|
121
|
+
| `content` | `string` | Note content |
|
|
122
|
+
| `marker?` | `string` | Custom marker (defaults to auto-numbering) |
|
|
123
|
+
|
|
124
|
+
#### `PostextConfig`
|
|
125
|
+
|
|
126
|
+
Top-level layout configuration.
|
|
127
|
+
|
|
128
|
+
| Field | Type | Description |
|
|
129
|
+
|---|---|---|
|
|
130
|
+
| `columns?` | `number` | Number of columns |
|
|
131
|
+
| `gutter?` | `string` | Space between columns (e.g., `'24px'`) |
|
|
132
|
+
| `columnConfig?` | `ColumnConfig` | Detailed column settings |
|
|
133
|
+
| `resourcePlacement?` | `ResourcePlacementConfig` | Resource placement strategy |
|
|
134
|
+
| `typography?` | `TypographyConfig` | Typographic quality rules |
|
|
135
|
+
| `references?` | `ReferenceConfig` | Footnote/endnote/numbering settings |
|
|
136
|
+
| `sectionOverrides?` | `PostextSectionOverride[]` | Per-section rule overrides |
|
|
137
|
+
| `renderer?` | `'web' \| 'pdf'` | Output format |
|
|
138
|
+
|
|
139
|
+
#### `ColumnConfig`
|
|
140
|
+
|
|
141
|
+
| Field | Type | Description |
|
|
142
|
+
|---|---|---|
|
|
143
|
+
| `count?` | `number` | Number of columns |
|
|
144
|
+
| `gutter?` | `string` | Space between columns |
|
|
145
|
+
| `columnRule?` | `{ width?, style?, color? }` | Visual rule between columns |
|
|
146
|
+
| `balancing?` | `boolean` | Equalize column heights |
|
|
147
|
+
|
|
148
|
+
#### `ResourcePlacementConfig`
|
|
149
|
+
|
|
150
|
+
| Field | Type | Description |
|
|
151
|
+
|---|---|---|
|
|
152
|
+
| `defaultStrategy?` | `PlacementStrategy` | Default placement strategy |
|
|
153
|
+
| `deferPlacement?` | `boolean` | Find next available position if resource doesn't fit |
|
|
154
|
+
| `preserveAspectRatio?` | `boolean` | Maintain aspect ratio when sizing |
|
|
155
|
+
|
|
156
|
+
#### `PlacementStrategy`
|
|
157
|
+
|
|
158
|
+
```ts
|
|
159
|
+
type PlacementStrategy =
|
|
160
|
+
| 'topOfColumn'
|
|
161
|
+
| 'inline'
|
|
162
|
+
| 'floatLeft'
|
|
163
|
+
| 'floatRight'
|
|
164
|
+
| 'fullWidthBreak'
|
|
165
|
+
| 'margin';
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
#### `TypographyConfig`
|
|
169
|
+
|
|
170
|
+
| Field | Type | Description |
|
|
171
|
+
|---|---|---|
|
|
172
|
+
| `orphans?` | `number` | Min lines at top of column |
|
|
173
|
+
| `widows?` | `number` | Min lines at bottom of column |
|
|
174
|
+
| `hyphenation?` | `boolean` | Enable hyphenation |
|
|
175
|
+
| `ragOptimization?` | `boolean` | Minimize ragged right edges |
|
|
176
|
+
| `spacing?` | `object` | Space before/after headings, figures, block quotes |
|
|
177
|
+
| `keepTogether?` | `object` | Keep heading with paragraph, figure with caption |
|
|
178
|
+
|
|
179
|
+
#### `ReferenceConfig`
|
|
180
|
+
|
|
181
|
+
| Field | Type | Description |
|
|
182
|
+
|---|---|---|
|
|
183
|
+
| `footnotes?` | `{ placement?, marker? }` | Footnote placement and marker style |
|
|
184
|
+
| `figureNumbering?` | `boolean` | Auto-number figures |
|
|
185
|
+
| `tableNumbering?` | `boolean` | Auto-number tables |
|
|
186
|
+
| `marginNotes?` | `boolean` | Enable margin notes |
|
|
187
|
+
|
|
188
|
+
#### `PostextSectionOverride`
|
|
189
|
+
|
|
190
|
+
| Field | Type | Description |
|
|
191
|
+
|---|---|---|
|
|
192
|
+
| `selector` | `string` | CSS selector or content marker |
|
|
193
|
+
| `columns?` | `ColumnConfig` | Column overrides for this section |
|
|
194
|
+
| `typography?` | `TypographyConfig` | Typography overrides |
|
|
195
|
+
| `resourcePlacement?` | `ResourcePlacementConfig` | Placement overrides |
|
|
196
|
+
|
|
197
|
+
## Full Documentation
|
|
198
|
+
|
|
199
|
+
For the project vision, architecture, roadmap, and contributing guidelines, see the [project README](https://github.com/AUsername/postext#readme).
|
|
200
|
+
|
|
201
|
+
## License
|
|
202
|
+
|
|
203
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createLayout.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/createLayout.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { createElement } from "react";
|
|
3
|
+
import { createLayout } from "../createLayout";
|
|
4
|
+
describe("createLayout", () => {
|
|
5
|
+
const minimalContent = {
|
|
6
|
+
markdown: "# Hello\n\nA paragraph of text.",
|
|
7
|
+
};
|
|
8
|
+
it("returns a React function component", () => {
|
|
9
|
+
const Layout = createLayout(minimalContent);
|
|
10
|
+
expect(typeof Layout).toBe("function");
|
|
11
|
+
});
|
|
12
|
+
it("returned component has displayName 'PostextLayout'", () => {
|
|
13
|
+
const Layout = createLayout(minimalContent);
|
|
14
|
+
expect(Layout.displayName).toBe("PostextLayout");
|
|
15
|
+
});
|
|
16
|
+
it("returned component renders without throwing", () => {
|
|
17
|
+
const Layout = createLayout(minimalContent);
|
|
18
|
+
// createElement exercises the component function
|
|
19
|
+
expect(() => createElement(Layout)).not.toThrow();
|
|
20
|
+
});
|
|
21
|
+
it("accepts content with resources", () => {
|
|
22
|
+
const content = {
|
|
23
|
+
markdown: "# Article\n\nSome text with a figure reference.",
|
|
24
|
+
resources: [
|
|
25
|
+
{
|
|
26
|
+
id: "fig-1",
|
|
27
|
+
type: "image",
|
|
28
|
+
src: "/photo.jpg",
|
|
29
|
+
alt: "A photo",
|
|
30
|
+
caption: "Figure 1",
|
|
31
|
+
width: 800,
|
|
32
|
+
height: 600,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: "tbl-1",
|
|
36
|
+
type: "table",
|
|
37
|
+
content: "| A | B |\n|---|---|\n| 1 | 2 |",
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: "pq-1",
|
|
41
|
+
type: "pullQuote",
|
|
42
|
+
content: "A compelling quote.",
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
};
|
|
46
|
+
const Layout = createLayout(content);
|
|
47
|
+
expect(Layout.displayName).toBe("PostextLayout");
|
|
48
|
+
});
|
|
49
|
+
it("accepts content with notes", () => {
|
|
50
|
+
const content = {
|
|
51
|
+
markdown: "Text with a footnote reference.",
|
|
52
|
+
notes: [
|
|
53
|
+
{ id: "fn-1", type: "footnote", content: "A footnote.", marker: "1" },
|
|
54
|
+
{ id: "en-1", type: "endnote", content: "An endnote." },
|
|
55
|
+
{ id: "mn-1", type: "marginNote", content: "A margin note." },
|
|
56
|
+
],
|
|
57
|
+
};
|
|
58
|
+
const Layout = createLayout(content);
|
|
59
|
+
expect(Layout.displayName).toBe("PostextLayout");
|
|
60
|
+
});
|
|
61
|
+
it("accepts a full config object", () => {
|
|
62
|
+
const config = {
|
|
63
|
+
columns: 2,
|
|
64
|
+
gutter: "2rem",
|
|
65
|
+
columnConfig: {
|
|
66
|
+
count: 2,
|
|
67
|
+
gutter: "2rem",
|
|
68
|
+
columnRule: { width: "1px", style: "solid", color: "#ccc" },
|
|
69
|
+
balancing: true,
|
|
70
|
+
},
|
|
71
|
+
typography: {
|
|
72
|
+
orphans: 2,
|
|
73
|
+
widows: 2,
|
|
74
|
+
hyphenation: true,
|
|
75
|
+
ragOptimization: true,
|
|
76
|
+
spacing: {
|
|
77
|
+
beforeHeading: "1.5em",
|
|
78
|
+
afterHeading: "0.5em",
|
|
79
|
+
beforeFigure: "1em",
|
|
80
|
+
afterFigure: "1em",
|
|
81
|
+
beforeBlockQuote: "1em",
|
|
82
|
+
afterBlockQuote: "1em",
|
|
83
|
+
},
|
|
84
|
+
keepTogether: {
|
|
85
|
+
headingWithParagraph: true,
|
|
86
|
+
figureWithCaption: true,
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
resourcePlacement: {
|
|
90
|
+
defaultStrategy: "topOfColumn",
|
|
91
|
+
deferPlacement: false,
|
|
92
|
+
preserveAspectRatio: true,
|
|
93
|
+
},
|
|
94
|
+
references: {
|
|
95
|
+
footnotes: { placement: "columnBottom", marker: "number" },
|
|
96
|
+
figureNumbering: true,
|
|
97
|
+
tableNumbering: true,
|
|
98
|
+
marginNotes: true,
|
|
99
|
+
},
|
|
100
|
+
sectionOverrides: [
|
|
101
|
+
{
|
|
102
|
+
selector: ".intro",
|
|
103
|
+
columns: { count: 1 },
|
|
104
|
+
typography: { orphans: 3 },
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
renderer: "web",
|
|
108
|
+
};
|
|
109
|
+
const Layout = createLayout(minimalContent, config);
|
|
110
|
+
expect(Layout.displayName).toBe("PostextLayout");
|
|
111
|
+
});
|
|
112
|
+
it("accepts config with pdf renderer", () => {
|
|
113
|
+
const Layout = createLayout(minimalContent, { renderer: "pdf" });
|
|
114
|
+
expect(Layout.displayName).toBe("PostextLayout");
|
|
115
|
+
});
|
|
116
|
+
it("works with no config (optional)", () => {
|
|
117
|
+
const Layout = createLayout(minimalContent);
|
|
118
|
+
expect(Layout.displayName).toBe("PostextLayout");
|
|
119
|
+
});
|
|
120
|
+
it("works with empty config", () => {
|
|
121
|
+
const Layout = createLayout(minimalContent, {});
|
|
122
|
+
expect(Layout.displayName).toBe("PostextLayout");
|
|
123
|
+
});
|
|
124
|
+
it("accepts all resource placement strategies", () => {
|
|
125
|
+
const strategies = [
|
|
126
|
+
"topOfColumn",
|
|
127
|
+
"inline",
|
|
128
|
+
"floatLeft",
|
|
129
|
+
"floatRight",
|
|
130
|
+
"fullWidthBreak",
|
|
131
|
+
"margin",
|
|
132
|
+
];
|
|
133
|
+
for (const strategy of strategies) {
|
|
134
|
+
const Layout = createLayout(minimalContent, {
|
|
135
|
+
resourcePlacement: { defaultStrategy: strategy },
|
|
136
|
+
});
|
|
137
|
+
expect(Layout.displayName).toBe("PostextLayout");
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
//# sourceMappingURL=createLayout.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createLayout.test.js","sourceRoot":"","sources":["../../src/__tests__/createLayout.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,MAAM,cAAc,GAAmB;QACrC,QAAQ,EAAE,iCAAiC;KAC5C,CAAC;IAEF,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;QAC5C,MAAM,MAAM,GAAG,YAAY,CAAC,cAAc,CAAC,CAAC;QAC5C,MAAM,CAAC,OAAO,MAAM,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oDAAoD,EAAE,GAAG,EAAE;QAC5D,MAAM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Q;YACR,WAAW;YACX,YAAY;YACZ,gBAAgB;YAChB,QAAQ;SACA,CAAC;QAEX,KAAK,MAAM,QAAQ,IAAI,UAAU,EAAE,CAAC;YAClC,MAAM,MAAM,GAAG,YAAY,CAAC,cAAc,EAAE;gBAC1C,iBAAiB,EAAE,EAAE,eAAe,EAAE,QAAQ,EAAE;aACjD,CAAC,CAAC;YACH,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACnD,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exports.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/exports.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import * as postext from "../index";
|
|
3
|
+
describe("package exports", () => {
|
|
4
|
+
it("exports createLayout function", () => {
|
|
5
|
+
expect(postext.createLayout).toBeDefined();
|
|
6
|
+
expect(typeof postext.createLayout).toBe("function");
|
|
7
|
+
});
|
|
8
|
+
it("does not export unexpected values", () => {
|
|
9
|
+
const exportedKeys = Object.keys(postext);
|
|
10
|
+
// Only createLayout should be a runtime export; types are compile-time only
|
|
11
|
+
expect(exportedKeys).toEqual(["createLayout"]);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=exports.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exports.test.js","sourceRoot":"","sources":["../../src/__tests__/exports.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,KAAK,OAAO,MAAM,UAAU,CAAC;AAEpC,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;QACvC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,WAAW,EAAE,CAAC;QAC3C,MAAM,CAAC,OAAO,OAAO,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;QAC3C,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1C,4EAA4E;QAC5E,MAAM,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "postext",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "A programmable typesetter for the web",
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"description": "A programmable typesetter for the web. Layout engine that applies professional editorial rules — columns, orphan/widow prevention, resource placement, footnotes — to semantic content. Built on @chenglou/pretext for DOM-free text measurement.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -23,14 +23,19 @@
|
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/react": "^19",
|
|
26
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
27
|
+
"eslint": "^9.39.4",
|
|
26
28
|
"react": "^19.2.4",
|
|
27
29
|
"typescript": "latest",
|
|
30
|
+
"typescript-eslint": "^8.58.0",
|
|
31
|
+
"vitest": "^4.1.3",
|
|
28
32
|
"@postext/typescript-config": "0.0.0"
|
|
29
33
|
},
|
|
30
34
|
"scripts": {
|
|
31
35
|
"build": "tsc",
|
|
32
36
|
"dev": "tsc --watch",
|
|
33
37
|
"check-types": "tsc --noEmit",
|
|
34
|
-
"lint": "eslint ."
|
|
38
|
+
"lint": "eslint .",
|
|
39
|
+
"test": "vitest run"
|
|
35
40
|
}
|
|
36
41
|
}
|