Skip to content

Commit

Permalink
Ensure code spans put in emphasis work correctly
Browse files Browse the repository at this point in the history
When putting code span into simple or double emphasis, we've got an
unexpected output. This commit fix this problem simply removing an
ignore statement about back ticks in the find_emph_char function

Fix #135 and #190
  • Loading branch information
robin850 committed May 26, 2013
1 parent e94a07e commit 9137e7c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Changelog

* Ensure nested code spans put in emphasis work correctly *Robin Dupret*

## Version 2.3.0

* Add a `:disable_indented_code_blocks` option *Dmitriy Kiriyenko*
Expand Down
2 changes: 1 addition & 1 deletion ext/redcarpet/markdown.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ find_emph_char(uint8_t *data, size_t size, uint8_t c)
size_t i = 1;

while (i < size) {
while (i < size && data[i] != c && data[i] != '`' && data[i] != '[')
while (i < size && data[i] != c && data[i] != '[')
i++;

if (i == size)
Expand Down
23 changes: 23 additions & 0 deletions test/html_render_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,27 @@ def test_that_link_works_with_quotes
rd = render_with(@rndr[:escape_html], %([This'link"is](http://example.net/)))
assert_equal "<p><a href=\"http://example.net/\">This&#39;link&quot;is</a></p>\n", rd
end

def test_that_code_emphasis_work
markdown = <<-MD
This should be **`a bold codespan`**
However, this should be *`an emphasised codespan`*
* **`ABC`** or **`DEF`**
* Foo bar
MD

html = <<HTML
<p>This should be <strong><code>a bold codespan</code></strong>
However, this should be <em><code>an emphasised codespan</code></em></p>
<ul>
<li><strong><code>ABC</code></strong> or <strong><code>DEF</code></strong></li>
<li>Foo bar</li>
</ul>
HTML

output = render_with(Redcarpet::Render::HTML.new, markdown)
assert_equal html, output
end
end

0 comments on commit 9137e7c

Please sign in to comment.