diff --git a/index.coffee b/index.coffee index 5020311..573bf94 100644 --- a/index.coffee +++ b/index.coffee @@ -259,6 +259,12 @@ module.exports = class Flatten caption = null title = null src = null + if tag.children.length is 1 and tag.children[0].name is 'img' and tag.children[0].attribs?.src + results.push + type: 'image' + html: @tagToHtml tag.children[0] + src: @normalizeUrl tag.children[0].attribs.src + return results for child in tag.children if child.name is 'h1' and not title title = '' diff --git a/spec/Flatten.coffee b/spec/Flatten.coffee index 53b7c43..e1786bc 100644 --- a/spec/Flatten.coffee +++ b/spec/Flatten.coffee @@ -681,7 +681,7 @@ describe 'Flatten', -> path: 'foo/bar.html' items: [ id: 'http://html5doctor.com/the-article-element/' - html: "

Apple

The apple is the pomaceous fruit of the apple tree...

Red Delicious

These bright red apples are the most common found in many supermarkets...

" + html: "

Apple

The apple is the pomaceous fruit of the apple tree...

Red Delicious

These bright red apples are the most common found in many supermarkets...

" ] expected = @@ -699,6 +699,10 @@ describe 'Flatten', -> title: 'Red Delicious' caption: 'These bright red apples are the most common found in many supermarkets...' src: 'http://www.theproducemom.com/wp-content/uploads/2012/01/red_delicious_jpg.jpg' + , + type: 'image' + html: "" + src: 'https://s3-us-west-2.amazonaws.com/the-grid-img/p/904a32ea9f56b9e7bf1b500e5e2e2217a090b225.jpg' ] ]