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

Fix #57 -- SmartyPants handling of single quotes. #200

Merged
merged 3 commits into from
May 5, 2013
Merged

Fix #57 -- SmartyPants handling of single quotes. #200

merged 3 commits into from
May 5, 2013

Conversation

mmorearty
Copy link
Contributor

git bisect indicates that the single quote bug was introduced in commit ad2c7fe. The problem is that by the time quotation marks are being converted, ' has already been changed into ', and the code to convert that into a smart quote is only looking for ', not &#39.

There was already code to handle the fact that " had been converted into ", but it appears that single-quotes were overlooked.

@mmorearty
Copy link
Contributor Author

Hang on please, there is a bug in this pull request that I need to fix...

E.g. if the original text is "test'test".
@mmorearty
Copy link
Contributor Author

Okay, it's good to go

@aprescott
Copy link

Your branch has a broken rake for me:

git clone https://github.com/mmorearty/redcarpet.git
cd redcarpet
git checkout patch-single-quotes
bundle install
rake
mkdir -p tmp/x86_64-linux/redcarpet/1.9.3
cd tmp/x86_64-linux/redcarpet/1.9.3
/home/adam/.rvm/rubies/ruby-1.9.3-p286/bin/ruby -I. ../../../../ext/redcarpet/extconf.rb
creating Makefile
cd -
cd tmp/x86_64-linux/redcarpet/1.9.3
make
compiling ../../../../ext/redcarpet/html_smartypants.c
../../../../ext/redcarpet/html_smartypants.c: In function ‘squote_len’:
../../../../ext/redcarpet/html_smartypants.c:94:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
../../../../ext/redcarpet/html_smartypants.c:94:2: note: use option -std=c99 or -std=gnu99 to compile your code
make: *** [html_smartypants.o] Error 1
rake aborted!
Command failed with status (2): [make...]
/home/adam/.rvm/gems/ruby-1.9.3-p286/gems/rake-compiler-0.8.1/lib/rake/extensiontask.rb:112:in `block (2 levels) in define_compile_tasks'
/home/adam/.rvm/gems/ruby-1.9.3-p286/gems/rake-compiler-0.8.1/lib/rake/extensiontask.rb:111:in `block in define_compile_tasks'
Tasks: TOP => default => test => test:unit => compile => compile:x86_64-linux => compile:redcarpet:x86_64-linux => copy:redcarpet:x86_64-linux:1.9.3 => tmp/x86_64-linux/redcarpet/1.9.3/redcarpet.so
(See full trace by running task with --trace)

@aprescott
Copy link

Same error when trying to install the built gem:

Building native extensions.  This could take a while...
ERROR:  Error installing redcarpet-2.2.2.gem:
    ERROR: Failed to build gem native extension.

        /home/adam/.rvm/rubies/ruby-1.9.3-p286/bin/ruby extconf.rb
creating Makefile

make
compiling buffer.c
compiling rc_render.c
compiling html.c
compiling stack.c
compiling markdown.c
compiling rc_markdown.c
compiling autolink.c
compiling html_smartypants.c
html_smartypants.c: In function ‘squote_len’:
html_smartypants.c:94:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
html_smartypants.c:94:2: note: use option -std=c99 or -std=gnu99 to compile your code
make: *** [html_smartypants.o] Error 1


Gem files will remain installed in /home/adam/.rvm/gems/ruby-1.9.3-p286/gems/redcarpet-2.2.2 for inspection.
Results logged to /home/adam/.rvm/gems/ruby-1.9.3-p286/gems/redcarpet-2.2.2/ext/redcarpet/gem_make.out

@mmorearty
Copy link
Contributor Author

That's weird; I have no idea why I didn't hit that compile error sooner. Sorry; fixed.

@aprescott
Copy link

Looks good. I built a 2.2.2.quotes version of the gem and installed it, looks like it solves the bug, at least, as well as handling ' even in HTML:

Redcarpet::Markdown.new(Redcarpet::Render::SmartyHTML).render("<p>testing's &#39;quote&#39;s and <code>code's code</code></p>")
#=> "<p>testing&rsquo;s &lsquo;quote&rsquo;s and <code>code's code</code></p>\n"

@jamieholst
Copy link

+1

@robin850
Copy link
Collaborator

robin850 commented May 4, 2013

@mmorearty : Could you rebase your commit please? 😄 I can't merge it automatically. If you want me to do it manually, let me know. It looks good to me. Thanks a lot!

robin850 added a commit that referenced this pull request May 5, 2013
Conflicts:
	ext/redcarpet/buffer.h
@robin850 robin850 merged commit 0e97ce6 into vmg:master May 5, 2013
@robin850
Copy link
Collaborator

robin850 commented May 5, 2013

@mmorearty : Sorry it was a merge conflict, your commits were correctly squashed ; I allow myself to merge it locally. Thanks a lot for this contribution!

@mmorearty
Copy link
Contributor Author

Great, thanks @robin850 !

@mmorearty mmorearty deleted the patch-single-quotes branch May 5, 2013 18:00
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

Successfully merging this pull request may close these issues.

5 participants