#!/bin/sh
# Converts body of stdin simple WEBVTT file to simple stdout HTML5 file.
# The output will likely need further editing.
# Timestamp resolution below 1s is discarded.
# See end of script for sample input and output.


exec awk 'BEGIN {
    inText = 0;
    }
"-->" == $2 {
    cuetime=substr($1, 1, index($1, ".")-1);
    printf("<div class=\"cuetime\" id=\"ct-%s\">\n", cuetime);
    printf("[%s]\n", cuetime);
    print "</div>";
    print "<p>";
    inText = 1;
    next;
    }
"" == $0 {
    if(1 == inText) { print "</p>"; inText = 0; }
    }
1 == inText {
    print $0
    }'


# Should not get here!
exit 1


#Sample WEBVTT body input text:



#01:16.000 --> 01:25.000
#How did I get into it? This is the kind of checking the privilege at the door. I'm white and middle class and so on.
#
#
#01:25.000 --> 01:35.000
#I have all sorts of advantages there, but I didn't only think about electronics when I was thinking of going to university or something.
#
#
#01:35.000 --> 01:41.000
#My dad got me hooked with some really quite simple bulbs and battery circuits, bizarre,
#


#Sample output HTML:


#<div class="cuetime">
#[01:16]
#</div>
#<p>
#How did I get into it? This is the kind of checking the privilege at the door. I'm white and middle class and so on.
#</p>







##########
# May be used / adapted / etc without any promise of fitness for purpose
# under the terms of the Apache License Version 2.0, January 2004
#     http://www.apache.org/licenses/LICENSE-2.0
##########
