72 lines
1.5 KiB
JavaScript
72 lines
1.5 KiB
JavaScript
function HMML_parse(contents) {
|
|
var l = new HMMLexer();
|
|
var state = {
|
|
line: 0,
|
|
annos: [],
|
|
meta: {
|
|
member: "",
|
|
twitch: "",
|
|
project: "",
|
|
title: "",
|
|
platform: "",
|
|
id: "",
|
|
annotator: ""
|
|
},
|
|
an: {
|
|
line: 0,
|
|
time: "",
|
|
text: "",
|
|
author: "",
|
|
references: [],
|
|
markers: [],
|
|
quote: {
|
|
id: 0,
|
|
author: ""
|
|
},
|
|
is_quote: false
|
|
},
|
|
ref: {
|
|
site: "",
|
|
page: "",
|
|
url: "",
|
|
title: "",
|
|
article: "",
|
|
author: "",
|
|
editor: "",
|
|
publisher: "",
|
|
isbn: "",
|
|
offset: 0
|
|
},
|
|
attr: "",
|
|
mnext: 0,
|
|
first: true
|
|
};
|
|
l.setInput(contents, state);
|
|
|
|
try {
|
|
var r;
|
|
do {
|
|
r = l.next();
|
|
} 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 {
|
|
metadata: state.meta,
|
|
annotations: state.annos
|
|
};
|
|
} catch (e) {
|
|
return {
|
|
error: e
|
|
};
|
|
}
|
|
}
|
|
|
|
function HMMLexer() {}
|
|
/* generated by jison-lex 0.3.4 */
|
|
HMMLexer.prototype = {
|