#!/usr/bin/env bash

Remark — Markdown slideshow generator (inspired by gnab/remark 12K+ stars)

set -euo pipefail

CMD="${1:-help}"; shift 2>/dev/null || true

case "$CMD" in

help) echo "Remark — HTML slideshow from Markdown

Commands:

generate Convert MD to HTML slideshow

preview Generate and show file path

theme Apply theme (dark/light/solarized)

speaker Add speaker notes format

info Version info

Powered by BytesAgain | bytesagain.com";;

generate)

f="${1:-}"; [ -z "$f" ] && { echo "Usage: generate "; exit 1; }

out="${f%.md}.html"

python3 << PYEOF

with open("$f") as fh: md = fh.read()

html = """

Slides

"""

slides = md.split("

")

for i, slide in enumerate(slides):

content = slide.strip()

if not content: continue

html += '

'

for line in content.split("\\n"):

line = line.strip()

if line.startswith("# "): html += "

{}

".format(line[2:])

elif line.startswith("## "): html += "

{}

".format(line[3:])

elif line.startswith("### "): html += "

{}

".format(line[4:])

elif line.startswith("- "): html += "

  • {}
  • ".format(line[2:])

    elif line: html += "

    {}

    ".format(line)

    html += "

    \\n"

    html += '

    '

    with open("$out", "w") as fh: fh.write(html)

    print("Generated: $out ({} slides)".format(len(slides)))

    PYEOF

    ;;

    preview)

    f="${1:-}"; [ -z "$f" ] && { echo "Usage: preview "; exit 1; }

    bash "$0" generate "$f"

    out="${f%.md}.html"

    echo "Open in browser: file://$(readlink -f "$out" 2>/dev/null || echo "$out")";;

    theme)

    name="${1:-dark}"

    case "$name" in

    dark) echo "background:#1a1a2e;color:#eee;h1{color:#e94560}";;

    light) echo "background:#fff;color:#333;h1{color:#0f3460}";;

    solarized) echo "background:#002b36;color:#839496;h1{color:#b58900}";;

    *) echo "Themes: dark, light, solarized";;

    esac;;

    speaker)

    f="${1:-}"; [ -z "$f" ] && { echo "Usage: speaker "; exit 1; }

    echo "Add speaker notes with ???:"

    echo " ## Slide Title"

    echo " Content here"

    echo " ???"

    echo " Speaker notes go here";;

    info) echo "Remark v1.0.0"; echo "Inspired by: gnab/remark (12,000+ stars)"; echo "Powered by BytesAgain | bytesagain.com";;

    *) echo "Unknown: $CMD"; exit 1;;

    esac