@agentshouse/kit 0.2.1-cb6679d048e60 → 0.2.1-cc988e43abeeb

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/dist/blocks.js DELETED
@@ -1,51 +0,0 @@
1
- const FENCE = /^\s*(`{3,}|~{3,})\s*(\S*)/;
2
- export function blocksOf(text) {
3
- const blocks = [];
4
- let paragraph = [];
5
- let fence = null;
6
- const closeParagraph = () => {
7
- const joined = paragraph.join('\n').trim();
8
- if (joined.length > 0)
9
- blocks.push({ type: 'paragraph', text: joined });
10
- paragraph = [];
11
- };
12
- const closeFence = () => {
13
- const joined = fence.lines.join('\n');
14
- if (joined.length > 0)
15
- blocks.push({ type: 'code', language: fence.language, text: joined });
16
- fence = null;
17
- };
18
- for (const line of text.split('\n')) {
19
- if (fence !== null) {
20
- if (line.trim().startsWith(fence.marker))
21
- closeFence();
22
- else
23
- fence.lines.push(line);
24
- continue;
25
- }
26
- const opening = FENCE.exec(line);
27
- if (opening !== null) {
28
- closeParagraph();
29
- fence = { marker: opening[1], language: opening[2] || null, lines: [] };
30
- }
31
- else if (line.trim().length === 0) {
32
- closeParagraph();
33
- }
34
- else {
35
- paragraph.push(line);
36
- }
37
- }
38
- if (fence !== null)
39
- closeFence();
40
- closeParagraph();
41
- return blocks;
42
- }
43
- export function firstChange(before, after) {
44
- let index = 0;
45
- while (index < before.length &&
46
- index < after.length &&
47
- JSON.stringify(before[index]) === JSON.stringify(after[index])) {
48
- index++;
49
- }
50
- return index;
51
- }