Skip to content

Instantly share code, notes, and snippets.

@makzan
Created September 8, 2014 02:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save makzan/4e39b40bf758a1378b44 to your computer and use it in GitHub Desktop.
Save makzan/4e39b40bf758a1378b44 to your computer and use it in GitHub Desktop.
Orphans Fixer without jQuery
# Orphans Fixer
all_paragraphs = document.querySelectorAll('p, h1, h2, h3, li')
window.p = all_paragraphs[0]
reg = /\s([^\s<]{0,10})\s*$/
for p in all_paragraphs
p.innerHTML = p.innerHTML.replace reg, "&nbsp$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment