I am passing every test except for every single ‘should return this’ test even though my returned output is exactly correct when logged. Code below. I also don’t seem to know how to paste my code in a fancy window like other people
const markDown = document.getElementById("markdown-input");
const html = document.getElementById("html-output");
const preview = document.getElementById("preview")
function convertMarkdown(input) {
let output = input;
if(/\>(.*)/g.test(output)){
output = output.replace(/\>(.*)/g, `<blockquote>$1</blockquote>`)
}
if(/(?:^|\s)(#{1,3}).*/g.test(output)){
output = output.replace(/(?:^|\s)(#{1,3})\s(.+)/gm, (_, hash, text) => `<h${hash.length}>${text}</h${hash.length}>`)
};
if(/(?:__|\*\*)(.+)(?:__|\*\*)/g.test(output)){
output = output.replace(/(?:__|\*\*)(.+)(?:__|\*\*)/g, `<strong>$1</strong>`);
}
if(/(?:_|\*)(.+)(?:_|\*)/g.test(output)){
output = output.replace(/(?:_|\*)(.+)(?:_|\*)/g, `<em>$1</em>`);
}
if(/!\[(.+)\]\((.+)\)/g.test(output)){
output = output.replace(/!\[(.+)\]\((.+)\)/g, `<img src="$2" alt="$1">`);
}
if(/\[(.+)\]\((.+)\)/g.test(output)){
output = output.replace(/\[(.+)\]\((.+)\)/g, `<a href="$2">$1</a>`);
}
if(output !== input){
html.textContent = output;
preview.innerHTML = output;
console.log(output);
return output;
} else {
console.log(output);
return "";
}
}
markDown.addEventListener("input", () => convertMarkdown(markDown.value))