JSFiddle - React, Tailwind, and code Playground

JavaScript

var a = "once upon a time ^COMMA there was a horse ^PERIOD that horse cost me $50 ^PERIOD ^OPENQUOTE eat your stupid oats ^COMMA already ^BANG ^CLOSEQUOTE I told the horse ^PERIOD the horse neighed back ^OPENQUOTE no ^CLOSEQUOTE and died ^PERIOD I always hated that stupid horse ^DASH his name was Franklin ^HYPHEN James the III ^PERIOD I decided to go and buy a new animal ^EMDASH a cow ^EMDASH named Franklin ^HYPHEN James ^SEMICOLON however ^COMMA this time he was the first in his line, so his full name was simply Franklin ^HYPHEN James ^PERIOD That cow sucked ^PERIOD I wish I could have the talking horse named Ed ^PERIOD One time, I went to a circus and they had a banner that said ^COMMA ^OPENQUOTE COME SEE ED ^COLON THE TALKING HORSE ^BANG ^CLOSEQUOTE but I had no money so I did not get to see him ^PERIOD THE END ^PERIOD"

alert(function(z){R="replace",C="charAt",U="toUpperCase";return z[R](/\^((COMMA)|(SEMICOLON)|(COLON)|(PERIOD)|(BANG)|(DASH)|(HYPHEN)|(EMDASH)|(OPENQUOTE)|(CLOSEQUOTE))/g,((m,_,a,b,c,d,e,f,g,h,i,j)=>a?",":b?";":c?":":d?".":e?"!":f?"-":g?"-h-":h?"-e-":i?' "':'" '))[R](/\s+((\.)|(\!)|(\,)|(\;)|(\:)|(\-\h\-\s+)|(\-\e\-\s+))/g,((xx,__,k,l,m,n,o,p,q)=>k?".":l?"!":m?",":n?";":o?":":p?"-":"--"))[R](/[^!,"'.]\"\s/g,'"')[R](/.+?[\.\?\!](\s+|$)/g,function(r){return r[C](0)[U]()+r.substr(1)})[R](/\"[a-z]/g,function(s){return s[C](0)+ s[C](1)[U]()})}(a))