;;; org-reveal-config.el --- Reveal.js Presentation Configuration -*- lexical-binding: t; coding: utf-8; -*- ;; author: Craig Jennings ;;; Commentary: ;; ;; Layer: 4 (Optional). ;; Category: O/D/P. ;; Load shape: eager. ;; Eager reason: none; presentation export is a command-loaded deferral ;; candidate for Phase 4. ;; Top-level side effects: registers a presentation prefix keymap under ;; cj/custom-keymap; package configuration via use-package. ;; Runtime requires: keybindings. ;; Direct test load: yes (requires keybindings explicitly). ;; ;; Integrates ox-reveal for creating reveal.js presentations from Org files. ;; ;; 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 ;; - C-; p p : Start live preview (re-exports on save) ;; - C-; p s : Stop live preview ;; - C-; p h : Insert #+REVEAL_ header block at top of current buffer ;; - C-; p H : Remove reveal.js headers from current buffer ;; - C-; p n : Create new presentation file (prompts for title and location) ;;; Code: (require 'keybindings) ;; cj/register-prefix-map, cj/custom-keymap ;; Forward declarations for byte-compiler (ox-reveal loaded via use-package) (defvar org-reveal-root) (defvar org-reveal-single-file) (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 --------------------------------- (defconst cj/reveal-root (expand-file-name "reveal.js" user-emacs-directory) "Local reveal.js installation directory.") (defconst cj/reveal-default-theme "black" "Default reveal.js theme for new presentations.") (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