Re: Smart quotes?

Sherwood Botsford <[email protected]> Thu, 24 Mar 2016 21:18:08 -0600
Newsgroups gmane.comp.lang.perl.modules.template-toolkit
Message-ID <CAOX=2F9+0jL+515QYAxFyMp1sCBCNrO4KYiFRBgmGk43FptQVw@mail.gmail.com>
--===============3110102308101151694==
Content-Type: multipart/alternative; boundary=001a114082ee733d8e052ed705f4

--001a114082ee733d8e052ed705f4
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

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 t=
o
> replace quotes; something like this :
>
>
>
> sub replace_quotes {
>
>   my $text =3D shift;
>
>   $text =3D~ s/"\b/&laquo;/g;
>
>   $text =3D~ s/\b"/&raquo;/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 Botsford
> *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 the
> ttree script so that the html output has straight quotes replaced with
> typograper's quotes?
>
>
>
>
> Respectfully,
>
> Sherwood of Sherwood's Forests
>

--001a114082ee733d8e052ed705f4
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I was hoping for a little bit more comprehensive solution.=
=C2=A0 Even SmartyPants doesn&#39;t get it all correct.<div><br></div><div>=
To do it right:</div><div><br></div><div>A: =C2=A0Must be able to recognize=
d when inside of PRE and CODE tags.</div><div>B: =C2=A0Must not replace ins=
ide html tags. =C2=A0&lt;div class=3D\&amp;rdquot;foo\&amp;ldquot;&gt; is n=
ot a win.</div><div>C: Ideally recognises prefix situations: =C2=A0E.g. &#3=
9;Twas the night before Christmas, and =C2=A0&quot;Throw &#39;nother log on=
 the fire&quot;</div></div><div class=3D"gmail_extra"><br clear=3D"all"><di=
v><div class=3D"gmail_signature"><div dir=3D"ltr"><div><div dir=3D"ltr"><di=
v>Respectfully,<br><br>Sherwood of Sherwood&#39;s Forests<br><br></div></di=
v></div></div></div></div>
<br><div class=3D"gmail_quote">On 24 March 2016 at 03:53, Dami Laurent (PJ)=
 <span dir=3D"ltr">&lt;<a href=3D"mailto:laurent.dami-gCR5xK869Ejx/[email protected]" target=
=3D"_blank">laurent.dami-gCR5xK869Ejx/[email protected]</a>&gt;</span> wrote:<br><blockquote=
 class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc soli=
d;padding-left:1ex">





<div lang=3D"FR-CH" link=3D"blue" vlink=3D"purple">
<div>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ar=
ial&quot;,&quot;sans-serif&quot;;color:#1f497d">Hi,<u></u><u></u></span></p=
>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ar=
ial&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u>=C2=A0<u></u></span>=
</p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ar=
ial&quot;,&quot;sans-serif&quot;;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:&quot;Ar=
ial&quot;,&quot;sans-serif&quot;;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:&quot;Ar=
ial&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u>=C2=A0<u></u></span>=
</p>
<p class=3D"MsoNormal"><span lang=3D"DE-CH" style=3D"font-size:11.0pt;font-=
family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#1f497d">sub replace_=
quotes {<u></u><u></u></span></p>
<p class=3D"MsoNormal"><span lang=3D"DE-CH" style=3D"font-size:11.0pt;font-=
family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#1f497d">=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:&quot;Ar=
ial&quot;,&quot;sans-serif&quot;;color:#1f497d">=C2=A0 $text =3D~ s/&quot;\=
b/&amp;laquo;/g;<u></u><u></u></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ar=
ial&quot;,&quot;sans-serif&quot;;color:#1f497d">=C2=A0 $text =3D~
</span><span lang=3D"DE-CH" style=3D"font-size:11.0pt;font-family:&quot;Ari=
al&quot;,&quot;sans-serif&quot;;color:#1f497d">s/\b&quot;/&amp;raquo;/g;<u>=
</u><u></u></span></p>
<p class=3D"MsoNormal"><span lang=3D"DE-CH" style=3D"font-size:11.0pt;font-=
family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#1f497d">=C2=A0 retur=
n text;<u></u><u></u></span></p>
<p class=3D"MsoNormal"><span lang=3D"DE-CH" style=3D"font-size:11.0pt;font-=
family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#1f497d">}<u></u><u><=
/u></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ar=
ial&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u>=C2=A0<u></u></span>=
</p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ar=
ial&quot;,&quot;sans-serif&quot;;color:#1f497d">Hope this helps,<u></u><u><=
/u></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ar=
ial&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u>=C2=A0<u></u></span>=
</p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ar=
ial&quot;,&quot;sans-serif&quot;;color:#1f497d">Laurent Dami<u></u><u></u><=
/span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ar=
ial&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u>=C2=A0<u></u></span>=
</p>
<p class=3D"MsoNormal" style=3D"margin-left:35.4pt"><b><span lang=3D"FR" st=
yle=3D"font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quo=
t;">De=C2=A0:</span></b><span lang=3D"FR" style=3D"font-size:10.0pt;font-fa=
mily:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> <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=
 class=3D"">
<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&#39;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&#39;s Forests<u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</span></div>
</div>

</blockquote></div><br></div>

--001a114082ee733d8e052ed705f4--


--===============3110102308101151694==
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

--===============3110102308101151694==--