Skip to content

Commit

Permalink
[Experimental] Coalesce/parse nested inline tags
Browse files Browse the repository at this point in the history
The compiler should now handle things like:

    <time><span>**Foo**</span></time>
  • Loading branch information
Evan Jacobs committed Sep 16, 2016
1 parent 5645a27 commit 2a00f5a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ function coalesceInlineHTML(ast) {

// are there more html nodes directly after? if so, fold them into the current node
if (index < siblings.length - 1 && siblings[index + 1].type === 'html') {
// further folding is needed
// create a new coalescer context
coalescer(siblings[index + 1], index + 1, siblings);
}

let i = index + 1;
Expand Down
13 changes: 13 additions & 0 deletions index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,19 @@ describe('markdown-to-jsx', () => {
expect($element.children[0].children[0].textContent).toBe('Hello');
});

it('processes markdown within nested inline HTML', () => {
const element = render(converter('<time><span>**Hello**</span></time>'));
const $element = dom(element);

// inline elements are always wrapped in a paragraph context
expect($element.tagName).toBe('P');

expect($element.children[0].tagName).toBe('TIME');
expect($element.children[0].children[0].tagName).toBe('SPAN');
expect($element.children[0].children[0].children[0].tagName).toBe('STRONG');
expect($element.children[0].children[0].children[0].textContent).toBe('Hello');
});

it('processes attributes within inline HTML', () => {
const element = render(converter('<time data-foo="bar">Hello</time>'));
const $element = dom(element);
Expand Down

0 comments on commit 2a00f5a

Please sign in to comment.