Skip to content

Commit

Permalink
ekalinin#39 rock and roll aware
Browse files Browse the repository at this point in the history
Fix ekalinin#39

Use two apostrophes for the 'n' in rock ’n’ roll.
  • Loading branch information
mheiber committed May 6, 2017
1 parent 6bbb46f commit 7cc88d1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/typogr.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ module.exports = {
'&#8220;<a href="http://example.com">switched off</a>&#8221;.');
assert.eql( tp.smartypants('<a href="">markdown</a>\'s popularity is growing'),
'<a href="">markdown</a>&#8217;s popularity is growing');
assert.eql( tp.smartypants("<p>I love rock 'n' roll</p>"),
'<p>I love rock &#8217;n&#8217; roll</p>');
},
'typogrify': function(){
assert.eql( tp.typogrify(
Expand Down
4 changes: 4 additions & 0 deletions typogr.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@
}
} else {
t = token.txt;

// Special case rock ’n’ roll—use apostrophes
t = t.replace(/(rock )'n'( roll)/gi, '$1&#8217;n&#8217;$2');

// Remember last char of this token before processing
last_char = t.slice(-1);

Expand Down

0 comments on commit 7cc88d1

Please sign in to comment.