Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Directly generate pdfpc config #84

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions logic.typ
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#import "utils/pdfpc.typ": register_page;

#let subslide = counter("subslide")
#let pause-counter = counter("pause-counter")
#let logical-slide = counter("logical-slide")
Expand Down Expand Up @@ -294,14 +296,7 @@
if curr-subslide <= repetitions.at(loc).first() {
if curr-subslide > 1 { pagebreak(weak: true) }
set heading(outlined: false) if curr-subslide > 1

[
#metadata((t: "NewSlide")) <pdfpc>
#metadata((t: "Idx", v: counter(page).at(loc).first() - 1)) <pdfpc>
#metadata((t: "Overlay", v: curr-subslide - 1)) <pdfpc>
#metadata((t: "LogicalSlide", v: logical-slide.at(loc).first())) <pdfpc>
]

register_page(counter(page).at(loc).first() - 1, logical-slide.at(loc).first(), curr-subslide - 1);
body
}
})
Expand Down
2 changes: 2 additions & 0 deletions themes/bipartite.typ
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// This theme is inspired by https://slidesgo.com/theme/modern-annual-report

#import "../logic.typ"
#import "../utils/pdfpc.typ": meta_out;


#let bipartite-dark = rgb("#192e41")
Expand All @@ -17,6 +18,7 @@
)

body
meta_out();
}

#let title-slide(title: [], subtitle: none, author: [], date: none) = {
Expand Down
2 changes: 2 additions & 0 deletions themes/clean.typ
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#import "../logic.typ"
#import "../utils/utils.typ"
#import "../utils/pdfpc.typ": meta_out;

#let clean-footer = state("clean-footer", [])
#let clean-short-title = state("clean-short-title", none)
Expand Down Expand Up @@ -33,6 +34,7 @@
clean-logo.update(logo)

body
meta_out();
}


Expand Down
2 changes: 2 additions & 0 deletions themes/metropolis.typ
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#import "../logic.typ"
#import "../utils/utils.typ"
#import "../utils/pdfpc.typ": meta_out;

#let m-dark-teal = rgb("#23373b")
#let m-light-brown = rgb("#eb811b")
Expand Down Expand Up @@ -48,6 +49,7 @@
m-footer.update(footer)

body
meta_out();
}

#let title-slide(
Expand Down
2 changes: 2 additions & 0 deletions themes/simple.typ
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#import "../logic.typ"
#import "../utils/pdfpc.typ": meta_out;

#let simple-footer = state("simple-footer", [])

Expand Down Expand Up @@ -26,6 +27,7 @@
simple-footer.update(footer)

body
meta_out();
}

#let centered-slide(body) = {
Expand Down
2 changes: 2 additions & 0 deletions themes/university.typ
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#import "../logic.typ"
#import "../utils/utils.typ"
#import "../utils/pdfpc.typ": meta_out;

// University theme
//
Expand Down Expand Up @@ -41,6 +42,7 @@
uni-short-date.update(short-date)

body
meta_out();
}

#let title-slide(
Expand Down
78 changes: 59 additions & 19 deletions utils/pdfpc.typ
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
#let pdfpc_metadata = state("polylux_pdfpc_metadata", (
pdfpcFormat: 2,
pages: ()
));

#let set_or_fail(key, value) = {
pdfpc_metadata.update(m=>{
assert(key not in m.keys(), message: "The key "+key+" can only be set once.");
m.insert(key, value);
m
})
}

#let register_page(idx, logicalSlide, overlay) = {
pdfpc_metadata.update(m=>{
let entry = (
idx: idx,
label: str(logicalSlide),
overlay: overlay
);

if(overlay>0) {
entry.forcedOverlay = true;
}

m.pages.push(entry);
m
})
}

#let meta_out() = {
pdfpc_metadata.display(m=>[#metadata(m)<pdfpc>]);
}

#let speaker-note(text) = {
let text = if type(text) == "string" {
text
Expand All @@ -6,20 +40,27 @@
} else {
panic("A note must either be a string or a raw block")
}
[ #metadata((t: "Note", v: text)) <pdfpc> ]
pdfpc_metadata.update(m=>{
m.pages.last().insert("note", m.pages.last().at("note", default: "")+text);
m
})
}

#let end-slide = [
#metadata((t: "EndSlide")) <pdfpc>
]
#let end-slide = {
pdfpc_metadata.display(m=>set_or_fail("endSlide", int(m.pages.last().label)-1))

}

#let save-slide = [
#metadata((t: "SaveSlide")) <pdfpc>
]
#let save-slide = {
pdfpc_metadata.display(m=>set_or_fail("savedSlide", int(m.pages.last().label)-1))
}

#let hidden-slide = [
#metadata((t: "HiddenSlide")) <pdfpc>
]
#let hidden-slide = {
pdfpc_metadata.update(m=>{
m.pages.last().hidden=true;
m
})
}

#let config(
duration-minutes: none,
Expand All @@ -31,7 +72,7 @@
default-transition: none,
) = {
if duration-minutes != none {
[ #metadata((t: "Duration", v: duration-minutes)) <pdfpc> ]
set_or_fail("duration", duration-minutes);
}

let _time-config(time, msg-name, tag-name) = {
Expand All @@ -42,27 +83,26 @@
} else {
panic(msg-name + " must be either a datetime or a string in the HH:MM format.")
}

[ #metadata((t: tag-name, v: time)) <pdfpc> ]
set_or_fail(tag-name, time);
}

if start-time != none {
_time-config(start-time, "Start time", "StartTime")
_time-config(start-time, "Start time", "startTime")
}

if end-time != none {
_time-config(end-time, "End time", "EndTime")
_time-config(end-time, "End time", "endTime")
}

if last-minutes != none {
[ #metadata((t: "LastMinutes", v: last_minutes)) <pdfpc> ]
set_or_fail("lastMinutes", last_minutes);
}

if note-font-size != none {
[ #metadata((t: "NoteFontSize", v: note-font-size)) <pdfpc> ]
set_or_fail("noteFontSize", note-font-size);
}

[ #metadata((t: "DisableMarkdown", v: disable-markdown)) <pdfpc> ]
set_or_fail("disableMarkdown", disable-markdown);

if default-transition != none {
let dir-to-angle(dir) = if dir == ltr {
Expand All @@ -89,6 +129,6 @@
default-transition.at("direction", default: "outward")
)

[ #metadata((t: "DefaultTransition", v: transition-str)) <pdfpc> ]
set_or_fail("defaultTransition", transition-str);
}
}