Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smarty filter doesn't convert straight single quote into curly single quote #57

Closed
steverandy opened this issue Sep 13, 2011 · 9 comments

Comments

@steverandy
Copy link

In the release of b5, the Smarty filter doesn't convert straight single quote into curly single quote.

It was working properly in b4.

@codyrobbins
Copy link
Contributor

I’m seeing the same thing. When using Redcarpet::Render::SmartyPants in a standalone capacity it correctly handles single quotes, replacing them with ’. However, when mixing in a subclass of Redcarpet::Render::HTML it simply replaces them with '. Double quotes, en and em dashes, etc. are all properly replaced, but not single quotes.

The following minimal test case

class TestRenderer < Redcarpet::Render::HTML
  include(Redcarpet::Render::SmartyPants)
end

Redcarpet::Markdown.new(TestRenderer).render(%q(This "works" but this doesn't.))

for me produces

"<p>This &ldquo;works&rdquo; but this doesn&#39;t.</p>\n"

The following

Redcarpet::Render::SmartyPants.render(%q(This "works" but this doesn't.))

however correctly produces

"This &ldquo;works&rdquo; but this doesn&rsquo;t."

I cursorily tried to track down the problem but don’t immediately see where the &#39; is coming from.

@steverandy
Copy link
Author

I use this as a temporary fix.

markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML)
html = markdown.render content
html.gsub!("&#39;", "'")
html = Redcarpet::Render::SmartyPants.render html

@telemachus
Copy link

This doesn't seem to have been fixed for the 2.0.0 release. Or am I mistaken? (I'm curious because I want to update nanoc's Redcarpet support, and I want to make sure that SmartyPants rendering still works.)

@codyrobbins
Copy link
Contributor

Yup, it’s still broken for me in 2.0.0.

@dpk
Copy link

dpk commented Oct 10, 2012

This is still an issue. Is there any plan to fix it or is it now Expected Behaviour™?

@puyo
Copy link

puyo commented Nov 16, 2012

+1 vote to fix this

@puyo
Copy link

puyo commented Nov 16, 2012

My workaround was to completely write my own SmartyPants replacement set of gsubs, which are less smart because they rely on me using backtick characters like LaTeX/Markdown, but I think I prefer it that way, since AFAIK, there isn't actually a way to programmatically predict all the crazy ways English can use curly quotes, and I was having specific problems, like the curly quote being the wrong way around when abbreviating the front of a word, like 'round instead of around.

https:/puyo/poetry.gregorymcintyre.com/blob/master/lib/ensmarten.rb

@aprescott
Copy link

+1 to fixing this. @vmg, any news on this / #53 / #66?

The temporary fix above isn't great for me, since there's a custom renderer. @mmorearty seems to have added a possible fix with his referencing commit.

Just to repeat @steverandy:

Redcarpet::Markdown.new(Redcarpet::Render::SmartyHTML).render(%q{This "works" but this doesn't"})
# => "<p>This &ldquo;works&rdquo; but this doesn&#39;t&quot;</p>\n" 
#
# note the &#39;

And yet, using SmartyPants.render does work as expected, which is counterintuitive:

Redcarpet::Render::SmartyPants.render(%q{This "works" but this doesn't"})
# => "This &ldquo;works&rdquo; but this doesn&rsquo;t&quot;" 
#
# note the &rsquo; where &#39; was above

I'd like to see both behaving the way SmartyPants.render does, since that's the correct output.

@aprescott
Copy link

The fix seems to be in #200 as a pull request.

aprescott added a commit to aprescott/serif that referenced this issue Mar 14, 2013
This is needed because of a bug in vmg/redcarpet#57. There is a test
assertion in test_helper to verify that this is actually necessary, and
the condition means it will automatically turn off should redcarpet have
this bug fixed for the user.
tjg pushed a commit to tjg/redcarpet that referenced this issue Oct 21, 2013
Add article on Running a Clojure User Group
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants