Flow
Where the cutting script can slip
Most of these pass without an error.
1Same number on two slides
Both write to one file and the second one wins.
2Slide wrapped one level too deep
The script never sees it as a slide.
3Div tag inside a comment
Counted as real, so every later slide boundary shifts.
4Missing style block or container
The script stops with an error.
5Count never gets back to zero
The script stops with an error.
Flow
What people edit and what gets rebuilt
1Slide files, style file, frame
Edited by people. Meant to be the source of truth.
2Build script
Rebuilds the page from those files every time.
3Built page
Committed too, with nothing checking it matches a rebuild.
4Cutting script
Still in the folder. A rerun overwrites the slide files.
5Old single file
Left in place by this commit, so a rerun has something to read.
Typed in by hand, each slide's page number sat in a pitch deck that was one HTML file.
The whole deck sat in one long file: styles at the top, then every slide in one container, with print rules that put each slide on its own page. It worked, but it was a pain to edit. Changing one slide meant scrolling past all the others, and every change touched the whole file.
One file per slide, one build
So I split it. The deck now has its own folder with a shared stylesheet, an outer shell with two placeholders, one small file per slide, and its fonts and images stored right beside it. A short build script sorts the slide files by number, stops if there are none, and stitches everything back into one page. That page is what I present or print.
The cutting script
I didn't retype the slides. The same commit has a one-time script that cuts the old file apart. It pulls out the styles, then walks through the div tags, counting how deep it is. Each top-level slide goes into its own file, named by its slide number. What's left becomes the shell.
That counting is simple, which is also its weak spot. Two slides with the same number end up in one file. A div tag inside a comment throws off every slide after it. The script only complains if the count never gets back to zero.
The number lives in four places
Splitting the deck made an old problem obvious. Each slide's position is stored in four spots:
- the file name
- a number attribute on the slide
- the typed "page N of total" label
- for a few slides, a style rule that targets that number
Move one slide and you edit all of those. Add one and every label is wrong. Only the build knows the real order, and it doesn't write the label. That's what I'd change next.
Dollar signs
The build drops each slide into the shell with a plain string replace. In JavaScript, a few dollar-sign patterns in that string get treated as commands, so a doubled dollar sign turns into one. A pitch deck is full of dollar signs. I checked every slide, and none of them hit those patterns. That was luck. Handing the replace call a function instead of a string avoids the problem entirely.
Two copies of the truth
The cutting script is still in the folder, and it overwrites files without asking. Run it after someone edits a slide and it rebuilds every slide file from the old deck, which this commit left in place.
The built page is also saved next to the sources, with no check that a rebuild matches it. One forgotten rebuild and there are two versions of the deck.