diff --git a/ReadMe.md b/ReadMe.md index 9d01490..a17e510 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -20,5 +20,7 @@ I went through many tests and iterations before coming to even this minimal start and it was extremely frustrating. ## Tasks -- [ ] I need an option / 2nd script to output a version with no +- [x] I need an option / 2nd script to output a version with no timecode formatting for easier text extraction. + - I made it actually just combine both in the same document, + easier to manage that way. diff --git a/convert_transcript.lua b/convert_transcript.lua index 23d804d..70b5e60 100755 --- a/convert_transcript.lua +++ b/convert_transcript.lua @@ -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\"")