UNPKG

@reason.co/docugen

Version:

`npm i docugen` (private npm install for now)

40 lines (34 loc) 1.16 kB
<script type="text/javascript"> window.addEventListener('load', function() { document.querySelectorAll('img').forEach(i => { if(i.getAttribute('alt') && !i.getAttribute('parsed')){ let newNode = document.createElement('span'); newNode.className = 'img_caption' newNode.innerText = i.getAttribute('alt'); i.after(newNode); i.setAttribute('parsed','true') } }) let bqPara = document.querySelectorAll('blockquote p'); let tagregex = /{.(.*?)\}/g; bqPara.forEach(bqp => { let tag = bqp.innerText.match(tagregex); if(tag && tag.length){ bqp.innerText = bqp.innerText.replace(tagregex,''); let parentClassName = tag[0].substring(2,tag[0].length-1); bqp.parentElement.classList.add(parentClassName); } }) let documentLinks = document.querySelectorAll('a'); documentLinks.forEach(alink => { if( (alink.innerText.trim() !== alink.getAttribute('href')) && !alink.classList.contains('linked') ) { alink.innerHTML += '<span class="mdd-linked"> [' + alink.getAttribute('href') + ']</span>'; alink.classList.add('linked'); } }) }) </script>