rapier-markdown-kit 1.2.29 → 1.2.30
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/kit/render-markdown.mjs +3 -1
- package/dist/kit/render-print.mjs +26 -0
- package/dist/kit/render-styles.mjs +1 -1
- package/dist/kit/render.mjs +1 -1
- package/package.json +1 -1
- package/style.css +4 -2
|
@@ -1054,6 +1054,8 @@ function _rapierRemoveCalloutMarker(first) {
|
|
|
1054
1054
|
);
|
|
1055
1055
|
}
|
|
1056
1056
|
|
|
1057
|
+
const mathSource = /^\$\$[\s\S]+\$\$$|^\$[^$\n]+\$$/;
|
|
1058
|
+
|
|
1057
1059
|
function _rapierMathSource(node) {
|
|
1058
1060
|
if (!node) return '';
|
|
1059
1061
|
const carrier = node.matches && node.matches('[data-math-src]')
|
|
@@ -1404,7 +1406,7 @@ function* _rapierPortableInlineTextSteps(node, options) {
|
|
|
1404
1406
|
}
|
|
1405
1407
|
if (tag === 'CODE' && !opts.inPre) {
|
|
1406
1408
|
const source = String(node.textContent || '');
|
|
1407
|
-
return opts.visible ? source : source ? '`' + source + '`' : '';
|
|
1409
|
+
return opts.visible || mathSource.test(source) ? source : source ? '`' + source + '`' : '';
|
|
1408
1410
|
}
|
|
1409
1411
|
const parts = [];
|
|
1410
1412
|
for (let child = node.firstChild; child; child = child.nextSibling) parts.push(yield* _rapierPortableInlineTextSteps(child, opts));
|
|
@@ -171,6 +171,31 @@ function _rapierPrintWillPageCss() {
|
|
|
171
171
|
|
|
172
172
|
const CAPTURE_EDGE = 4096, CAPTURE_PIXELS = 4 * 1024 * 1024;
|
|
173
173
|
|
|
174
|
+
function wrapMasks(main) {
|
|
175
|
+
const doc = main.ownerDocument;
|
|
176
|
+
for (const float of main.querySelectorAll('.rapier-wrap-picture')) {
|
|
177
|
+
const image = float.querySelector('img'), layout = decodeURIComponent(image?.getAttribute('data-rapier-image-layout') || '');
|
|
178
|
+
if (!image || !/\bwrap=around\b/.test(layout) || /\b(rotate|y)=/.test(layout) || image.dataset.rapierContour?.endsWith('-box')) continue;
|
|
179
|
+
if (/^(inset|polygon)\(/.test(float.style.getPropertyValue('shape-outside'))) continue;
|
|
180
|
+
const bounds = image.getBoundingClientRect(), width = Math.ceil(bounds.width), height = Math.ceil(bounds.height);
|
|
181
|
+
float.style.removeProperty('shape-outside');
|
|
182
|
+
if (!(width > 0 && height > 0) || width * height > 4e6) continue;
|
|
183
|
+
const canvas = doc.createElement('canvas');
|
|
184
|
+
canvas.width = width; canvas.height = height;
|
|
185
|
+
try {
|
|
186
|
+
const context = canvas.getContext('2d', {willReadFrequently: true});
|
|
187
|
+
context.drawImage(image, 0, 0, width, height);
|
|
188
|
+
const alpha = context.getImageData(0, 0, width, height).data;
|
|
189
|
+
let clear = false;
|
|
190
|
+
for (let index = 3; index < alpha.length && !clear; index += 4) clear = alpha[index] < 250;
|
|
191
|
+
if (!clear) continue;
|
|
192
|
+
float.style.setProperty('shape-outside', 'url("' + canvas.toDataURL('image/png') + '")');
|
|
193
|
+
float.style.setProperty('shape-image-threshold', '0.1');
|
|
194
|
+
float.style.setProperty('shape-margin', '1rem');
|
|
195
|
+
} catch (_) { }
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
174
199
|
async function _rapierWritePrintPdf({root, css, fontCss = '', canonical, bom = false, filename, title, settings, templatePage = null}, {capture, signal, current, maxBytes = 8 * 1024 * 1024, film, ink} = {}) {
|
|
175
200
|
const refuse = code => { throw Object.assign(new Error(code), {code}); };
|
|
176
201
|
const check = () => {
|
|
@@ -240,6 +265,7 @@ async function _rapierWritePrintPdf({root, css, fontCss = '', canonical, bom = f
|
|
|
240
265
|
if (fontCss) await step(waitForFonts(main, {fontCss, css, settings}));
|
|
241
266
|
await step(into.fonts.ready);
|
|
242
267
|
for (const image of main.querySelectorAll('img')) { image.loading = 'eager'; await step(image.decode()); }
|
|
268
|
+
wrapMasks(main);
|
|
243
269
|
check();
|
|
244
270
|
for (const node of [main, ...main.querySelectorAll('*')]) {
|
|
245
271
|
const style = into.defaultView.getComputedStyle(node);
|
|
@@ -16,7 +16,7 @@ body{
|
|
|
16
16
|
--color-text-subtle:var(--md-color-text-subtle);--color-accent-text:var(--md-color-accent-text);
|
|
17
17
|
margin:0;background:var(--md-color-bg);color:var(--md-color-text);font-family:var(--md-font-sans);-webkit-font-smoothing:antialiased
|
|
18
18
|
}
|
|
19
|
-
.rapier-page{width:min(100%,calc(var(--md-measure,39.6rem) + 32px));margin:0 auto;padding:48px 16px 72px}
|
|
19
|
+
.rapier-page{width:min(100%,calc(var(--md-measure,39.6rem) + 32px));margin:0 auto;padding:48px 16px 72px;isolation:isolate}
|
|
20
20
|
.rapier-page [id]{scroll-margin-top:var(--md-space-8)}
|
|
21
21
|
.artifact-flat{margin:0;white-space:pre-wrap;overflow-wrap:anywhere;tab-size:2}
|
|
22
22
|
.artifact-flat--text{font:var(--md-fw-regular) 1rem/1.7 var(--md-font-sans)}
|
package/dist/kit/render.mjs
CHANGED
|
@@ -763,7 +763,7 @@ function* _rapierSharedPageLayoutSteps(root) {
|
|
|
763
763
|
if (layout.width != null || image.getAttribute('width')) image.style.width = '100%';
|
|
764
764
|
}
|
|
765
765
|
if (layout.rotate) { image.style.transform = 'rotate(' + layout.rotate + 'deg)'; image.style.transformOrigin = '50% 50%'; }
|
|
766
|
-
if (layout.wrap === 'around' && !layout.rotate && !layout.y && !image.dataset.rapierContour?.endsWith('-box')) {
|
|
766
|
+
if (layout.wrap === 'around' && !layout.rotate && !layout.y && layout.width == null && !image.dataset.rapierContour?.endsWith('-box')) {
|
|
767
767
|
const src = image.getAttribute('src');
|
|
768
768
|
if (src) {
|
|
769
769
|
paragraph.style.setProperty('shape-outside', 'url("' + src + '")');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rapier-markdown-kit",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.30",
|
|
4
4
|
"description": "Read, render and write Self-contained Markdown: one .md file that carries its pictures, drawings and layout, and that any Markdown app can read. HTML renderer, stylesheet, text layout, Will/1 agent permissions, and an edit history with authorship and offline merge. MIT, no dependencies.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markdown",
|
package/style.css
CHANGED
|
@@ -335,8 +335,10 @@
|
|
|
335
335
|
depend on it would go wrong quietly. */
|
|
336
336
|
color: inherit;
|
|
337
337
|
position: relative;
|
|
338
|
-
|
|
339
|
-
|
|
338
|
+
/* The 48px target overhangs the drawn box by 16px on every side; the overhangs take no room in the line, so the words
|
|
339
|
+
stand where they stood beside the box before the target grew (the left overhang in the line pushed them 16px on). */
|
|
340
|
+
left: calc(-1 * var(--md-space-5));
|
|
341
|
+
margin: -16px calc(var(--md-space-1) - 16px) -16px -16px;
|
|
340
342
|
width: 48px; height: 48px;
|
|
341
343
|
font: inherit;
|
|
342
344
|
-webkit-appearance: none; appearance: none;
|