From 8a0d89e63ef47702c19388e1e33ef5ec38f66895 Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Sun, 12 Feb 2023 15:59:03 -0500 Subject: [PATCH] Adding a simple image slide mechanism. --- commands/pdfpresgen.js | 14 ++++++++++++++ scripts/pdfpres_example.md | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/commands/pdfpresgen.js b/commands/pdfpresgen.js index 3c4c365..57edcf1 100644 --- a/commands/pdfpresgen.js +++ b/commands/pdfpresgen.js @@ -85,6 +85,17 @@ const write_page = (doc, template, content) => { doc.list(content.slide_body, main_box.x, main_box.y, main_box); + } else if(content.type == "title-image") { + // it's a title only slide + doc.fontSize(80); + // add the title/body text + doc.font("heading").text(content.slide_title, main_title.x, main_title.y, main_title); + + doc.image(content.slide_body, main_box.x, main_box.y, { + fit: [main_box.width, main_box.height], + align: "center", + valign: "center" + }); } else if(content.type == "title-only") { // it's a title only slide doc.fontSize(80); @@ -132,6 +143,9 @@ const parse_input = (input) => { } else if(body.startsWith("*")) { page.type = "title-bullets"; page.slide_body = body.split("\n").map(l => l.slice(1).trim()); + } else if(body.startsWith("[")) { + page.type = "title-image"; + page.slide_body = body.slice(1,-1); } else { page.type = "title-text"; } diff --git a/scripts/pdfpres_example.md b/scripts/pdfpres_example.md index ab5f3b6..b60feac 100644 --- a/scripts/pdfpres_example.md +++ b/scripts/pdfpres_example.md @@ -14,5 +14,9 @@ Another Thing Then we'll have more to do, but for now we'll be able to do more things than this hopefully. --- +Image Slide + +[static/images/zed.png] +--- Slide Title Only ---