You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

24 lines
537 B

function CompileText(ast) {
let str = "";
const mapper = node => {
node.forEach(element => {
if (typeof element === "string") {
str = str + element;
} else if (typeof element === "object") {
let result = "";
if (element.type === "url") {
result = mapper(element.children);
str += mapper(element.children) + " (" + element.url + ")";
} else {
result = mapper(element.children);
str = str + result;
}
}
});
return "";
};
mapper(ast);
return str;
}
module.exports = CompileText;