Help - Search - Members - Calendar
Full Version: Curly Quotes
Movable Type Community Forum > Additional Resources > Plugin Development and Usage
photomatt
Here are the instructions

I'm looking for feedback, suggestions, comments, anything. I love MT but I don't run it anymore, only because I like playing with PHP over Perl. I also have the same regex in a php function you can see in this post.

Let me know if you put this on your blog, because it would give me a warm fuzzy feeling tongue.gif .
JokeofAllTrades
I've just added it to my blog. I've been meaning to do something like this for awhile, but just got around to it today. Thanks for the code!

However, I don't know if it's working (until today, I've been hard-coding the curly quotes, so they were already there). I haven't tested it with a new post because *ahem* I'm at work. When I rebuilt, I got the following errors:
CODE
MT::App::CMS=HASH(0x82727b8) Bareword found where operator expected at (eval 12) line 1, near "s/([^=])‘([^ >].*)’/$1‘$2’/gU"
MT::App::CMS=HASH(0x82727b8) syntax error at (eval 12) line 1, near "s/([^=])‘([^ >].*)’/$1‘$2’/gU"
MT::App::CMS=HASH(0x82727b8) Substitution replacement not terminated at (eval 13) line 1.
MT::App::CMS=HASH(0x82727b8) Bareword found where operator expected at (eval 14) line 1, near "s/"(.*)<\/p>/“$1/“$1/“$1/“$1/“$1/“$1/“$1/“$1/“$1/“$1/“$1/“$1/“$1/“$1/“$1/“$1/“$1/“$1/“$1/“$1

But, the pages are still intact...

Thanks again...
photomatt
Go ahead and send me a email at matt@mullenweg.com or message me on AIM at saxmatt02 and we'll work it out.
photomatt
Just to let everyone know, this has been updated and works perfectly now.

Check it out.
Outtacontext
Have added Curly Quotes and all is working *almost* ok. Some quotes and apostrophes are converting but some are not. I can't see any pattern to this.

I've written Matt about this and he's going to check it out. But I'm wondering if anyone else has encountered this issue.
kevin
You can also use this at the top of a template to convert curlies from, say, Microsoft Word to Web-ready curlies and em dashes:

CODE
<MTAddRegex>s|\x91|‘|g</MTAddRegex>
<MTAddRegex>s|\x92|’|g</MTAddRegex>
<MTAddRegex>s|\x93|“|g</MTAddRegex>
<MTAddRegex>s|\x94|”|g</MTAddRegex>
<MTAddRegex>s|\x96|—|g</MTAddRegex>
kadyellebee
Thanks again, Matt, for helping me with the popup codes info smile.gif  Works like a charm!! smile.gif

Kristine
nriethmann
Is this smart enough to determine whether a set of quotation marks lives in the body text or in a tag? If a guy were to put an image in one of his posts, this may cause problems. For example...

CODE
<p>Hello, I'm some cool "body text" in a post. <img src="filename.jpg" /></p>

Do the quotes in the src attribute get converted?
photomatt
It's smart! So it shouldn't eat the quotes in the img tag.

Kristine, I'm going to add the popup-fixer code to the script page later today, after I quadruple-check it. Another guy who has the exact same code as you is still having problems, so we'll see what's up.

[edit: i can't spel rite, sorry KDLB smile.gif]
kadyellebee
Matt,

Just in case this helps, here's the order that I have the curly quote stuff in my module that IS working smile.gif
CODE
<!--curly quotes-->
<MTAddRegex>s/(',)\s*('popup',)\s*/$1$2/gi</MTAddRegex>
<MTAddRegex>s|'([dmst])([ .,?!\)\/<])|’$1$2|gi</MTAddRegex>
<MTAddRegex>s|'([lrv])([el])([ .,?!\)\/<])|’$1$2$3|gi</MTAddRegex>
<MTAddRegex>s|([^=])(\s+)'([^ >])?(.*?)([^=])'(\s*)([^>&])|$1$2‘$3$4$5’$6$7|g</MTAddRegex>
<MTAddRegex>s|([^=])(\s+)"([^ >])?(.*?)([^=])"(\s*)([^>&])|$1$2“$3$4$5”$6$7|g</MTAddRegex>
<MTAddRegex>s|<p>[\s]"(.*?)</p>|<p>“$1</p>|g</MTAddRegex>


Kristine
shacker
So I'm in a situation where most of the posts going into a blog I manage originate in Word and are full of Word-style smart quotes. The smart quotes go into the database and are spit back out in HTML by MT as smart quotes, never being transformed to entities. Everything seems fine. So the question is, should I care? Is this a problem? The purist in me wants to do something about it. The practical me is having trouble seeing why this is a bad thing. Which browsers out there will choke on these characters? Is it more than a few percent?
shacker
Appending to my previous question, would appreciate if someone could explain this mystery:

- Paste out of Word and into MT, post.
- Curly quotes and em dashes appear fine.
- Copy out of the generated HTML page source code and into a new HTML doc - curly quotes and em dashes now refuse to render properly.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.