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);
Записывать эти данные в БД я не могу.
<div class="btn" id="dbut" data-path="http://lorempixel.com/400/200/cats/">Download</div>
function downloadFile(url){
var link = document.createElement('a');
link.href = url;
link.target="_blank";
link.download='';
var event = document.createEvent("MouseEvents");
event.initMouseEvent("click");
link.dispatchEvent(event);
}
var but = document.getElementById('dbut')
but.addEventListener('click', function(){
downloadFile(but.getAttribute('data-path'));
})
const escapeStringRegexp = require('escape-string-regexp');
const pattern = '.js';
const reg = new RegExp('(.*'+escapeStringRegexp(pattern)+'$)', 'i')