var cleanParser = new DOMParser();
function parse(text) {
return Array.prototype.map.call(cleanParser.parseFromString(text, 'text/html').body.children, function(e){return e.innerHTML});
}
var codes = parse("<code>alert('hello');</code><code>console.log('test');</code>");
console.log(codes);