Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

for all the lowercase complainers:

   document.querySelectorAll("p").forEach(p => p.textContent = p.textContent.replace(/(^\w)|([.?!]\s*\w)|( i'? )/g, m => m.toUpperCase()));


Or using CSS p:first-letter{ text-transform: capitalize;}:

  document.styleSheets[0].insertRule("p:first-letter{ text-transform: capitalize;}",document.styleSheets[0].cssRules.length);


That only works for paragraphs, not sentences.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: