From 1bebd9c76bd68a2c1192adba3086e7697eeb9421 Mon Sep 17 00:00:00 2001 From: OrangeX4 <34951714+OrangeX4@users.noreply.github.com> Date: Fri, 24 Nov 2023 12:52:52 +0800 Subject: [PATCH 1/3] feat: add pdfpc-file --- utils/pdfpc.typ | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/utils/pdfpc.typ b/utils/pdfpc.typ index 6805e92..20292e4 100644 --- a/utils/pdfpc.typ +++ b/utils/pdfpc.typ @@ -1,3 +1,53 @@ +#let pdfpc-file = { + locate(loc => { + let arr = query(, loc).map(it => it.value) + let (config, ..slides) = arr.split((t: "NewSlide")) + let pdfpc = ( + pdfpcFormat: 2, + disableMarkdown: false, + ) + for item in config { + pdfpc.insert(lower(item.t.at(0)) + item.t.slice(1), item.v) + } + let pages = () + let current-label = 0 + for slide in slides { + let page = ( + idx: 0, + label: 1, + overlay: 0, + forcedOverlay: false, + hidden: false, + ) + for item in slide { + if item.t == "Idx" { + page.idx = item.v + } else if item.t == "LogicalSlide" { + page.label = item.v + } else if item.t == "Overlay" { + page.overlay = item.v + page.forcedOverlay = item.v > 0 + } else if item.t == "HiddenSlide" { + page.hidden = true + } else if item.t == "SaveSlide" { + if "savedSlide" not in pdfpc { + pdfpc.savedSlide = page.label - 1 + } + } else if item.t == "EndSlide" { + if "endSlide" not in pdfpc { + pdfpc.endSlide = page.label - 1 + } + } else if item.t == "Note" { + page.note = item.v + } + } + pages.push(page) + } + pdfpc.insert("pages", pages) + [#metadata(pdfpc)] + }) +} + #let speaker-note(text) = { let text = if type(text) == "string" { text @@ -91,4 +141,7 @@ [ #metadata((t: "DefaultTransition", v: transition-str)) ] } + + // add a metadata to generate json-based pdfpc file + pdfpc-file } From 23b10dab45c68a0c4b59c54be726d40af4532ea4 Mon Sep 17 00:00:00 2001 From: OrangeX4 <34951714+OrangeX4@users.noreply.github.com> Date: Fri, 24 Nov 2023 13:44:16 +0800 Subject: [PATCH 2/3] fix: remove useless variable --- utils/pdfpc.typ | 1 - 1 file changed, 1 deletion(-) diff --git a/utils/pdfpc.typ b/utils/pdfpc.typ index 20292e4..938d92b 100644 --- a/utils/pdfpc.typ +++ b/utils/pdfpc.typ @@ -10,7 +10,6 @@ pdfpc.insert(lower(item.t.at(0)) + item.t.slice(1), item.v) } let pages = () - let current-label = 0 for slide in slides { let page = ( idx: 0, From ca2486a407db90b84052f89fc132a6adb84a57fc Mon Sep 17 00:00:00 2001 From: OrangeX4 <34951714+OrangeX4@users.noreply.github.com> Date: Sun, 21 Jan 2024 11:25:22 +0800 Subject: [PATCH 3/3] Update pdfpc.typ --- utils/pdfpc.typ | 2 ++ 1 file changed, 2 insertions(+) diff --git a/utils/pdfpc.typ b/utils/pdfpc.typ index 938d92b..27251ea 100644 --- a/utils/pdfpc.typ +++ b/utils/pdfpc.typ @@ -38,6 +38,8 @@ } } else if item.t == "Note" { page.note = item.v + } else { + pdfpc.insert(lower(item.t.at(0)) + item.t.slice(1), item.v) } } pages.push(page)