Skip to content

Commit f78eb86

Browse files
author
Jan Jedrychowski
committed
Multiple pairs of single quotes fix
1 parent 4f3a899 commit f78eb86

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
* Multiple single quote pairs are parsed correctly.
4+
5+
Fix issue [#549](https://github.com/vmg/redcarpet/issues/549).
6+
37
* Table headers don't require a minimum of three dashes anymore; a
48
single one can be used for each row.
59

ext/redcarpet/html_smartypants.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ smartypants_squote(struct buf *ob, struct smartypants_data *smrt, uint8_t previo
151151
return next_squote_len;
152152
}
153153

154+
if (smartypants_quotes(ob, previous_char, size > 0 ? text[1] : 0, 's', &smrt->in_squote))
155+
return 0;
156+
154157
// trailing single quotes: students', tryin'
155158
if (word_boundary(t1)) {
156159
BUFPUTSL(ob, "’");
@@ -178,9 +181,6 @@ smartypants_squote(struct buf *ob, struct smartypants_data *smrt, uint8_t previo
178181
}
179182
}
180183

181-
if (smartypants_quotes(ob, previous_char, size > 0 ? text[1] : 0, 's', &smrt->in_squote))
182-
return 0;
183-
184184
bufput(ob, squote_text, squote_size);
185185
return 0;
186186
}

test/smarty_pants_test.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,9 @@ def test_that_is_not_confused_by_fractions
5050
rd = @pants.render('I am 1/4... of the way to 1/4/2000')
5151
assert_equal "I am ¼… of the way to 1/4/2000", rd
5252
end
53+
54+
def test_that_smart_converts_multiple_single_quotes
55+
rd = @pants.render(%(<p>'First' and 'second' and 'third'</p>))
56+
assert_equal %(<p>&lsquo;First&rsquo; and &lsquo;second&rsquo; and &lsquo;third&rsquo;</p>), rd
57+
end
5358
end

0 commit comments

Comments
 (0)