/******************************************************************************/ /* */ /* md2slides.rex - Markdown to interactive slide deck */ /* ================================================== */ /* */ /* This program is part of the Rexx Parser package */ /* [See https://rexx.epbcn.com/rexx-parser/] */ /* */ /* Copyright (c) 2024-2026 Josep Maria Blasco */ /* */ /* License: Apache License 2.0 (https://www.apache.org/licenses/LICENSE-2.0) */ /* */ /* Date Version Details */ /* -------- ------- --------------------------------------------------------- */ /* 20260815 0.6 First prototype */ /* 20261119 A syntax error in a Rexx block is the condition USER */ /* REXX.PARSER.ERROR (THROW, RFE #31; ooRexx r13546 or */ /* later), reported by ReportParseError */ /* 20261121 The about page asks the parser its version */ /* (.Rexx.Parser~version), not the readme.md of the project */ /* 20261122 rexxpub/SearchPath.cls first: the parser is the one of */ /* the installed ooRexx, and finds rexxpub/ (Spots, */ /* GridTables, the LaTeX driver) in REXX_PATH */ /* */ /******************************************************************************/ /* */ /* Sibling of md2html and md2pdf. Where md2html produces a page and md2pdf a */ /* paginated document, md2slides produces an INTERACTIVE deck: one HTML file */ /* holding every slide, driven by the deck runtime (keys, fragments, timers, */ /* jump popup). */ /* */ /* It shares the whole common core, so nothing new is parsed here: */ /* */ /* FencedCode -> the Rexx Highlighter marks up the ~~~rexx blocks */ /* Pandoc -> Markdown becomes HTML, attributes and all */ /* md2slides -> that flat HTML is FOLDED into
*/ /* */ /* The folding is the only genuinely new step, and it is what this file is */ /* about. Everything the author writes reaches it as ordinary Pandoc output: */ /* */ /* # Title {#id .role kicker="..." anim=... wait-before=...} */ /* */ /* becomes an

carrying id, class and data-* attributes, and those move */ /* onto the
that the h1 opens. An h1 starts a slide; that is the */ /* whole rule. No {.newpage} marker is needed -- the slides docclass dropped */ /* that requirement in April, and this follows suit. */ /* */ /* Identity is two orthogonal axes, and this file emits neither: it lays out */ /* STRUCTURE and never names a font, a colour or a logo. The SKIN (-t) */ /* brings the brand -- fonts, palette, footer strings, in :root variables; */ /* the MASTER(s) (-mp) bring the presentation -- the rules that read those */ /* variables. Adding an institution is a skin; adding a kind of presentation */ /* is a master. Neither is a change here. */ /* */ /******************************************************************************/ Call Time R CLIhelper = InitCLI() myName = CLIhelper~name myHelp = CLIhelper~help myArgs = CLIhelper~args -- md2slides lives at /bin/md2slides.rex, so the project root is two -- levels up. The shared css/pandoc/ style sheets (and anything else md2slides -- borrows from the project) are resolved against this, exactly as md2pdf -- does -- no duplicated copies under the md2slides home. rootDir = .File~new(.context~package~name)~parentFile~parent rootDir = ChangeStr("\", rootDir, "/") ------------------------------------------------------------------------------ -- Ensure that we have access to pandoc -- ------------------------------------------------------------------------------ Address COMMAND "pandoc -v" With Output Stem pandocV. Error Stem Discard. If RC <> 0 Then Call Error myName "needs a working version of pandoc. Aborting..." ------------------------------------------------------------------------------ -- Command line -- ------------------------------------------------------------------------------ skin = DefaultSkinName() -- The skin sheet (the -s axis): a FILE, skinFromCLI = 0 -- ...unless -s/--skin says otherwise. masters = .Array~new -- Presentation masters to layer, in order -- (the -mp axis). Empty means "the default -- master sheet", resolved like any other. -- Multi-valued: the flag order IS the -- cascade order. mastersFromCLI = 0 -- ...true once -mp names at least one. imgDirs = .Array~new -- Extra picture folders for the DECK (the -- --img axis), searched in the order given -- after the deck's own img/. Repeatable. -- Decks only: a skin or master keeps its -- own img/ beside itself. imgFromCLI = 0 -- ...true once --img names at least one. pictureSize = "" -- --picture-size: the longest side a -- picture may keep (see PictureSize). -- "" = not given; the front matter or -- the default decides. home = rootDir"/bin/md2slides" -- md2slides home: the PRODUCT's own parts -- (templates/deck.template, the five -- css/, js/runtime.js) live here and -- nowhere else. Anchored to the .rex -- location, not the CWD, so md2slides -- runs from any directory. NOT an option: -- a program's own machinery is not a -- thing the caller gets to relocate. csl = "rexxpub" -- Citation Style Language style. A bare -- name resolves to csl/.csl in the -- project; a path is used as-is. Citeproc -- is activated by the deck declaring a -- bibliography:, not by this option; -- --csl only chooses WHICH style. hlStyle = "" -- Pandoc highlighting style for non-Rexx -- code. Precedence: --pandoc-highlight -- flag > skin's own --skin-pandoc-style -- > "pygments". Read from the project's -- shared css/pandoc/. args = .Array~new editMode = 0 -- --edit: serve the deck and take d's editPort = "" -- changes back into the .md (v281) editToken = "" -- --edit-build: the build the server -- asks for (see EditServer) passArgs = "" -- what the server passes on to it argCount = myArgs~items i = 1 Loop While i <= argCount arg = myArgs[i] Select Case arg When "-h", "--help" Then Do Call Help Exit 0 End When "-s", "--skin" Then Do i = i + 1 skin = myArgs[i] passArgs = passArgs arg EditQuote(myArgs[i]) skinFromCLI = 1 End When "-mp", "--master-pages" Then Do -- Repeatable, one master per occurrence; occurrences stack in the order -- they appear, because that order IS the CSS cascade. Three layers are -- '-mp base -mp economia -mp urgencia', base applied first. Repeating -- the flag (rather than a greedy list) keeps it unambiguous against the -- positional deck and destination, and needs no -- fence. i = i + 1 masters~append(myArgs[i]) passArgs = passArgs arg EditQuote(myArgs[i]) mastersFromCLI = 1 End When "--img" Then Do -- Repeatable, one folder per occurrence, searched in the order given -- AFTER the deck's own img/. It adds to the pool, it does not replace -- it: a deck normally has pictures of its own AND wants a shared one, -- and a flag that swapped the folder would force the author's own -- pictures out of their deck to get at the shared one. i = i + 1 imgDirs~append(myArgs[i]) passArgs = passArgs arg EditQuote(myArgs[i]) imgFromCLI = 1 End When "--picture-size" Then Do -- The longest side, in pixels, a picture keeps in the deck; "no" -- embeds every picture as it is. Beats picture-size: in the front -- matter, like every flag here. i = i + 1 pictureSize = myArgs[i] passArgs = passArgs arg EditQuote(myArgs[i]) End When "--csl" Then Do -- Chooses the citation style, exactly as md2pdf does. A bare name -- (no path separator) resolves to the project's shared csl/.css; -- an argument containing a separator is a path used as-is. This does -- NOT switch citations on -- that is the bibliography:'s job (below); -- it only overrides the default 'rexxpub' when a bibliography exists. i = i + 1 csl = myArgs[i] passArgs = passArgs arg EditQuote(myArgs[i]) End When "--pandoc-highlight" Then Do -- The Pandoc style that colours non-Rexx code tokens, read from the -- project's shared css/pandoc/