slideshow
This commit is contained in:
1 parent
988a5410f7
commit
262b853c5b
18 files changed
+1305
-30
No files matched your search
@@ -243,12 +243,23 @@ export function getTodos(src) {
|
||||
return { total, done: (s.match(/- \[x\]/g) || []).length };
|
||||
}
|
||||
|
||||
// Matches the `src:` line inside a ```slide-image fenced block (slideshow plugin format).
|
||||
const SLIDE_IMAGE_RE = /```slide-image\s*\n([\s\S]*?)(?:\n```|$)/;
|
||||
function slideImageSrc(block) {
|
||||
if (!block) return null;
|
||||
const m = block.match(/^\s*src\s*:\s*([^\n]+)/m);
|
||||
return m ? m[1].trim() : null;
|
||||
}
|
||||
|
||||
export function firstImage(src) {
|
||||
const s = src || '';
|
||||
const md = s.match(/!\[[^\]]*\]\(([^)]+)\)/);
|
||||
if (md) return md[1];
|
||||
const html = s.match(/<img[^>]+src="([^"]+)"/i);
|
||||
return html ? html[1] : null;
|
||||
if (html) return html[1];
|
||||
const slide = s.match(SLIDE_IMAGE_RE);
|
||||
if (slide) return slideImageSrc(slide[1]);
|
||||
return null;
|
||||
}
|
||||
|
||||
export function leadingImage(src) {
|
||||
@@ -257,5 +268,9 @@ export function leadingImage(src) {
|
||||
const md = s.match(/^!\[[^\]]*\]\(([^)]+)\)/);
|
||||
if (md) return md[1].split(/\s+/)[0].replace(/^<(.+)>$/, '$1') || null;
|
||||
const html = s.match(/^<img[^>]+src=(['"])(.*?)\1/i);
|
||||
return html ? html[2] : null;
|
||||
if (html) return html[2];
|
||||
// A card whose body *starts* with a slide-image block → use its image as the cover.
|
||||
const slide = s.match(/^```slide-image\s*\n([\s\S]*?)(?:\n```|$)/);
|
||||
if (slide) return slideImageSrc(slide[1]);
|
||||
return null;
|
||||
}
|
||||
Reference in new issue
Block a user