rapier-html 1.2.12 → 1.2.13

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/wrap.mjs CHANGED
@@ -64,7 +64,7 @@ export function offlineTemplate(pageHtml, address = null) {
64
64
  head.slice(at) + pageHtml.slice(end);
65
65
  }
66
66
 
67
- export const CHOICES = Object.freeze(['drawing', 'math', 'mermaid']);
67
+ export const CHOICES = Object.freeze(['drawing', 'layout', 'math', 'mermaid']);
68
68
  const INVENTORY = '<script type="application/json" id="rapier-builtin-plugins">';
69
69
  const element = (html, id) => {
70
70
  const start = html.indexOf('<script type="application/rapier-runtime" id="' + id + '">');
@@ -79,8 +79,9 @@ export function carry(pageHtml, include = []) {
79
79
  if (kept.has('drawing')) kept.add('letters');
80
80
  let html = pageHtml;
81
81
  const cut = id => { const at = element(html, id); if (at) html = html.slice(0, at.start) + html.slice(at.end); };
82
+ const parts = new Set([...(kept.has('drawing') ? ['rapier-part-drawing'] : []), ...(kept.has('layout') ? ['rapier-part-document'] : [])]);
82
83
  for (const id of [...new Set([...html.matchAll(/<script type="application\/rapier-runtime" id="(rapier-part-[a-z-]+)">/g)].map(match => match[1]))])
83
- if (id !== 'rapier-part-drawing' || !kept.has('drawing')) cut(id);
84
+ if (!parts.has(id)) cut(id);
84
85
  const start = html.indexOf(INVENTORY);
85
86
  if (start < 0) return html;
86
87
  const close = html.indexOf(END, start), end = html[close + END.length] === '\n' ? close + END.length + 1 : close + END.length;
@@ -95,6 +96,8 @@ export function portableNeeds(text, {base, flowchart} = {}) {
95
96
  for (const source of [text, base]) {
96
97
  if (typeof source !== 'string') continue;
97
98
  let prose = '';
99
+ const front = /^---[ \t]*\r?\n[\s\S]*?\r?\n(?:---|\.\.\.)[ \t]*(?:\r?\n|$)/.exec(source);
100
+ if (front && /^template:[ \t]*page[ \t]*$/m.test(front[0])) needs.add('layout');
98
101
  const lines = source.split(/\r\n|\r|\n/);
99
102
  for (let at = 0; at < lines.length; at++) {
100
103
  const open = /^ {0,3}(`{3,}|~{3,})\s*([^\s`]*)/.exec(lines[at]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rapier-html",
3
- "version": "1.2.12",
3
+ "version": "1.2.13",
4
4
  "description": "One command turns a Markdown file into one offline HTML file: the whole Rapier editor with the document inside. Opens in any browser, phone or desktop, with no install or account. Write, draw and paint watercolor, then Send back the edits to your AI agent.",
5
5
  "keywords": [
6
6
  "markdown",