rapier-html 1.2.30 → 1.2.32
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/BUILD.json +4 -4
- package/README.md +9 -9
- package/dist/ledger/carried.mjs +14 -2
- package/dist/ledger/document-settings.mjs +429 -0
- package/dist/ledger/frontmatter.mjs +29 -0
- package/dist/ledger/md-marks.mjs +731 -0
- package/dist/ledger/md-source.mjs +153 -0
- package/dist/ledger/template-page.mjs +2 -4
- package/dist/rapier.html +43 -43
- package/dist/wrap.mjs +8 -2
- package/package.json +1 -1
package/dist/wrap.mjs
CHANGED
|
@@ -8,6 +8,7 @@ const START = '<script type="text/markdown" id="rapier-document"';
|
|
|
8
8
|
const DRAWING_START = '<script type="text/plain" id="rapier-drawing"';
|
|
9
9
|
const END = '</script>';
|
|
10
10
|
// The page's search words (rapier.html's RAPIER_SEO regions: description, canonical address, previews, structured data and the plain guide
|
|
11
|
+
const READABLE = /<noscript id="rapier-readable">[\s\S]*?<\/noscript>\n?/g;
|
|
11
12
|
const SEARCH_WORDS = /<!-- RAPIER_SEO_BEGIN -->[\s\S]*?<!-- RAPIER_SEO_END -->\n?/g;
|
|
12
13
|
const OFFLINE_POLICY = "default-src 'none'; script-src 'unsafe-inline' 'wasm-unsafe-eval' blob:; style-src 'unsafe-inline'; " +
|
|
13
14
|
"img-src data: blob:; media-src data: blob:; font-src data: blob:; connect-src 'none'; worker-src blob:; manifest-src 'none'; base-uri 'none'; form-action 'none'";
|
|
@@ -44,6 +45,11 @@ function previewHead(markdown, fallbackTitle) {
|
|
|
44
45
|
(description ? meta('property', 'og:description', description) : '') + meta('name', 'generator', 'Rapier (https://rapier.website)');
|
|
45
46
|
}
|
|
46
47
|
|
|
48
|
+
function readableBlock(html) {
|
|
49
|
+
if (typeof html !== 'string' || !html.trim() || /<\/noscript|<!--/i.test(html)) return '';
|
|
50
|
+
return '\n<noscript id="rapier-readable"><style>html,body{background:#fff;color:#000}a{color:#0000ee}</style><main style="max-width:44rem;margin:0 auto;padding:1rem">' + html + '</main></noscript>';
|
|
51
|
+
}
|
|
52
|
+
|
|
47
53
|
function safeName(name, fallback) {
|
|
48
54
|
return [...String(name || fallback).replace(/[\\/\0"<>&]/g, '-')].slice(0, 256).join('').replace(/[\uD800-\uDBFF]$/, '') || fallback;
|
|
49
55
|
}
|
|
@@ -163,7 +169,7 @@ export function wrap(pageHtml, text, name, options) {
|
|
|
163
169
|
const titled = stripped.replace(/<title>[^<]*<\/title>\n?/, all => '<title>' + docName.replace(/&/g, '&').replace(/</g, '<') + ' — Rapier</title>' +
|
|
164
170
|
(all.endsWith('\n') ? '\n' : '') + previewHead(text, docName.replace(/\.[^.]*$/, '')));
|
|
165
171
|
const shift = titled.length - stripped.length;
|
|
166
|
-
return titled.slice(0, at + shift) + '\n' + block + carriedBlocks + titled.slice(at + shift);
|
|
172
|
+
return titled.slice(0, at + shift) + '\n' + block + carriedBlocks + readableBlock(opts.readable) + titled.slice(at + shift);
|
|
167
173
|
}
|
|
168
174
|
export function unwrap(pageHtml) {
|
|
169
175
|
const theme = Array.from(pageHtml.matchAll(APPEARANCE), match => match[1])[0] || null;
|
|
@@ -197,5 +203,5 @@ export function unwrap(pageHtml) {
|
|
|
197
203
|
const carriedBase = takeBase(html); html = carriedBase.html;
|
|
198
204
|
const comparisonBase = carriedBase.base;
|
|
199
205
|
const parts = takeParts(html, text);
|
|
200
|
-
return {...parts, text, name, kind, view, theme, drawing, drawingName, comparisonBase, base: comparisonBase?.text ?? null, baseName: comparisonBase?.name ?? null, baseSha256: comparisonBase?.sha256 ?? null, baseRevision: comparisonBase?.revision ?? null, by: comparisonBase?.by ?? null, at: comparisonBase?.at ?? null, return: address, return_expires_at: expiry};
|
|
206
|
+
return {...parts, html: parts.html.replace(READABLE, ''), text, name, kind, view, theme, drawing, drawingName, comparisonBase, base: comparisonBase?.text ?? null, baseName: comparisonBase?.name ?? null, baseSha256: comparisonBase?.sha256 ?? null, baseRevision: comparisonBase?.revision ?? null, by: comparisonBase?.by ?? null, at: comparisonBase?.at ?? null, return: address, return_expires_at: expiry};
|
|
201
207
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rapier-html",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.32",
|
|
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",
|