From 7c669bf353c873afe16e384e6515ef2ff708082b Mon Sep 17 00:00:00 2001 From: Tangent Date: Wed, 26 Aug 2026 19:20:44 -0600 Subject: [PATCH] init --- .gitignore | 1 + ReadMe.md | 16 ++++++++++++++++ apply_margin.lua | 16 ++++++++++++++++ oops_all_code.lua | 14 ++++++++++++++ 4 files changed, 47 insertions(+) create mode 100644 .gitignore create mode 100644 ReadMe.md create mode 100755 apply_margin.lua create mode 100755 oops_all_code.lua diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/ReadMe.md b/ReadMe.md new file mode 100644 index 0000000..51260e8 --- /dev/null +++ b/ReadMe.md @@ -0,0 +1,16 @@ +This is heavily WIP. + +I used the apply_margin script on a transcript downloaded from +https://www.youtube-transcript.io to correct the poor formatting, +then oops_all_code to add backticks to each line (because else +pandoc encodes all code in a single block no matter how poorly +that aligns with a page boundary when exporting epubs), then +pandoc --from markdown+hard_line_breaks input -o output to finally +have a functional epub that is legible. + +This will probably fail with videos longer than an hour because +the export will be different enough to fuck up the margin fix. + +I am really frustrated because pandoc doesn't support plain text. +I went through many tests and iterations before coming to even +this minimal start and it was extremely frustrating. diff --git a/apply_margin.lua b/apply_margin.lua new file mode 100755 index 0000000..65ce261 --- /dev/null +++ b/apply_margin.lua @@ -0,0 +1,16 @@ +#!/usr/bin/env luajit +local a, b = arg[1], arg[2] + +local file = io.open(b, "w") +assert(file, "Couldn't open \"" .. b .. "\"") + +for line in io.lines(a) do + if not (line:sub(3, 3) == ":") then + file:write(string.rep(" ", 6)) + end + + file:write(line) + file:write("\n") +end + +file:close() diff --git a/oops_all_code.lua b/oops_all_code.lua new file mode 100755 index 0000000..3fa707e --- /dev/null +++ b/oops_all_code.lua @@ -0,0 +1,14 @@ +#!/usr/bin/env luajit +local a, b = arg[1], arg[2] + +local file = io.open(b, "w") +assert(file, "Couldn't open \"" .. b .. "\"") + +for line in io.lines(a) do + file:write("`") + file:write(line) + file:write("`") + file:write("\n") +end + +file:close()