This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
const setContent = element => nodesArray => { | |
element.innerText = ""; | |
nodesArray.forEach(node => { | |
element.appendChild(node); | |
}); | |
}; | |
const parseHTML = text => new DOMParser().parseFromString(text, "text/html"); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Document</title> | |
<style> | |
body, html { | |
padding: 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Adapted nippet from here: https://rosettacode.org/wiki/Strip_control_codes_and_extended_characters_from_a_string#JavaScript | |
// Also remove non "<" chars in the beginning of the XML. | |
function stripGarbage (string) { | |
return string.split('').filter(function (character) { | |
const number = character.charCodeAt(0) | |
return 31 < number && 127 > number | |
}).join('').replace(/^[^<]*/, '') | |
} | |
// Snippet from here: http://stackoverflow.com/a/13240395/511923 |