Skip to content

A local video studio for your coding agent. Describe a video in one sentence: your agent directs, your machine renders. Claude Code, Codex, Cursor, Devin and more. No API keys, no uploads.

showtime 0.4.6: the HTML export's own-style packing skips scripts and comments ended the way browsers end them; from a job folder, the job's own project counts however its path is written

Favio Vázquez49ccdee9a0b6
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ed6f21e..13ac93c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -94,11 +94,13 @@ it.
figure packed the files of linked stylesheets only; a project's own `@font-face` in the page's `<style>`
(`url("fonts/x.woff2")`) stayed a file the page's policy (`font-src data:`) blocks, so the text fell back to another
font. Files named in the page's own `<style>` blocks are packed like a stylesheet's (only from inside the project),
- and one that is missing stops the export with its name. An inline `<script>` is never rewritten.
+ and one that is missing stops the export with its name. An inline `<script>` or an HTML comment is never rewritten,
+ however it ends: a script at `</script` with more before its `>`, a comment at `--!>`, as browsers end them.
- **Fixed: `export html` from inside a job writes into the job** (#72). On a project inside a job, or run from the job
folder of the project being exported (its `job.json` names it), it made a new `showtime-out/<title>-<time>/`
folder nested in the job; the export now goes into that job, and a live page or figure is noted in its `job.json`.
- Another project exported from a job folder goes where it always did.
+ Another project exported from a job folder goes where it always did. The job's own project counts however its path
+ is written: a Windows short (8.3) name or another letter case.
- **Fixed: a new 16:9 X-ray project passes its own check** (#68). The brand, the tag and the counters sit 96 px (5%)
from the left edge, the counters above the player controls' strip, their labels and the end card's small print are
26 px, and the red letter on the paper card and the end card's number use a red that reads at 4.5:1 on both themes
diff --git a/skills/showtime/scripts/export.mjs b/skills/showtime/scripts/export.mjs
index fa49a57..a844971 100644
--- a/skills/showtime/scripts/export.mjs
+++ b/skills/showtime/scripts/export.mjs
@@ -136,13 +136,25 @@ function ledgerJob(p) {
/** True when the project folder dir is inside job, or is the project its job.json or render.json names. */
export function jobHolds(job, dir) {
- const real = (q) => { try { return fs.realpathSync(q); } catch { return path.resolve(q); } };
+ // one folder however it is written: the native realpath gives Windows' long names (not 8.3 short ones) and the case
+ // on disk, which the JS one keeps as typed; the device and inode decide when the two strings still differ
+ const real = (q) => {
+ for (const rp of [fs.realpathSync.native, fs.realpathSync]) { try { return rp(q); } catch { /* the next one */ } }
+ return path.resolve(q);
+ };
+ const same = (a, b) => {
+ if (a === b) return true;
+ try {
+ const x = fs.statSync(a, { bigint: true }), y = fs.statSync(b, { bigint: true });
+ return x.ino !== 0n && x.ino === y.ino && x.dev === y.dev;
+ } catch { return false; }
+ };
const d = real(dir), j = real(job), rel = path.relative(j, d);
if (rel === '' || (rel.split(path.sep)[0] !== '..' && !path.isAbsolute(rel))) return true;
for (const f of ['job.json', 'render.json']) {
let p = null;
try { p = JSON.parse(fs.readFileSync(path.join(j, f), 'utf8')).project; } catch { /* no such file */ }
- if (typeof p === 'string' && p && real(path.resolve(j, p)) === d) return true;
+ if (typeof p === 'string' && p && same(real(path.resolve(j, p)), d)) return true;
}
return false;
}
diff --git a/skills/showtime/scripts/lib/export/collect.mjs b/skills/showtime/scripts/lib/export/collect.mjs
index 417be30..5f5969e 100644
--- a/skills/showtime/scripts/lib/export/collect.mjs
+++ b/skills/showtime/scripts/lib/export/collect.mjs
@@ -40,16 +40,19 @@ function abs(spec, fromPath) {
} catch { return null; }
}
-/** Rewrite relative/root import specifiers and import.meta.url to absolute virtual URLs. -> {text, deps} */
+// a script ends at "</script" then a space, "/" or ">" (anything after, up to ">"), a comment at "-->" or "--!>", as
+// browsers end them ("</script-x>" does not end a script)
+const OWN_STYLES = /<!--[\s\S]*?--!?>|<script\b[^>]*>[\s\S]*?<\/script(?=[\s/>])[^>]*>|<style\b([^>]*)>([\s\S]*?)<\/style>/gi;
+
/**
* The page's own <style> blocks, each replaced by fn(m, attrs, text), never one inside an inline <script> or an HTML
* comment: a script's "<style>@font-face { src: url(...) }" string is code and stays byte for byte.
*/
export function replaceOwnStyles(html, fn) {
- return html.replace(/<!--[\s\S]*?-->|<script\b[^>]*>[\s\S]*?<\/script\s*>|<style\b([^>]*)>([\s\S]*?)<\/style>/gi,
- (m, attrs, text) => (attrs === undefined ? m : fn(m, attrs, text)));
+ return html.replace(OWN_STYLES, (m, attrs, text) => (attrs === undefined ? m : fn(m, attrs, text)));
}
+/** Rewrite relative/root import specifiers and import.meta.url to absolute virtual URLs. -> {text, deps} */
export function rewriteJs(text, filePath) {
const deps = new Set();
const fix = (spec) => {
diff --git a/skills/showtime/tests/test_export.py b/skills/showtime/tests/test_export.py
index 6bc6dcd..0c84d24 100644
--- a/skills/showtime/tests/test_export.py
+++ b/skills/showtime/tests/test_export.py
@@ -1485,6 +1485,47 @@ SHARE_PAGE = """<!doctype html><html lang="en"><head><meta charset="utf-8"><scri
"""
+OWN_STYLES_DRIVER = r"""
+import path from 'node:path';
+import { pathToFileURL } from 'node:url';
+const { replaceOwnStyles } = await import(pathToFileURL(path.join(process.argv[2], 'scripts', 'lib', 'export', 'collect.mjs')).href);
+const pages = JSON.parse(process.argv[3]);
+console.log(JSON.stringify(pages.map((h) => replaceOwnStyles(h, (m, attrs, text) => '<style' + attrs + '>PACKED</style>'))));
+"""
+
+
+class OwnStylesTest(unittest.TestCase):
+ """The HTML export packs only the page's own <style> blocks: never one inside a script or a comment, however
+ the script or comment ends (browsers end a script at "</script" plus anything up to ">", a comment at "--!>")."""
+
+ OWN = '<style>b{}</style>'
+
+ def packed(self, cases):
+ with tempfile.TemporaryDirectory(prefix="st-own-styles-") as tmp:
+ drv = Path(tmp) / "own.mjs"
+ drv.write_text(OWN_STYLES_DRIVER, encoding="utf-8")
+ node = shutil.which("node", path=ENV.get("PATH")) or "node"
+ cp = subprocess.run([node, str(drv), str(SKILL), json.dumps(cases)], env=ENV, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE, encoding="utf-8", errors="replace", timeout=60)
+ self.assertEqual(cp.returncode, 0, cp.stderr[-2000:])
+ for page, got in zip(cases, json.loads(cp.stdout)):
+ # the script or comment stays byte for byte and the page's own style after it is packed
+ self.assertEqual(got, page.replace(self.OWN, '<style>PACKED</style>'), page)
+
+ def test_a_script_ended_with_more_after_its_name(self):
+ js = '<script>var s = "<style>a{}</style>";'
+ self.packed([js + '</script foo="1">' + self.OWN, js + '</script\t\n bar>' + self.OWN,
+ js + '</SCRIPT >' + self.OWN, js + '</script/>' + self.OWN, js + '</script>' + self.OWN])
+
+ def test_a_longer_tag_name_does_not_end_a_script(self):
+ # "</script-x>" and "</scriptx>" are other tags inside the script's text: the script runs on to its "</script>"
+ js = '<script>var s = "<style>a{}</style>";'
+ self.packed([js + end + ' var t = "<style>z{}</style>";</script>' + self.OWN for end in ('</script-x>', '</scriptx>')])
+
+ def test_a_comment_ended_with_a_bang(self):
+ self.packed(['<!-- <style>c{}</style> --!>' + self.OWN, '<!-- <style>c{}</style> -->' + self.OWN])
+
+
@needs_listen
class ExportFilesTest(unittest.TestCase):
"""Every file the page needs is packed or the export stops; sound files only data names stay out;
diff --git a/skills/showtime/tests/test_xray_live.py b/skills/showtime/tests/test_xray_live.py
index 36a01f5..1403637 100644
--- a/skills/showtime/tests/test_xray_live.py
+++ b/skills/showtime/tests/test_xray_live.py
@@ -256,6 +256,26 @@ class TestCli(unittest.TestCase):
hist = [h["event"] for h in json.loads((job / "job.json").read_text(encoding="utf-8"))["history"]]
self.assertEqual(len([h for h in hist if h.startswith("export html --interactive ")]), 1, hist)
+ def test_from_a_job_its_project_written_another_way_goes_in(self):
+ # #72 on Windows: job.json holds the project's long path while the argument can be its 8.3 short form (a temp
+ # folder under a short home name) or another letter case; it is still the job's own project, so the page goes in
+ base = TMP / "jobs72c"
+ base.mkdir(exist_ok=True)
+ own = TMP / "Own72c"
+ showtime("new", "xray", own)
+ variant = own.with_name(own.name.lower())
+ if not variant.exists():
+ self.skipTest("a case-sensitive file system: no other spelling of the same folder")
+ job = Path(json.loads(showtime("job", "init", "live72c", "--base", base, "--project", own, "--no-check",
+ "--json").stdout)["job"])
+ cp = subprocess.run([sys.executable, str(LAUNCHER), "export", "html", str(variant), "--interactive", "--json"],
+ env=ENV, cwd=str(job), stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf-8",
+ errors="replace", timeout=300)
+ self.assertEqual(cp.returncode, 0, cp.stderr[-2000:])
+ rep = json.loads(cp.stdout)
+ self.assertEqual(Path(rep["output"]).parent.resolve(), job.resolve(), rep["output"])
+ self.assertEqual(Path(rep["job"]).resolve(), job.resolve())
+
def test_diagram_layout(self):
_, out, rep = sample("diagram")
self.assertEqual(rep["layout"], "diagram")