hmmlib-js: multiple guests/annotators/co-hosts update

This commit is contained in:
Alex Baines 2017-06-20 21:15:26 +01:00
parent f23eceace0
commit bd74374962
3 changed files with 141 additions and 148 deletions

View File

@ -3,19 +3,16 @@ function HMML_parse(contents) {
var state = { var state = {
line: 0, line: 0,
annos: [], annos: [],
meta: {}, meta: {
annotators: [],
guests: [],
co_hosts: []
},
an: { an: {
line: 0, line: 0,
time: "",
text: "", text: "",
author: "",
references: [], references: [],
markers: [], markers: [],
quote: {
id: 0,
author: ""
},
is_quote: false
}, },
ref: {}, ref: {},
first: true first: true
@ -27,13 +24,6 @@ function HMML_parse(contents) {
do { do {
r = l.next(); r = l.next();
} while (!r); } while (!r);
state.annos.forEach(function(a) {
if (!a.is_quote) {
delete a.quote;
}
if (a.author === "") delete a.author;
delete a.is_quote;
});
return { return {
metadata: state.meta, metadata: state.meta,
annotations: state.annos annotations: state.annos
@ -425,16 +415,9 @@ HMMLexer.prototype = {
if (!yy.first) yy.annos.push(yy.an); if (!yy.first) yy.annos.push(yy.an);
yy.an = { yy.an = {
line: yy.line, line: yy.line,
time: "",
text: "", text: "",
author: "",
references: [], references: [],
markers: [], markers: [],
quote: {
id: 0,
author: ""
},
is_quote: false
}; };
yy.an.line = yy.line; yy.an.line = yy.line;
yy.first = false; yy.first = false;
@ -485,16 +468,16 @@ HMMLexer.prototype = {
yy_.begin("V_ATTR"); yy_.begin("V_ATTR");
break; break;
case 12: case 12:
yy.attr = "co_host" yy.attr = "co_hosts"
yy_.begin("V_ATTR"); yy_.begin("V2_ATTR");
break; break;
case 13: case 13:
yy.attr = "guest" yy.attr = "guests"
yy_.begin("V_ATTR"); yy_.begin("V2_ATTR");
break; break;
case 14: case 14:
yy.attr = "annotator"; yy.attr = "annotators";
yy_.begin("V_ATTR"); yy_.begin("V2_ATTR");
break; break;
case 15: case 15:
yy_.begin("ANNOTATION"); yy_.begin("ANNOTATION");
@ -518,121 +501,136 @@ HMMLexer.prototype = {
yy_.begin("VIDEO"); yy_.begin("VIDEO");
break; break;
case 21: case 21:
yy_.begin("VIDEO");
break;
case 22:
yy.meta[yy.attr].push(yy_.yytext);
yy_.begin("VIDEO");
break;
case 23:
yy.meta[yy.attr].push(UNQUOTE(yy, yy_.yytext.substr(1, yy_.yyleng - 2)));
yy_.begin("VIDEO");
break;
case 24:
yy_.less(0);
yy_.begin("VIDEO");
break;
case 25:
NEWANNO(yy); NEWANNO(yy);
return 1; return 1;
break; break;
case 22: case 26:
NEWANNO(yy); NEWANNO(yy);
yy.an.time = yy_.yytext.substr(1, yy_.yyleng - 4); yy.an.time = yy_.yytext.substr(1, yy_.yyleng - 4);
yy_.begin("AUTHOR"); yy_.begin("AUTHOR");
break; break;
case 23: case 27:
NEWANNO(yy); NEWANNO(yy);
yy.an.time = yy_.yytext.substr(1, yy_.yyleng - 2); yy.an.time = yy_.yytext.substr(1, yy_.yyleng - 2);
yy_.begin("TEXT_START"); yy_.begin("TEXT_START");
break; break;
case 24: case 28:
ERR(yy, "Timecode '" + yy_.yytext + "' out of range."); ERR(yy, "Timecode '" + yy_.yytext + "' out of range.");
break; break;
case 25: case 29:
break; break;
case 26: case 30:
ERR(yy, "Cannot parse annotation. Expected timecode."); ERR(yy, "Cannot parse annotation. Expected timecode.");
break; break;
case 27: case 31:
M_(yy, "CATEGORY", "TEXT"); M_(yy, "CATEGORY", "TEXT");
yy_.begin("MARKER"); yy_.begin("MARKER");
break; break;
case 28: case 32:
M_(yy, "MEMBER", "TEXT"); M_(yy, "MEMBER", "TEXT");
yy_.begin("MARKER"); yy_.begin("MARKER");
break; break;
case 29: case 33:
M_(yy, "PROJECT", "TEXT"); M_(yy, "PROJECT", "TEXT");
yy_.begin("MARKER"); yy_.begin("MARKER");
break; break;
case 30: case 34:
yy_.less(0); yy_.less(0);
yy_.begin("TEXT"); yy_.begin("TEXT");
break; break;
case 31: case 35:
ERR(yy, "Unknown character '" + yy_.yytext + "' after timecode."); ERR(yy, "Unknown character '" + yy_.yytext + "' after timecode.");
break; break;
case 32: case 36:
yy.an.text += yy_.yytext; yy.an.text += yy_.yytext;
break; break;
case 33: case 37:
CHECKESCAPE(yy, yy_.yytext.charAt(1)); CHECKESCAPE(yy, yy_.yytext.charAt(1));
yy.an.text += yy_.yytext.substr(1, yy_.yyleng - 1); yy.an.text += yy_.yytext.substr(1, yy_.yyleng - 1);
break; break;
case 34: case 38:
yy.an.text += ' '; yy.an.text += ' ';
M_(yy, "CATEGORY", "TEXT"); M_(yy, "CATEGORY", "TEXT");
yy_.begin("MARKER"); yy_.begin("MARKER");
break; break;
case 35: case 39:
yy.an.text += ' '; yy.an.text += ' ';
M_(yy, "MEMBER", "TEXT"); M_(yy, "MEMBER", "TEXT");
yy_.begin("MARKER"); yy_.begin("MARKER");
break; break;
case 36: case 40:
yy.an.text += ' '; yy.an.text += ' ';
M_(yy, "PROJECT", "TEXT"); M_(yy, "PROJECT", "TEXT");
yy_.begin("MARKER"); yy_.begin("MARKER");
break; break;
case 37: case 41:
M_(yy, "CATEGORY", "MARKER_XTRA"); M_(yy, "CATEGORY", "MARKER_XTRA");
yy_.begin("MARKER"); yy_.begin("MARKER");
break; break;
case 38: case 42:
M_(yy, "MEMBER", "MARKER_XTRA"); M_(yy, "MEMBER", "MARKER_XTRA");
yy_.begin("MARKER"); yy_.begin("MARKER");
break; break;
case 39: case 43:
M_(yy, "PROJECT", "MARKER_XTRA"); M_(yy, "PROJECT", "MARKER_XTRA");
yy_.begin("MARKER"); yy_.begin("MARKER");
break; break;
case 40: case 44:
yy_.begin("AFTERTEXT"); yy_.begin("AFTERTEXT");
break; break;
case 41: case 45:
yy.ref.offset = yy.an.text.length; yy.ref.offset = yy.an.text.length;
yy_.begin("REF"); yy_.begin("REF");
break; break;
case 42: case 46:
break; break;
case 43: case 47:
yy.an.text += ' '; yy.an.text += ' ';
break; break;
case 44: case 48:
yy.an.text += yy_.yytext; yy.an.text += yy_.yytext;
break; break;
case 45: case 49:
M_ADD(yy, yy_.yytext); M_ADD(yy, yy_.yytext);
yy_.begin(yy.mnext); yy_.begin(yy.mnext);
break; break;
case 46: case 50:
M_ADD(yy, yy_.yytext.substr(1, yy_.yyleng - 2)); M_ADD(yy, yy_.yytext.substr(1, yy_.yyleng - 2));
yy_.begin(yy.mnext); yy_.begin(yy.mnext);
break; break;
case 47: case 51:
ERR(yy, "Cannot parse Marker. Expected quoted or alphanumeric attribute."); ERR(yy, "Cannot parse Marker. Expected quoted or alphanumeric attribute.");
break; break;
case 48: case 52:
MX_ADD(yy, ']'); MX_ADD(yy, ']');
break; break;
case 49: case 53:
MX_ADD(yy, '#'); MX_ADD(yy, '#');
break; break;
case 50: case 54:
yy_.begin("TEXT"); yy_.begin("TEXT");
break; break;
case 51: case 55:
if (yy.an.markers[yy.an.markers.length - 1].parameter) { if (yy.an.markers[yy.an.markers.length - 1].parameter) {
MX_ADD(yy, ' '); MX_ADD(yy, ' ');
} }
break; break;
case 52: case 56:
var m = yy.an.markers[yy.an.markers.length - 1]; var m = yy.an.markers[yy.an.markers.length - 1];
if (m.type == "PROJECT") { if (m.type == "PROJECT") {
m.episode = yy_.yytext.substr(2); m.episode = yy_.yytext.substr(2);
@ -641,178 +639,184 @@ HMMLexer.prototype = {
} }
break; break;
case 53: case 57:
MX_ADD(yy, yy_.yytext); MX_ADD(yy, yy_.yytext);
break; break;
case 54: case 58:
break; break;
case 55: case 59:
yy.attr = "site"; yy.attr = "site";
yy_.begin("R_ATTR"); yy_.begin("R_ATTR");
break; break;
case 56: case 60:
yy.attr = "page"; yy.attr = "page";
yy_.begin("R_ATTR"); yy_.begin("R_ATTR");
break; break;
case 57: case 61:
yy.attr = "url"; yy.attr = "url";
yy_.begin("R_ATTR"); yy_.begin("R_ATTR");
break; break;
case 58: case 62:
yy.attr = "title"; yy.attr = "title";
yy_.begin("R_ATTR"); yy_.begin("R_ATTR");
break; break;
case 59: case 63:
yy.attr = "article"; yy.attr = "article";
yy_.begin("R_ATTR"); yy_.begin("R_ATTR");
break; break;
case 60: case 64:
yy.attr = "author"; yy.attr = "author";
yy_.begin("R_ATTR"); yy_.begin("R_ATTR");
break; break;
case 61: case 65:
yy.attr = "editor"; yy.attr = "editor";
yy_.begin("R_ATTR"); yy_.begin("R_ATTR");
break; break;
case 62: case 66:
yy.attr = "publisher"; yy.attr = "publisher";
yy_.begin("R_ATTR"); yy_.begin("R_ATTR");
break; break;
case 63: case 67:
yy.attr = "isbn"; yy.attr = "isbn";
yy_.begin("R_ATTR"); yy_.begin("R_ATTR");
break; break;
case 64: case 68:
yy.an.references.push(yy.ref); yy.an.references.push(yy.ref);
yy.ref = {}; yy.ref = {};
yy_.begin("TEXT"); yy_.begin("TEXT");
break; break;
case 65:
ERR(yy, "Unexpected item in ref: " + yy_.yytext);
break;
case 66:
break;
case 67:
yy.ref[yy.attr] = yy_.yytext;
yy_.begin("REF");
break;
case 68:
yy.ref[yy.attr] = UNQUOTE(yy, yy_.yytext.substr(1, yy_.yyleng - 2));
yy_.begin("REF");
break;
case 69: case 69:
NEWANNO(yy); ERR(yy, "Unexpected item in ref: " + yy_.yytext);
return 1;
break; break;
case 70: case 70:
break; break;
case 71: case 71:
yy_.begin("QUOTES"); yy.ref[yy.attr] = yy_.yytext;
yy_.begin("REF");
break; break;
case 72: case 72:
yy.ref[yy.attr] = UNQUOTE(yy, yy_.yytext.substr(1, yy_.yyleng - 2));
yy_.begin("REF");
break;
case 73:
NEWANNO(yy);
return 1;
break;
case 74:
break;
case 75:
yy_.begin("QUOTES");
break;
case 76:
yy_.begin("CATEGORIES"); yy_.begin("CATEGORIES");
yy_.less(1); yy_.less(1);
break; break;
case 73: case 77:
yy_.begin("ANNOTATION"); yy_.begin("ANNOTATION");
yy_.less(0); yy_.less(0);
break; break;
case 74: case 78:
ERR(yy, "Unexpected thing after text node: " + yy_.yytext); ERR(yy, "Unexpected thing after text node: " + yy_.yytext);
break; break;
case 75: case 79:
ERR(yy, "Unexpected thing after text node: " + yy_.yytext); ERR(yy, "Unexpected thing after text node: " + yy_.yytext);
break; break;
case 76: case 80:
yy.an.author = yy_.yytext.substr(0, yy_.yyleng - 1); yy.an.author = yy_.yytext.substr(0, yy_.yyleng - 1);
yy_.begin("TEXT_START"); yy_.begin("TEXT_START");
break; break;
case 77: case 81:
break; break;
case 78: case 82:
break; break;
case 79: case 83:
yy.an.markers.push({ yy.an.markers.push({
type: "CATEGORY", type: "CATEGORY",
marker: yy_.yytext.substr(1, yy_.yyleng - 1), marker: yy_.yytext.substr(1, yy_.yyleng - 1),
offset: -1 offset: -1
}); });
break; break;
case 80: case 84:
yy.an.markers.push({ yy.an.markers.push({
type: "CATEGORY", type: "CATEGORY",
marker: UNQUOTE(yy, yy_.yytext.substr(2, yy_.yyleng - 3)), marker: UNQUOTE(yy, yy_.yytext.substr(2, yy_.yyleng - 3)),
offset: -1 offset: -1
}); });
break; break;
case 81: case 85:
yy_.begin("QUOTES"); yy_.begin("QUOTES");
break; break;
case 82:
yy_.begin("ANNOTATION");
break;
case 83:
ERR(yy, "Unexpected character in category tag: " + yy_.yytext);
break;
case 84:
break;
case 85:
yy.an.is_quote = true;
yy.an.quote.id = parseInt(yy_.yytext);
yy_.begin("ANNOTATION");
break;
case 86: case 86:
yy.an.quote.author += yy_.yytext; yy_.begin("ANNOTATION");
break; break;
case 87: case 87:
ERR(yy, "Unexpected character in category tag: " + yy_.yytext);
break;
case 88:
break;
case 89:
yy.an.quote = {
author: "",
id: parseInt(yy_.yytext)
};
yy_.begin("ANNOTATION");
break;
case 90:
yy.an.quote.author += yy_.yytext;
break;
case 91:
ERR(yy, "Unexpected character in quotes tag: " + yy_.yytext); ERR(yy, "Unexpected character in quotes tag: " + yy_.yytext);
break; break;
} }
}, },
rules: [/^(?:$)/, /^(?:\r\n|\n)/, /^(?:(\[video\b))/, /^(?:.)/, /^(?:([\t \r]+))/, /^(?:member([\t \r]*)=)/, /^(?:stream_platform([\t \r]*)=)/, /^(?:stream_username([\t \r]*)=)/, /^(?:project([\t \r]*)=)/, /^(?:title([\t \r]*)=)/, /^(?:vod_platform([\t \r]*)=)/, /^(?:id([\t \r]*)=)/, /^(?:co_host([\t \r]*)=)/, /^(?:guest([\t \r]*)=)/, /^(?:annotator([\t \r]*)=)/, /^(?:\])/, /^(?:.)/, /^(?:([\t \r]+))/, /^(?:([^\" \]\t\r\n][^ \]\t\r\n]*))/, /^(?:("([^\n\"\\]|\\.)*"))/, /^(?:\])/, /^(?:\[\/video\])/, /^(?:(\[[0-9]{1,2}(:[0-5][0-9]){1,2}\])(\[)@)/, /^(?:(\[[0-9]{1,2}(:[0-5][0-9]){1,2}\]))/, /^(?:(\[[0-9]{1,2}(:[6-9][0-9]){1,2}\]))/, /^(?:([\t \r]+))/, /^(?:.)/, /^(?:(\[):)/, /^(?:(\[)@)/, /^(?:(\[)~)/, /^(?:(\[))/, /^(?:.)/, /^(?:([^\\\:\@\~\[\]\r\n\t ])+)/, /^(?:\\.)/, /^(?:[ \r\t]+:)/, /^(?:[ \r\t]+@)/, /^(?:[ \r\t]+~)/, /^(?:(\[):)/, /^(?:(\[)@)/, /^(?:(\[)~)/, /^(?:\])/, /^(?:(\[)ref\b)/, /^(?:(\[))/, /^(?:([\t \r]+))/, /^(?:.)/, /^(?:([0-9a-zA-Z][0-9a-zA-Z_]*))/, /^(?:("([^\n\"\\]|\\.)*"))/, /^(?:.)/, /^(?:\\)/, /^(?:\\#)/, /^(?:\])/, /^(?:[ ])/, /^(?:[ ]#[0-9]+)/, /^(?:.)/, /^(?:([\t \r]+))/, /^(?:site([\t \r]*)=)/, /^(?:page([\t \r]*)=)/, /^(?:url([\t \r]*)=)/, /^(?:title([\t \r]*)=)/, /^(?:article([\t \r]*)=)/, /^(?:author([\t \r]*)=)/, /^(?:editor([\t \r]*)=)/, /^(?:publisher([\t \r]*)=)/, /^(?:isbn([\t \r]*)=)/, /^(?:\])/, /^(?:.)/, /^(?:([\t \r]+))/, /^(?:([^\" \]\t\r\n][^ \]\t\r\n]*))/, /^(?:("([^\n\"\\]|\\.)*"))/, /^(?:\[\/video\])/, /^(?:([\t \r]+))/, /^(?:(\[)quote\b)/, /^(?:(\[):)/, /^(?:(\[)[0-9])/, /^(?:..)/, /^(?:.)/, /^(?:[^\]\n]+\])/, /^(?:([\t \r]+))/, /^(?:([\t \r]+))/, /^(?::([^\" \]\t\r\n][^ \]\t\r\n]*))/, /^(?::("([^\n\"\\]|\\.)*"))/, /^(?:\](\[))/, /^(?:\])/, /^(?:.)/, /^(?:([\t \r]+))/, /^(?:[0-9]+([\t \r]*)\])/, /^(?:([0-9a-zA-Z][0-9a-zA-Z_]*))/, /^(?:.)/], rules: [/^(?:$)/, /^(?:\r\n|\n)/, /^(?:(\[video\b))/, /^(?:.)/, /^(?:([\t \r]+))/, /^(?:member([\t \r]*)=)/, /^(?:stream_platform([\t \r]*)=)/, /^(?:stream_username([\t \r]*)=)/, /^(?:project([\t \r]*)=)/, /^(?:title([\t \r]*)=)/, /^(?:vod_platform([\t \r]*)=)/, /^(?:id([\t \r]*)=)/, /^(?:co-host([\t \r]*)=)/, /^(?:guest([\t \r]*)=)/, /^(?:annotator([\t \r]*)=)/, /^(?:\])/, /^(?:.)/, /^(?:([\t \r]+))/, /^(?:([^\" \]\t\r\n][^ \]\t\r\n]*))/, /^(?:("([^\n\"\\]|\\.)*"))/, /^(?:\])/, /^(?:([\t \r]+))/, /^(?:([^\" \]\t\r\n][^ \]\t\r\n]*))/, /^(?:("([^\n\"\\]|\\.)*"))/, /^(?:\])/, /^(?:\[\/video\])/, /^(?:(\[[0-9]{1,2}(:[0-5][0-9]){1,2}\])(\[)@)/, /^(?:(\[[0-9]{1,2}(:[0-5][0-9]){1,2}\]))/, /^(?:(\[[0-9]{1,2}(:[6-9][0-9]){1,2}\]))/, /^(?:([\t \r]+))/, /^(?:.)/, /^(?:(\[):)/, /^(?:(\[)@)/, /^(?:(\[)~)/, /^(?:(\[))/, /^(?:.)/, /^(?:([^\\\:\@\~\[\]\r\n\t ])+)/, /^(?:\\.)/, /^(?:[ \r\t]+:)/, /^(?:[ \r\t]+@)/, /^(?:[ \r\t]+~)/, /^(?:(\[):)/, /^(?:(\[)@)/, /^(?:(\[)~)/, /^(?:\])/, /^(?:(\[)ref\b)/, /^(?:(\[))/, /^(?:([\t \r]+))/, /^(?:.)/, /^(?:([0-9a-zA-Z][0-9a-zA-Z_]*))/, /^(?:("([^\n\"\\]|\\.)*"))/, /^(?:.)/, /^(?:\\)/, /^(?:\\#)/, /^(?:\])/, /^(?:[ ])/, /^(?:[ ]#[0-9]+)/, /^(?:.)/, /^(?:([\t \r]+))/, /^(?:site([\t \r]*)=)/, /^(?:page([\t \r]*)=)/, /^(?:url([\t \r]*)=)/, /^(?:title([\t \r]*)=)/, /^(?:article([\t \r]*)=)/, /^(?:author([\t \r]*)=)/, /^(?:editor([\t \r]*)=)/, /^(?:publisher([\t \r]*)=)/, /^(?:isbn([\t \r]*)=)/, /^(?:\])/, /^(?:.)/, /^(?:([\t \r]+))/, /^(?:([^\" \]\t\r\n][^ \]\t\r\n]*))/, /^(?:("([^\n\"\\]|\\.)*"))/, /^(?:\[\/video\])/, /^(?:([\t \r]+))/, /^(?:(\[)quote\b)/, /^(?:(\[):)/, /^(?:(\[)[0-9])/, /^(?:..)/, /^(?:.)/, /^(?:[^\]\n]+\])/, /^(?:([\t \r]+))/, /^(?:([\t \r]+))/, /^(?::([^\" \]\t\r\n][^ \]\t\r\n]*))/, /^(?::("([^\n\"\\]|\\.)*"))/, /^(?:\](\[))/, /^(?:\])/, /^(?:.)/, /^(?:([\t \r]+))/, /^(?:[0-9]+([\t \r]*)\])/, /^(?:([0-9a-zA-Z][0-9a-zA-Z_]*))/, /^(?:.)/],
conditions: { conditions: {
"QUOTES": { "QUOTES": {
"rules": [0, 1, 84, 85, 86, 87], "rules": [0, 1, 88, 89, 90, 91],
"inclusive": true "inclusive": true
}, },
"CATEGORIES": { "CATEGORIES": {
"rules": [0, 1, 78, 79, 80, 81, 82, 83], "rules": [0, 1, 82, 83, 84, 85, 86, 87],
"inclusive": true "inclusive": true
}, },
"AUTHOR": { "AUTHOR": {
"rules": [0, 1, 76, 77], "rules": [0, 1, 80, 81],
"inclusive": true "inclusive": true
}, },
"AFTERTEXT": { "AFTERTEXT": {
"rules": [0, 1, 69, 70, 71, 72, 73, 74, 75], "rules": [0, 1, 73, 74, 75, 76, 77, 78, 79],
"inclusive": true "inclusive": true
}, },
"R_ATTR": { "R_ATTR": {
"rules": [0, 1, 66, 67, 68], "rules": [0, 1, 70, 71, 72],
"inclusive": true "inclusive": true
}, },
"REF": { "REF": {
"rules": [0, 1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65], "rules": [0, 1, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69],
"inclusive": true "inclusive": true
}, },
"MARKER_XTRA": { "MARKER_XTRA": {
"rules": [0, 1, 48, 49, 50, 51, 52, 53], "rules": [0, 1, 52, 53, 54, 55, 56, 57],
"inclusive": true "inclusive": true
}, },
"MARKER": { "MARKER": {
"rules": [0, 1, 45, 46, 47], "rules": [0, 1, 49, 50, 51],
"inclusive": true "inclusive": true
}, },
"TEXT": { "TEXT": {
"rules": [0, 1, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44], "rules": [0, 1, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48],
"inclusive": true "inclusive": true
}, },
"TEXT_START": { "TEXT_START": {
"rules": [0, 1, 27, 28, 29, 30, 31], "rules": [0, 1, 31, 32, 33, 34, 35],
"inclusive": true "inclusive": true
}, },
"ANNOTATION": { "ANNOTATION": {
"rules": [0, 1, 21, 22, 23, 24, 25, 26], "rules": [0, 1, 25, 26, 27, 28, 29, 30],
"inclusive": true
},
"V2_ATTR": {
"rules": [0, 1, 21, 22, 23, 24],
"inclusive": true "inclusive": true
}, },
"V_ATTR": { "V_ATTR": {

View File

@ -3,19 +3,16 @@ function HMML_parse(contents) {
var state = { var state = {
line: 0, line: 0,
annos: [], annos: [],
meta: {}, meta: {
annotators: [],
guests: [],
co_hosts: []
},
an: { an: {
line: 0, line: 0,
time: "",
text: "", text: "",
author: "",
references: [], references: [],
markers: [], markers: [],
quote: {
id: 0,
author: ""
},
is_quote: false
}, },
ref: {}, ref: {},
first: true first: true
@ -27,13 +24,6 @@ function HMML_parse(contents) {
do { do {
r = l.next(); r = l.next();
} while (!r); } while (!r);
state.annos.forEach(function(a) {
if (!a.is_quote) {
delete a.quote;
}
if (a.author === "") delete a.author;
delete a.is_quote;
});
return { return {
metadata: state.meta, metadata: state.meta,
annotations: state.annos annotations: state.annos

View File

@ -49,16 +49,9 @@
if(!yy.first) yy.annos.push(yy.an); if(!yy.first) yy.annos.push(yy.an);
yy.an = { yy.an = {
line: yy.line, line: yy.line,
time: "",
text: "", text: "",
author: "",
references: [], references: [],
markers: [], markers: [],
quote: {
id: 0,
author: ""
},
is_quote: false
}; };
yy.an.line = yy.line; yy.an.line = yy.line;
yy.first = false; yy.first = false;
@ -82,6 +75,7 @@ RB \]
%s VIDEO %s VIDEO
%s V_ATTR %s V_ATTR
%s V2_ATTR
%s ANNOTATION %s ANNOTATION
%s TEXT_START %s TEXT_START
%s TEXT %s TEXT
@ -110,9 +104,9 @@ RB \]
<VIDEO>title{S}\= { yy.attr = "title"; yy_.begin("V_ATTR"); } <VIDEO>title{S}\= { yy.attr = "title"; yy_.begin("V_ATTR"); }
<VIDEO>vod_platform{S}\= { yy.attr = "vod_platform"; yy_.begin("V_ATTR"); } <VIDEO>vod_platform{S}\= { yy.attr = "vod_platform"; yy_.begin("V_ATTR"); }
<VIDEO>id{S}\= { yy.attr = "id"; yy_.begin("V_ATTR"); } <VIDEO>id{S}\= { yy.attr = "id"; yy_.begin("V_ATTR"); }
<VIDEO>co_host{S}\= { yy.attr = "co_host" yy_.begin("V_ATTR"); } <VIDEO>co\-host{S}\= { yy.attr = "co_hosts" yy_.begin("V2_ATTR"); }
<VIDEO>guest{S}\= { yy.attr = "guest" yy_.begin("V_ATTR"); } <VIDEO>guest{S}\= { yy.attr = "guests" yy_.begin("V2_ATTR"); }
<VIDEO>annotator{S}\= { yy.attr = "annotator"; yy_.begin("V_ATTR"); } <VIDEO>annotator{S}\= { yy.attr = "annotators"; yy_.begin("V2_ATTR"); }
<VIDEO>\] { yy_.begin("ANNOTATION"); }; <VIDEO>\] { yy_.begin("ANNOTATION"); };
<VIDEO>. { ERR(yy, "Invalid char '"+ yytext +"' in video tag."); } <VIDEO>. { ERR(yy, "Invalid char '"+ yytext +"' in video tag."); }
@ -121,6 +115,11 @@ RB \]
<V_ATTR>{ATTR_QUOTED} { yy.meta[yy.attr] = UNQUOTE(yy, yytext.substr(1, yyleng-2)); yy_.begin("VIDEO"); } <V_ATTR>{ATTR_QUOTED} { yy.meta[yy.attr] = UNQUOTE(yy, yytext.substr(1, yyleng-2)); yy_.begin("VIDEO"); }
<V_ATTR>\] { yy_.less(0); yy_.begin("VIDEO"); } <V_ATTR>\] { yy_.less(0); yy_.begin("VIDEO"); }
<V2_ATTR>{SP} { yy_.begin("VIDEO"); }
<V2_ATTR>{ATTR_SIMPLE} { yy.meta[yy.attr].push(yytext); yy_.begin("VIDEO"); }
<V2_ATTR>{ATTR_QUOTED} { yy.meta[yy.attr].push(UNQUOTE(yy, yytext.substr(1, yyleng-2))); yy_.begin("VIDEO"); }
<V2_ATTR>\] { yy_.less(0); yy_.begin("VIDEO"); }
<ANNOTATION>\[\/video\] { NEWANNO(yy); return 1; } <ANNOTATION>\[\/video\] { NEWANNO(yy); return 1; }
<ANNOTATION>{TIMECODE}{LB}\@ { NEWANNO(yy); yy.an.time = yytext.substr(1, yyleng-4); yy_.begin("AUTHOR"); } <ANNOTATION>{TIMECODE}{LB}\@ { NEWANNO(yy); yy.an.time = yytext.substr(1, yyleng-4); yy_.begin("AUTHOR"); }
<ANNOTATION>{TIMECODE} { NEWANNO(yy); yy.an.time = yytext.substr(1, yyleng-2); yy_.begin("TEXT_START"); } <ANNOTATION>{TIMECODE} { NEWANNO(yy); yy.an.time = yytext.substr(1, yyleng-2); yy_.begin("TEXT_START"); }
@ -203,7 +202,7 @@ RB \]
<CATEGORIES>. { ERR(yy, "Unexpected character in category tag: " + yytext); } <CATEGORIES>. { ERR(yy, "Unexpected character in category tag: " + yytext); }
<QUOTES>{SP} {} <QUOTES>{SP} {}
<QUOTES>[0-9]+{S}\] { yy.an.is_quote = true; yy.an.quote.id = parseInt(yytext); yy_.begin("ANNOTATION"); } <QUOTES>[0-9]+{S}\] { yy.an.quote = { author: "", id: parseInt(yytext) }; yy_.begin("ANNOTATION"); }
<QUOTES>{ATTR_ALNUM} { yy.an.quote.author += yytext; } <QUOTES>{ATTR_ALNUM} { yy.an.quote.author += yytext; }
<QUOTES>. { ERR(yy, "Unexpected character in quotes tag: " + yytext); } <QUOTES>. { ERR(yy, "Unexpected character in quotes tag: " + yytext); }