Skip to content

Instantly share code, notes, and snippets.

@meisterx2020
meisterx2020 / Text Converter
Created June 14, 2023 07:46
Text Converter for Teachable .VTT file
data:text/html,<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>Text Converter</title> <style>textarea{width: 400px; height: 200px;}</style> <script>function processLines(lines){var timestampFound=false; var filteredLines=[]; var previousLineEnds=[".", "?", "!"]; for (var i=0; i < lines.length; i++){var line=lines[i]; if (line.indexOf("-->") !==-1){timestampFound=true;}if (timestampFound){filteredLines.push(line);}}var processedLines=[]; for (var i=0; i < filteredLines.length; i++){var line=filteredLines[i].trim(); if (line.length <=4){continue;}if (line===""){continue;}if (line.indexOf("-->") !==-1){if (processedLines.length > 0 && !previousLineEnds.some(function(lineEnd){return processedLines[processedLines.length - 1].indexOf(lineEnd) !==-1;})){continue;}}processedLines.push(line);}var finalLines=[]; for (var i=0; i < processedLines.length; i++){var line=processedLines[i]; if (line.indexOf("-->") !==-1){line +="\n";}if (line.endsWith(".") || line.endsWith("?") || line.endsWith("!")){line +="\n\n"