28 lines
891 B
JavaScript
28 lines
891 B
JavaScript
const converter = new showdown.Converter();
|
|
|
|
fetch("./event-test.xml")
|
|
.then((response) => response.text())
|
|
.then((jsonResponse) => parseXML(jsonResponse))
|
|
.catch((error) => console.error(error));
|
|
|
|
const parseXML = (XML) => {
|
|
const eventItemRegex = /<eventitem.*>(.|\n)*?<\/eventitem>/g;
|
|
const shortRegex = /(?<=<short>)(.|\n)*?(?=<\/short>)/g;
|
|
const abstractRegex = /(?<=<abstract>)(.|\n)*?(?=<\/abstract>)/g;
|
|
|
|
let eventItems = [];
|
|
|
|
// Find how many eventItems there are here
|
|
while ((eventItems = eventItemRegex.exec(XML)) !== null) {
|
|
shortRegex.lastIndex = 0
|
|
abstractRegex.lastIndex = 0
|
|
|
|
const eventItem = eventItems[0];
|
|
console.log(eventItem);
|
|
let short = shortRegex.exec(eventItem);
|
|
console.log(converter.makeMarkdown(short[0]));
|
|
let abstract = abstractRegex.exec(eventItem);
|
|
console.log(converter.makeMarkdown(abstract[0]));
|
|
}
|
|
};
|