verso-cms 0.0.0-stage → 0.1.2

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 (108) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +288 -2
  3. package/bin/verso.js +16 -0
  4. package/editor/door.js +139 -0
  5. package/editor/editor.js +1880 -0
  6. package/editor/elevate.css +2158 -0
  7. package/editor/ext-attrs.js +87 -0
  8. package/editor/ext-blocks.js +422 -0
  9. package/editor/ext-builder.js +819 -0
  10. package/editor/ext-channels.js +574 -0
  11. package/editor/ext-components.js +160 -0
  12. package/editor/ext-history.js +242 -0
  13. package/editor/ext-palette.js +307 -0
  14. package/editor/ext-people.js +345 -0
  15. package/editor/ext-repeaters.js +143 -0
  16. package/editor/ext-screens.js +94 -0
  17. package/editor/ext-site-settings.js +318 -0
  18. package/editor/ext-site-view.js +632 -0
  19. package/editor/ext-tokens.js +1166 -0
  20. package/editor/new-page.js +252 -0
  21. package/editor/rich.js +23 -0
  22. package/package.json +69 -4
  23. package/src/blocks.js +269 -0
  24. package/src/box.js +339 -0
  25. package/src/build.js +210 -0
  26. package/src/cli.js +161 -0
  27. package/src/color.js +137 -0
  28. package/src/components.js +223 -0
  29. package/src/elevate.js +74 -0
  30. package/src/errors.js +46 -0
  31. package/src/extensions/README.md +70 -0
  32. package/src/extensions/blocks.js +294 -0
  33. package/src/extensions/builder.js +734 -0
  34. package/src/extensions/channels.js +341 -0
  35. package/src/extensions/components.js +141 -0
  36. package/src/extensions/history.js +169 -0
  37. package/src/extensions/palette.js +31 -0
  38. package/src/extensions/people.js +113 -0
  39. package/src/extensions/site-settings.js +251 -0
  40. package/src/extensions/site-view.js +381 -0
  41. package/src/extensions/tags.js +15 -0
  42. package/src/extensions/tokens.js +587 -0
  43. package/src/fonts.js +139 -0
  44. package/src/git.js +419 -0
  45. package/src/html-edit.js +942 -0
  46. package/src/images.js +116 -0
  47. package/src/people.js +286 -0
  48. package/src/rich.js +124 -0
  49. package/src/scaffold.js +185 -0
  50. package/src/screens.js +65 -0
  51. package/src/server.js +693 -0
  52. package/src/site.js +618 -0
  53. package/src/template.js +915 -0
  54. package/src/video.js +29 -0
  55. package/starter/Dockerfile +20 -0
  56. package/starter/README.md +49 -0
  57. package/starter/blocks/call-to-action.html +6 -0
  58. package/starter/blocks/features.html +15 -0
  59. package/starter/blocks/hero.html +8 -0
  60. package/starter/blocks/image-and-text.html +8 -0
  61. package/starter/blocks/latest-posts.html +20 -0
  62. package/starter/blocks/post-index.html +30 -0
  63. package/starter/blocks/quote.html +9 -0
  64. package/starter/blocks/site-footer.html +8 -0
  65. package/starter/blocks/site-nav.html +8 -0
  66. package/starter/blocks/tag-list.html +10 -0
  67. package/starter/blocks/tagged-posts.html +19 -0
  68. package/starter/blocks/team.html +15 -0
  69. package/starter/blocks/text.html +4 -0
  70. package/starter/content/404/page.json +21 -0
  71. package/starter/content/about/page.json +65 -0
  72. package/starter/content/journal/designing-for-the-morning-shift/body.html +22 -0
  73. package/starter/content/journal/designing-for-the-morning-shift/checklist.jpg +0 -0
  74. package/starter/content/journal/designing-for-the-morning-shift/cover.jpg +0 -0
  75. package/starter/content/journal/designing-for-the-morning-shift/page.json +17 -0
  76. package/starter/content/journal/page.json +19 -0
  77. package/starter/content/journal/the-first-week/body.html +17 -0
  78. package/starter/content/journal/the-first-week/cover.jpg +0 -0
  79. package/starter/content/journal/the-first-week/page.json +17 -0
  80. package/starter/content/journal/the-first-week/wall-of-cards.jpg +0 -0
  81. package/starter/content/page.json +94 -0
  82. package/starter/content/site.json +88 -0
  83. package/starter/content/studio-table.jpg +0 -0
  84. package/starter/content/topics/page.json +27 -0
  85. package/starter/dockerignore +5 -0
  86. package/starter/elevate/config/design.ts +30 -0
  87. package/starter/elevate/config/elevate.ts +16 -0
  88. package/starter/elevate/config/syntax.ts +6 -0
  89. package/starter/elevate/design/site.ts +9 -0
  90. package/starter/elevate/design/tokens.json +20 -0
  91. package/starter/elevate/extend/fonts.css +1 -0
  92. package/starter/gitignore +6 -0
  93. package/starter/netlify.toml +5 -0
  94. package/starter/parts/.gitkeep +0 -0
  95. package/starter/public/favicon.svg +1 -0
  96. package/starter/templates/page.html +20 -0
  97. package/starter/templates/page.layout.json +23 -0
  98. package/starter/templates/post.html +65 -0
  99. package/starter/verso.defaults.json +33 -0
  100. package/starter-blank/blocks/site-footer.html +3 -0
  101. package/starter-blank/blocks/site-nav.html +8 -0
  102. package/starter-blank/blocks/text.html +4 -0
  103. package/starter-blank/content/404/page.json +18 -0
  104. package/starter-blank/content/page.json +18 -0
  105. package/starter-blank/content/site.json +36 -0
  106. package/starter-blank/elevate/design/tokens.json +10 -0
  107. package/starter-blank/templates/page.html +17 -0
  108. package/starter-blank/verso.defaults.json +26 -0
package/package.json CHANGED
@@ -1,6 +1,71 @@
1
1
  {
2
2
  "name": "verso-cms",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.2",
4
+ "description": "A repo-first CMS for Elevate. Edit the real page in your browser, then publish with git.",
5
+ "scripts": {
6
+ "build:ui": "tsx elevate/core/index.ts build && npm run build:rich",
7
+ "test": "node --test \"test/*.test.js\"",
8
+ "build:rich": "esbuild editor/rich.src.js --bundle --format=esm --minify --target=es2020 --outfile=editor/rich.js",
9
+ "elevate": "tsx elevate/core/index.ts"
10
+ },
11
+ "keywords": [
12
+ "cms",
13
+ "git",
14
+ "static-site",
15
+ "elevate",
16
+ "css"
17
+ ],
18
+ "author": "DesignInTheBlack",
19
+ "license": "MIT",
20
+ "dependencies": {
21
+ "chokidar": "^4.0.3",
22
+ "image-size": "^2.1.0",
23
+ "jimp": "^1.6.1",
24
+ "sanitize-html": "^2.18.2",
25
+ "tsx": "^4.23.15"
26
+ },
27
+ "devDependencies": {
28
+ "elevate-framework": "^1.3.1",
29
+ "esbuild": "^0.28.2",
30
+ "prosemirror-commands": "^1.7.2",
31
+ "prosemirror-dropcursor": "^1.8.4",
32
+ "prosemirror-gapcursor": "^1.4.1",
33
+ "prosemirror-history": "^1.5.1",
34
+ "prosemirror-inputrules": "^1.6.0",
35
+ "prosemirror-keymap": "^1.2.3",
36
+ "prosemirror-model": "^1.25.13",
37
+ "prosemirror-schema-list": "^1.6.0",
38
+ "prosemirror-state": "^1.4.4",
39
+ "prosemirror-tables": "^1.8.5",
40
+ "prosemirror-view": "^1.42.9"
41
+ },
42
+ "type": "module",
43
+ "bin": {
44
+ "verso": "bin/verso.js"
45
+ },
46
+ "engines": {
47
+ "node": "^20.19.0 || >=22.12.0"
48
+ },
49
+ "files": [
50
+ "bin",
51
+ "src",
52
+ "editor/editor.js",
53
+ "editor/elevate.css",
54
+ "starter",
55
+ "starter-blank",
56
+ "README.md",
57
+ "LICENSE",
58
+ "editor/rich.js",
59
+ "editor/new-page.js",
60
+ "editor/ext-*.js",
61
+ "editor/door.js"
62
+ ],
63
+ "repository": {
64
+ "type": "git",
65
+ "url": "git+https://github.com/DesignInTheBlack/verso.git"
66
+ },
67
+ "homepage": "https://github.com/DesignInTheBlack/verso#readme",
68
+ "bugs": {
69
+ "url": "https://github.com/DesignInTheBlack/verso/issues"
70
+ }
71
+ }
package/src/blocks.js ADDED
@@ -0,0 +1,269 @@
1
+ // Blocks: small templates in blocks/ that are stacked into slots.
2
+ //
3
+ // A page's block content lives in page.json under "blocks":
4
+ // { "sections": [ { "id": "b-k3x9", "block": "feature", "fields": { … }, "blocks": { "items": [ … ] } } ] }
5
+ // Each instance has an id that never changes, so the editor can name a block
6
+ // field as "@<id>.<field>" however the blocks are moved around.
7
+
8
+ import { randomBytes } from 'crypto';
9
+ import path from 'path';
10
+ import { VersoError } from './errors.js';
11
+ import { humanize, getColors } from './template.js';
12
+ import { sanitizeRich, richIsEmpty, IMAGE_FILE } from './rich.js';
13
+ import { expandList, expandBlocks, findPart, topBlocks, writeComponent } from './components.js';
14
+
15
+ export const newId = () => `b-${randomBytes(3).toString('hex')}`;
16
+
17
+ // Calls fn(instance, list, index, owner, slot) for every block, depth first.
18
+ export function walkBlocks(blocks, fn, owner = '') {
19
+ Object.entries(blocks || {}).forEach(([slot, list]) => {
20
+ if (!Array.isArray(list)) return;
21
+ list.forEach((inst, index) => {
22
+ fn(inst, list, index, owner, slot);
23
+ walkBlocks(inst?.blocks, fn, inst?.id);
24
+ });
25
+ });
26
+ }
27
+
28
+ export function findBlock(page, id) {
29
+ let found = null;
30
+ walkBlocks(page.blocks, (inst, list, index, owner, slot) => {
31
+ if (!found && inst?.id === id) found = { inst, list, index, owner, slot };
32
+ });
33
+ return found;
34
+ }
35
+
36
+ // The template that declares a slot: the page's own, or the block that owns it.
37
+ export function slotField(page, template, blocks, owner, slot) {
38
+ if (!owner) return { field: template.fields.get(slot), holder: page };
39
+ const found = findBlock(page, owner);
40
+ if (!found) return { field: null, holder: null };
41
+ return { field: blocks.get(found.inst.block)?.fields.get(slot) || null, holder: found.inst };
42
+ }
43
+
44
+ export const allows = (field, name) => !field.tools.length || field.tools.includes(name);
45
+
46
+ // The list a block can go into, created if it's empty. Throws in plain words
47
+ // when the slot doesn't exist or doesn't take that block.
48
+ export function slotList(page, template, blocks, target, blockName) {
49
+ const [owner, slot] = String(target || '').split(':');
50
+ const { field, holder } = slotField(page, template, blocks, owner, slot);
51
+ if (!field || field.type !== 'blocks') throw new VersoError('That place on the page no longer takes blocks.');
52
+ if (blockName && !allows(field, blockName)) {
53
+ throw new VersoError(`${humanize(blockName)} can't go there. That spot takes ${field.tools.map(humanize).join(', ')}.`);
54
+ }
55
+ holder.blocks = holder.blocks || {};
56
+ holder.blocks[slot] = Array.isArray(holder.blocks[slot]) ? holder.blocks[slot] : [];
57
+ return holder.blocks[slot];
58
+ }
59
+
60
+ export function cloneWithNewIds(inst) {
61
+ const copy = JSON.parse(JSON.stringify(inst));
62
+ const renew = (b) => {
63
+ b.id = newId();
64
+ Object.values(b.blocks || {}).forEach((list) => list.forEach(renew));
65
+ };
66
+ renew(copy);
67
+ return copy;
68
+ }
69
+
70
+ // Checks a page's blocks against the templates. Returns problems.
71
+ // Component instances are checked as the blocks they expand into.
72
+ export function checkBlocks(page, template, blocks, { strict = true } = {}) {
73
+ const problems = [];
74
+ const where = { file: page.file };
75
+ const checkInst = (inst, field, slot, label, inComponent) => {
76
+ const bt = blocks.get(inst.block);
77
+ if (!bt) { problems.push(new VersoError(`${label} uses blocks/${inst.block}.html, which doesn't exist.`, where)); return; }
78
+ if (!allows(field, inst.block)) problems.push(new VersoError(`${label} is in "${slot}", which only takes ${field.tools.map(humanize).join(', ')}.`, where));
79
+ Object.entries(inst.fields || {}).forEach(([name, value]) => {
80
+ const f = bt.fields.get(name);
81
+ if (!f) { if (strict && !inComponent) problems.push(new VersoError(`${label} has content for "${name}", which ${bt.file} no longer has.`, where)); return; }
82
+ if ((f.type === 'text' || f.type === 'rich') && typeof value !== 'string') problems.push(new VersoError(`"${f.label}" in ${label.charAt(0).toLowerCase()}${label.slice(1)} should be text.`, where));
83
+ if (f.type === 'image' && value != null && (typeof value !== 'object' || typeof value.file !== 'string')) problems.push(new VersoError(`"${f.label}" in ${label.charAt(0).toLowerCase()}${label.slice(1)} should be an image.`, where));
84
+ });
85
+ if (strict) {
86
+ bt.fields.forEach((f) => {
87
+ if (!f.required) return;
88
+ const v = inst.fields?.[f.name];
89
+ const blank = f.type === 'rich' ? richIsEmpty(v) : f.type === 'image' ? !v?.file : !String(v ?? '').trim();
90
+ if (blank) problems.push(new VersoError(`"${f.label}" in ${label.charAt(0).toLowerCase()}${label.slice(1)} is required, but it's empty.`, { ...where, hint: `Fill it in on the page, or remove :required from ${bt.file}, line ${f.line}.` }));
91
+ });
92
+ }
93
+ checkSlots(inst, bt, label, inComponent);
94
+ };
95
+ // inComponent: false, or "the Pricing component on Home" for blocks inside one.
96
+ const checkSlots = (holder, tpl, ownerLabel, inComponent = false) => {
97
+ Object.entries(holder.blocks || {}).forEach(([slot, list]) => {
98
+ const field = tpl.fields.get(slot);
99
+ if (!field || field.type !== 'blocks') {
100
+ if (strict && !inComponent) problems.push(new VersoError(`${ownerLabel} has blocks for "${slot}", but ${tpl.file} no longer has that block area.`, where));
101
+ return;
102
+ }
103
+ if (!Array.isArray(list)) {
104
+ problems.push(new VersoError(`The blocks for "${slot}" should be a list.`, where));
105
+ return;
106
+ }
107
+ list.forEach((inst) => {
108
+ if (inst && typeof inst.component === 'string') {
109
+ const comp = blocks.components?.get(inst.component);
110
+ const clabel = `the ${comp ? comp.label : humanize(inst.component)} component on ${page.label}`;
111
+ if (!comp) { problems.push(new VersoError(`The ${humanize(inst.component)} component on ${page.label} uses components/${inst.component}.json, which doesn't exist.`, where)); return; }
112
+ topBlocks(comp).forEach((name) => {
113
+ if (!allows(field, name)) problems.push(new VersoError(`The ${comp.label} component on ${page.label} starts with a ${humanize(name)} block, but "${slot}" only takes ${field.tools.map(humanize).join(', ')}.`, where));
114
+ });
115
+ expandList([inst], blocks.components).forEach((part) => {
116
+ // The slot's allow-list was checked for the component as a whole.
117
+ checkInst(part, { ...field, tools: [] }, slot, `The ${humanize(part.block)} block in ${clabel}`, clabel);
118
+ });
119
+ return;
120
+ }
121
+ if (!inst || typeof inst !== 'object' || typeof inst.block !== 'string') {
122
+ problems.push(new VersoError(`Something in "${slot}" isn't a block.`, where));
123
+ return;
124
+ }
125
+ checkInst(inst, field, slot, inComponent ? `The ${humanize(inst.block)} block in ${inComponent}` : `The ${humanize(inst.block)} block on ${page.label}`, inComponent);
126
+ });
127
+ });
128
+ };
129
+ checkSlots(page, template, page.label);
130
+ return problems;
131
+ }
132
+
133
+ // Saves one block field, named "@<id>.<field>", checked against its type.
134
+ // In a component, the content goes to the instance, or to the component file
135
+ // when the field is locked (then every page that uses it changes).
136
+ export function saveBlockField(page, blocks, key, value, { clean, exists, root = null, onComponentWrite = null }) {
137
+ const m = /^@([a-z0-9-]+)\.([a-zA-Z][a-zA-Z0-9_-]*)$/.exec(key);
138
+ if (!m) throw new VersoError(`"${key}" isn't a field on this page.`);
139
+ let bag;
140
+ let fieldKey = m[2];
141
+ let blockName;
142
+ let writeBack = null;
143
+ const found = findBlock(page, m[1]);
144
+ if (found && !found.inst.component) {
145
+ blockName = found.inst.block;
146
+ bag = found.inst.fields = found.inst.fields || {};
147
+ } else {
148
+ const part = findPart(page, m[1], blocks.components);
149
+ if (!part) throw new VersoError('That block is no longer on the page.');
150
+ blockName = part.node.block;
151
+ fieldKey = `${part.key}.${m[2]}`;
152
+ if (fieldKey in (part.comp.shared || {})) {
153
+ bag = part.comp.shared;
154
+ writeBack = part.comp;
155
+ } else {
156
+ bag = part.inst.fields = part.inst.fields || {};
157
+ }
158
+ }
159
+ const tpl = blocks.get(blockName);
160
+ const field = tpl?.fields.get(m[2]);
161
+ if (!field || field.type === 'blocks') throw new VersoError(`"${m[2]}" isn't a field in that block.`);
162
+ const inComponent = fieldKey !== m[2];
163
+ if (field.type === 'text') {
164
+ if (typeof value !== 'string') throw new VersoError(`"${field.label}" must be text.`);
165
+ bag[fieldKey] = clean(value, 20000);
166
+ } else if (field.type === 'rich') {
167
+ if (typeof value !== 'string') throw new VersoError(`"${field.label}" must be rich text.`);
168
+ const html = sanitizeRich(value, field.tools);
169
+ // In a component an empty value is kept, so the default doesn't come back.
170
+ if (richIsEmpty(html) && !inComponent) delete bag[fieldKey];
171
+ else bag[fieldKey] = richIsEmpty(html) ? '' : html;
172
+ } else if (field.type === 'color') {
173
+ if (value === null) { delete bag[fieldKey]; return; }
174
+ if (!value || typeof value.color !== 'string' || !(value.color in getColors())) throw new VersoError(`"${field.label}" must be one of the site's colours.`);
175
+ bag[fieldKey] = { color: value.color };
176
+ } else if (field.type === 'image') {
177
+ if (writeBack) throw new VersoError('Images can\'t be shared across pages. Unlock this field to choose an image for this page.');
178
+ if (value === null) { delete bag[fieldKey]; return; }
179
+ if (typeof value !== 'object' || typeof value.file !== 'string') throw new VersoError(`"${field.label}" must be an image.`);
180
+ if (value.file && (!IMAGE_FILE.test(value.file) || !exists(value.file))) throw new VersoError(`The image for "${field.label}" isn't in this page's folder. Choose it again.`);
181
+ bag[fieldKey] = { file: value.file, alt: clean(value.alt || '', 1000) };
182
+ }
183
+ if (writeBack) {
184
+ // The site root, worked out from the page when the caller didn't say.
185
+ const siteRoot = root || (page.dir && page.file ? path.resolve(page.dir, ...path.dirname(page.file).split('/').map(() => '..')) : null);
186
+ if (!siteRoot) throw new VersoError('Shared component content can\'t be saved from here.');
187
+ const out = writeComponent(siteRoot, writeBack);
188
+ onComponentWrite?.(out);
189
+ }
190
+ }
191
+
192
+ // Editor data for every block field on a page, named "@<id>.<field>".
193
+ // Fields in components say which component, and whether they're locked.
194
+ export function blockFieldData(page, blocks) {
195
+ const fields = [];
196
+ const values = {};
197
+ const used = new Set();
198
+ walkBlocks(expandBlocks(page.blocks, blocks.components), (inst) => {
199
+ const tpl = blocks.get(inst?.block);
200
+ if (!tpl) return;
201
+ used.add(inst.block);
202
+ tpl.fields.forEach((f) => {
203
+ // Shared fields belong to the site, not the block (see siteFields).
204
+ if (f.type === 'blocks' || f.site) return;
205
+ const name = `@${inst.id}.${f.name}`;
206
+ const extra = inst.part ? { component: inst.part.component, componentLabel: inst.part.label, instance: inst.part.instance, locked: inst.part.locked.includes(f.name) } : {};
207
+ fields.push({ name, label: f.label, type: f.type, tools: f.tools, required: f.required, onPage: f.contexts.has('text') || f.contexts.has('attr'), offPage: false, block: inst.block, ...extra });
208
+ if (f.type !== 'rich' && inst.fields?.[f.name] !== undefined) values[name] = inst.fields[f.name];
209
+ });
210
+ });
211
+ return { fields, values, used };
212
+ }
213
+
214
+ // ════ Where a block lives ════
215
+ // A block is shown on its own in the Blocks library and in Build a block.
216
+ // It should look the way it does on a page, so it's wrapped in the same
217
+ // elements its block area sits in: a <main> with the page's background, a
218
+ // column that sets its width. Returns { open, close } HTML, or empty strings.
219
+ const VOID = new Set(['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'source', 'track', 'wbr']);
220
+
221
+ export function blockSurround(site, name) {
222
+ const none = { open: '', close: '' };
223
+ // The block area a page keeps this block in, at the top level of the page.
224
+ // Items of a list are shown inside their own block, so they need nothing.
225
+ const holds = (blocks) => Object.entries(blocks || {}).find(([, list]) => {
226
+ let found = false;
227
+ walkBlocks({ list }, (inst) => { if (inst?.block === name) found = true; });
228
+ return found;
229
+ })?.[0];
230
+ let area = null;
231
+ let template = null;
232
+ const shared = holds(site.siteData?.blocks);
233
+ if (shared) {
234
+ area = `site.${shared}`;
235
+ template = [...site.templates.values()].find((t) => t?.fields?.has(area));
236
+ } else {
237
+ for (const page of site.pages) {
238
+ const slot = holds(page.blocks);
239
+ if (slot) { area = slot; template = site.templates.get(page.template); break; }
240
+ }
241
+ }
242
+ if (!template) {
243
+ // Not on a page yet: the first block area that would take it.
244
+ template = site.templates.get('page') || [...site.templates.values()][0];
245
+ const first = template && [...template.fields.values()].find((f) => f.type === 'blocks' && !f.site && (!f.tools?.length || f.tools.includes(name)));
246
+ area = first?.name || null;
247
+ }
248
+ if (!template?.source || !area) return none;
249
+ const source = template.source;
250
+ const at = source.search(new RegExp(`\\{\\{\\s*${area.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\s*:\\s*blocks\\b`));
251
+ const body = /<body[^>]*>/i.exec(source);
252
+ if (at < 0 || !body) return none;
253
+ // The elements still open where the block area's tag is.
254
+ const stack = [];
255
+ const tags = /<!--[\s\S]*?-->|<(script|style)\b[\s\S]*?<\/\1>|<(\/?)([a-zA-Z][\w-]*)((?:"[^"]*"|'[^']*'|[^>"'])*)>/g;
256
+ tags.lastIndex = body.index + body[0].length;
257
+ for (let m = tags.exec(source); m && m.index < at; m = tags.exec(source)) {
258
+ if (!m[3]) continue;
259
+ const tag = m[3].toLowerCase();
260
+ if (m[2]) {
261
+ const i = stack.map((s) => s.tag).lastIndexOf(tag);
262
+ if (i >= 0) stack.length = i;
263
+ } else if (!VOID.has(tag) && !/\/\s*$/.test(m[4])) {
264
+ // Without its tags or id: only how it looks matters here.
265
+ stack.push({ tag, html: `<${tag}${m[4].replace(/\{\{[^}]*\}\}/g, '').replace(/\sid\s*=\s*("[^"]*"|'[^']*')/i, '')}>` });
266
+ }
267
+ }
268
+ return { open: stack.map((s) => s.html).join(''), close: stack.reverse().map((s) => `</${s.tag}>`).join('') };
269
+ }