From 1197d5ed95e244e88dfa4cd6f15f662707707147 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Mon, 19 Oct 2026 14:32:03 -0500 Subject: feat(reveal): fit dense slides to the canvas instead of clipping them reveal.js lays each slide out on a fixed canvas and clips whatever runs past the bottom. At the stock 42px font a slide held about six lines. Anything past that vanished with no sign it was missing. I made three changes in org-reveal-config.el. The canvas is now 16:9 (1280x720), so lines wrap later. The head preamble sets a 30px base font and smaller headings through the theme's CSS variables, so any reveal 4+ theme picks them up. A script spliced in after Reveal.initialize measures every slide once reveal is ready and shrinks any that still overflows, down to a floor of half size. A slide that overflows even there gets a console warning. A slide that fits stays at full size. The script stays out of overview and print view, where reveal lays slides out differently and a measurement means nothing. The header template now emits the same init options as the global default and turns off ^ markup, so snake_case identifiers in slide text stop exporting as subscripts. A file that already carries its own #+REVEAL_INIT_OPTIONS keeps them. The preamble and the fit script apply to every export. --- modules/org-reveal-config.el | 143 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 136 insertions(+), 7 deletions(-) (limited to 'modules/org-reveal-config.el') diff --git a/modules/org-reveal-config.el b/modules/org-reveal-config.el index f842680b..e5358b13 100644 --- a/modules/org-reveal-config.el +++ b/modules/org-reveal-config.el @@ -18,6 +18,10 @@ ;; Fully offline workflow using a local reveal.js clone (managed by ;; scripts/setup-reveal.sh) and self-contained HTML export. ;; +;; Slides use a 16:9 canvas with a smaller base font than the stock theme, +;; and a script in the export shrinks any slide whose content would +;; otherwise be clipped (see "Slide Sizing" below). +;; ;; Keybindings (C-; p prefix): ;; - C-; p SPC : Ensure headers, export, and open in browser ;; - C-; p e : Export to self-contained HTML and open in browser @@ -37,6 +41,8 @@ (defvar org-reveal-plugins) (defvar org-reveal-highlight-css) (defvar org-reveal-init-options) +(defvar org-reveal-head-preamble) +(defvar org-reveal-extra-script) (declare-function org-reveal-export-to-html "ox-reveal") ;; --------------------------------- Constants --------------------------------- @@ -51,6 +57,130 @@ (defconst cj/reveal-default-transition "none" "Default reveal.js slide transition for new presentations.") +;; ------------------------------- Slide Sizing -------------------------------- +;; +;; reveal.js lays every slide out on a fixed canvas and scales that canvas +;; to the window; content taller than the canvas is clipped, not scrolled. +;; Three things keep a dense slide readable instead of cut off: +;; +;; - a 16:9 canvas (the shape of every screen the slides land on), so lines +;; wrap later than on the stock 960x700 frame; +;; - a smaller base font and heading scale, set through the theme's CSS +;; variables in the head preamble so any reveal.js 4+ theme picks them up; +;; - a script, spliced in after Reveal.initialize, that shrinks any slide +;; whose content still overflows. It floors at half size: a slide that +;; overflows even there needs splitting, not shrinking. +;; +;; The script rides ox-reveal's extra-script slot, so a file that sets its +;; own #+REVEAL_EXTRA_SCRIPT replaces it. Print view (?print-pdf) paginates +;; instead of clipping, so the fit is skipped there and a printed deck can +;; differ from the presented one. + +(defconst cj/reveal-canvas-width 1280 + "Width of the reveal.js slide canvas in CSS pixels.") + +(defconst cj/reveal-canvas-height 720 + "Height of the reveal.js slide canvas in CSS pixels.") + +(defconst cj/reveal-base-font-size "30px" + "Base font size for slide text, as a px value. +The stock themes use 42px, which fits about six short lines on a slide. +Keep it in px: ox-reveal runs the head preamble through `format-spec', +so a % unit would break the export.") + +(defun cj/--reveal-init-options () + "Return the Reveal.initialize options shared by default and template. +One line with no trailing comma, so ox-reveal can splice it into the +Reveal.initialize call." + (format "slideNumber:true, hash:true, transition:'%s', width:%d, height:%d" + cj/reveal-default-transition + cj/reveal-canvas-width + cj/reveal-canvas-height)) + +(defun cj/--reveal-head-preamble () + "Return the " + cj/reveal-base-font-size)) + +(defun cj/--reveal-fit-script () + "Return the JavaScript that shrinks overflowing slides to the canvas. +ox-reveal emits it inside the