UNPKG

bionical

Version:

bionic reading for your website in less than 1kb

21 lines (18 loc) 575 B
function bionical() { document .querySelectorAll('[data-bionic-parent="true"] p') .forEach((paragraph) => { const words = paragraph.textContent.split(" "); const modifiedContent = words .map((word) => { const halfLength = Math.ceil(word.length / 2); return `<span style="font-weight: bold;">${word.slice( 0, halfLength )}</span>${word.slice(halfLength)}`; }) .join(" "); paragraph.innerHTML = modifiedContent; }); } module.exports = bionical;