Skip to content

Commit

Permalink
Fix rendering of inline code tags. (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
sapegin authored and Evan Jacobs committed Sep 25, 2016
1 parent cd8068b commit 4249c15
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ export default function markdownToJSX(markdown, {overrides = {}} = {}) {

const key = index || '0';

if (ast.type === 'code') {
if (ast.type === 'code' && ast.value) {
return (
<pre key={key}>
<code className={`lang-${ast.lang}`}>
Expand Down
10 changes: 10 additions & 0 deletions index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,16 @@ describe('markdown-to-jsx', () => {
expect($element.children[0].tagName).toBe('STRONG');
expect($element.children[0].textContent).toBe('Hello');
});

it('renders inline <code> tags', () => {
const element = render(converter('Text and <code>**code**</code>'));
const $element = dom(element);

expect($element.tagName).toBe('P');
expect($element.children[0].tagName).toBe('CODE');
expect($element.children[0].children[0].tagName).toBe('STRONG');
expect($element.children[0].children[0].textContent).toBe('code');
});
});

describe('horizontal rules', () => {
Expand Down

0 comments on commit 4249c15

Please sign in to comment.