Re: Smart quotes?
Bill Ward <[email protected]> Fri, 25 Mar 2016 01:10:18 -0700
| Newsgroups | gmane.comp.lang.perl.modules.template-toolkit |
|---|---|
| Message-ID | <CAKGT8WqGjS0LvjD5X7U7XBfJYgzbSujVoo83g0AAxTu1e9E_xA@mail.gmail.com> |
--===============1375354853016495409== Content-Type: multipart/alternative; boundary=001a11488af651c45e052edb1a04 --001a11488af651c45e052edb1a04 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Wordpress does a pretty good job, though it's written in PHP. Maybe one could port that part of their code to Perl and turn it into a plugin. On Thu, Mar 24, 2016 at 8:18 PM, Sherwood Botsford <[email protected]> wrote: > I was hoping for a little bit more comprehensive solution. Even > SmartyPants doesn't get it all correct. > > To do it right: > > A: Must be able to recognized when inside of PRE and CODE tags. > B: Must not replace inside html tags. <div class=3D\&rdquot;foo\&ldquot= ;> > is not a win. > C: Ideally recognises prefix situations: E.g. 'Twas the night before > Christmas, and "Throw 'nother log on the fire" > > Respectfully, > > Sherwood of Sherwood's Forests > > > On 24 March 2016 at 03:53, Dami Laurent (PJ) <laurent.dami-gCR5xK869Ejx/[email protected]> > wrote: > >> Hi, >> >> >> >> I guess you could define a custom filter and then invoke the FILTER >> directive wherever you need it. >> >> The body of the filter could use regular expressions on word boundaries >> to replace quotes; something like this : >> >> >> >> sub replace_quotes { >> >> my $text =3D shift; >> >> $text =3D~ s/"\b/«/g; >> >> $text =3D~ s/\b"/»/g; >> >> return text; >> >> } >> >> >> >> Hope this helps, >> >> >> >> Laurent Dami >> >> >> >> *De :* templates-bounces-MnLy+PD7ppGDO3lXZvfOKmD2FQJk+8+b@public.gmane.org [mailto: >> templates-bounces-MnLy+PD7ppGDO3lXZvfOKmD2FQJk+8+b@public.gmane.org] *De la part de* Sherwood Botsfor= d >> *Envoy=C3=A9 :* mercredi 23 mars 2016 02:39 >> *=C3=80 :* [email protected] >> *Objet :* [Templates] Smart quotes? >> >> >> >> >> >> Anyone have a recipe for adding smartypants or equivalent script into th= e >> ttree script so that the html output has straight quotes replaced with >> typograper's quotes? >> >> >> >> >> Respectfully, >> >> Sherwood of Sherwood's Forests >> > > > _______________________________________________ > templates mailing list > [email protected] > http://mail.template-toolkit.org/mailman/listinfo/templates > > --=20 Check out my LEGO blog at brickpile.com <http://www.brickpile.com/> Follow/friend me: Facebook <http://facebook.com/billward> =E2=80=A2 Flickr <http://flickr.com/photos/billward/> =E2=80=A2 Twitter <http://twitter.com/williamward> =E2=80=A2 LinkedIn <http://www.linkedin.com/pub/william-ward/63/393/985/> =E2=80=A2 Goodreads <https://www.goodreads.com/user/show/2554312-bill-ward> --001a11488af651c45e052edb1a04 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Wordpress does a pretty good job, though it's written = in PHP. Maybe one could port that part of their code to Perl and turn it in= to a plugin.<br></div><div class=3D"gmail_extra"><br><div class=3D"gmail_qu= ote">On Thu, Mar 24, 2016 at 8:18 PM, Sherwood Botsford <span dir=3D"ltr">&= lt;<a href=3D"mailto:[email protected]" target=3D"_blank">sgbotsford@gma= il.com</a>></span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"= margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"= ltr">I was hoping for a little bit more comprehensive solution.=C2=A0 Even = SmartyPants doesn't get it all correct.<div><br></div><div>To do it rig= ht:</div><div><br></div><div>A: =C2=A0Must be able to recognized when insid= e of PRE and CODE tags.</div><div>B: =C2=A0Must not replace inside html tag= s. =C2=A0<div class=3D\&rdquot;foo\&ldquot;> is not a win.</d= iv><div>C: Ideally recognises prefix situations: =C2=A0E.g. 'Twas the n= ight before Christmas, and =C2=A0"Throw 'nother log on the fire&qu= ot;</div></div><div class=3D"gmail_extra"><span class=3D""><br clear=3D"all= "><div><div><div dir=3D"ltr"><div><div dir=3D"ltr"><div>Respectfully,<br><b= r>Sherwood of Sherwood's Forests<br><br></div></div></div></div></div><= /div> <br></span><div><div class=3D"h5"><div class=3D"gmail_quote">On 24 March 20= 16 at 03:53, Dami Laurent (PJ) <span dir=3D"ltr"><<a href=3D"mailto:laur= ent.dami-gCR5xK869Ejx/[email protected]" target=3D"_blank">laurent.dami-gCR5xK869Ejx/[email protected]</a>>= ;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 = .8ex;border-left:1px #ccc solid;padding-left:1ex"> <div link=3D"blue" vlink=3D"purple" lang=3D"FR-CH"> <div> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ar= ial","sans-serif";color:#1f497d">Hi,<u></u><u></u></span></p= > <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ar= ial","sans-serif";color:#1f497d"><u></u>=C2=A0<u></u></span>= </p> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ar= ial","sans-serif";color:#1f497d">I guess you could define a = custom filter and then invoke the FILTER directive wherever you need it. <u></u><u></u></span></p> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ar= ial","sans-serif";color:#1f497d">The body of the filter coul= d use regular expressions on word boundaries to replace quotes; something l= ike this :<u></u><u></u></span></p> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ar= ial","sans-serif";color:#1f497d"><u></u>=C2=A0<u></u></span>= </p> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ar= ial","sans-serif";color:#1f497d" lang=3D"DE-CH">sub replace_= quotes {<u></u><u></u></span></p> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ar= ial","sans-serif";color:#1f497d" lang=3D"DE-CH">=C2=A0 my $t= ext =3D shift;<u></u><u></u></span></p> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ar= ial","sans-serif";color:#1f497d">=C2=A0 $text =3D~ s/"\= b/&laquo;/g;<u></u><u></u></span></p> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ar= ial","sans-serif";color:#1f497d">=C2=A0 $text =3D~ </span><span style=3D"font-size:11.0pt;font-family:"Arial","= sans-serif";color:#1f497d" lang=3D"DE-CH">s/\b"/&raquo;/g;<u>= </u><u></u></span></p> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ar= ial","sans-serif";color:#1f497d" lang=3D"DE-CH">=C2=A0 retur= n text;<u></u><u></u></span></p> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ar= ial","sans-serif";color:#1f497d" lang=3D"DE-CH">}<u></u><u><= /u></span></p> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ar= ial","sans-serif";color:#1f497d"><u></u>=C2=A0<u></u></span>= </p> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ar= ial","sans-serif";color:#1f497d">Hope this helps,<u></u><u><= /u></span></p> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ar= ial","sans-serif";color:#1f497d"><u></u>=C2=A0<u></u></span>= </p> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ar= ial","sans-serif";color:#1f497d">Laurent Dami<u></u><u></u><= /span></p> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ar= ial","sans-serif";color:#1f497d"><u></u>=C2=A0<u></u></span>= </p> <p class=3D"MsoNormal" style=3D"margin-left:35.4pt"><b><span style=3D"font-= size:10.0pt;font-family:"Tahoma","sans-serif"" lang=3D"= FR">De=C2=A0:</span></b><span style=3D"font-size:10.0pt;font-family:"T= ahoma","sans-serif"" lang=3D"FR"> <a href=3D"mailto:template= [email protected]" target=3D"_blank">templates-bounces@templat= e-toolkit.org</a> [mailto:<a href=3D"mailto:templates-bounces@template-tool= kit.org" target=3D"_blank">templates-bounces-MnLy+PD7ppGDO3lXZvfOKmD2FQJk+8+b@public.gmane.org</a>] <b>De la part de</b> Sherwood Botsford<br> <b>Envoy=C3=A9=C2=A0:</b> mercredi 23 mars 2016 02:39<br> <b>=C3=80=C2=A0:</b> <a href=3D"mailto:[email protected]" targ= et=3D"_blank">[email protected]</a><br> <b>Objet=C2=A0:</b> [Templates] Smart quotes?<u></u><u></u></span></p><span= > <p class=3D"MsoNormal" style=3D"margin-left:35.4pt"><u></u>=C2=A0<u></u></p= > <div> <div> <p class=3D"MsoNormal" style=3D"margin-left:35.4pt"><u></u>=C2=A0<u></u></p= > </div> <div> <p class=3D"MsoNormal" style=3D"margin-left:35.4pt">Anyone have a recipe fo= r adding smartypants or equivalent script into the ttree script so that the= html output has straight quotes replaced with typograper's quotes?<u><= /u><u></u></p> </div> <div> <p class=3D"MsoNormal" style=3D"margin-left:35.4pt"><u></u>=C2=A0<u></u></p= > </div> <p class=3D"MsoNormal" style=3D"margin-left:35.4pt"><br clear=3D"all"> <u></u><u></u></p> <div> <div> <div> <div> <div> <div> <p class=3D"MsoNormal" style=3D"margin-right:0cm;margin-bottom:12.0pt;margi= n-left:35.4pt"> Respectfully,<br> <br> Sherwood of Sherwood's Forests<u></u><u></u></p> </div> </div> </div> </div> </div> </div> </div> </span></div> </div> </blockquote></div><br></div></div></div> <br>_______________________________________________<br> templates mailing list<br> <a href=3D"mailto:[email protected]">templates@template-toolki= t.org</a><br> <a href=3D"http://mail.template-toolkit.org/mailman/listinfo/templates" rel= =3D"noreferrer" target=3D"_blank">http://mail.template-toolkit.org/mailman/= listinfo/templates</a><br> <br></blockquote></div><br><br clear=3D"all"><br>-- <br><div class=3D"gmail= _signature"><div dir=3D"ltr"><div><div dir=3D"ltr"><div><div dir=3D"ltr"><d= iv><div dir=3D"ltr"><div><div dir=3D"ltr"><div><div dir=3D"ltr">Check out m= y LEGO blog at <a href=3D"http://www.brickpile.com/" target=3D"_blank">bric= kpile.com</a><br>Follow/friend me: <a href=3D"http://facebook.com/billward"= target=3D"_blank">Facebook</a> =E2=80=A2 <a href=3D"http://flickr.com/phot= os/billward/" target=3D"_blank">Flickr</a> =E2=80=A2 <a href=3D"http://twit= ter.com/williamward" target=3D"_blank">Twitter</a> =E2=80=A2 <a href=3D"htt= p://www.linkedin.com/pub/william-ward/63/393/985/" target=3D"_blank">Linked= In</a><span> =E2=80=A2 </span><a href=3D"https://www.goodreads.com/user/sho= w/2554312-bill-ward" target=3D"_blank">Goodreads</a><br></div></div></div><= /div></div></div></div></div></div></div></div></div> </div> --001a11488af651c45e052edb1a04-- --===============1375354853016495409== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ templates mailing list [email protected] http://mail.template-toolkit.org/mailman/listinfo/templates --===============1375354853016495409==--