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

Projects
None yet
6 participants
@steverandy

steverandy commented Sep 13, 2011

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

This comment has been minimized.

Contributor

codyrobbins commented Sep 22, 2011

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

This comment has been minimized.

steverandy commented Oct 22, 2011

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

This comment has been minimized.

telemachus commented Dec 6, 2011

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

This comment has been minimized.

Contributor

codyrobbins commented Dec 6, 2011

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

@dpk

This comment has been minimized.

dpk commented Oct 10, 2012

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

@puyo

This comment has been minimized.

puyo commented Nov 16, 2012

+1 vote to fix this

@puyo

This comment has been minimized.

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://github.com/puyo/poetry.gregorymcintyre.com/blob/master/lib/ensmarten.rb

@aprescott

This comment has been minimized.

aprescott commented Mar 3, 2013

+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

This comment has been minimized.

aprescott commented Mar 3, 2013

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

Fix lack of single curly quotes in 'markdown' filter.
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.

@robin850 robin850 closed this in d949cbd May 5, 2013

tjg pushed a commit to tjg/redcarpet that referenced this issue Oct 21, 2013

Michael Klishin
Merge pull request vmg#57 from puredanger/master
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