better output

This commit is contained in:
2026-08-28 03:12:27 -06:00
parent 1bcc6cf6c4
commit 5463bdddc9
2 changed files with 13 additions and 3 deletions
+10 -2
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env luajit
local version = "0.3.0"
local version = "0.4.0"
local input_file_name = arg[1]
assert(input_file_name,
@@ -32,6 +32,7 @@ for line in io.lines(input_file_name) do
end
local output_lines = {}
local timecode_free_lines = {}
for index, line in ipairs(input_lines) do
if not (line:sub(3, 3) == ":") then
local previous_line = input_lines[index - 1]
@@ -41,8 +42,10 @@ for index, line in ipairs(input_lines) do
else
output_lines[#output_lines + 1] = "`" .. string.rep(" ", 6) .. line .. "`" -- pandoc will ignore this margin
end
timecode_free_lines[#timecode_free_lines + 1] = line
else
output_lines[#output_lines + 1] = "`" .. line .. "`"
timecode_free_lines[#timecode_free_lines + 1] = line:sub(7)
end
end
@@ -52,9 +55,14 @@ assert(output_file, "Could not open \"" .. output_file_name .. "\"")
output_file:write(table.concat(frontmatter, "\n"))
output_file:write("\n")
output_file:write("# Raw Transcript\n\n")
output_file:write(table.concat(timecode_free_lines, "\n"))
output_file:write("\n\n")
output_file:write("# Timecoded Transcript\n\n")
output_file:write(table.concat(output_lines, "\n"))
output_file:write("\n")
output_file:close()
os.execute("pandoc --from markdown+hard_line_breaks \""
.. output_file_name .. "\" -o \"" .. title .. ".epub\"")
.. output_file_name .. "\" --toc=true -o \"" .. title .. ".epub\"")