minimize
Advanced tools
Comparing version 0.4.0 to 0.4.1
@@ -24,3 +24,5 @@ 'use strict'; | ||
, structural = /pre|textarea|code/ | ||
, interpunction = /[\.,!%;:\-\?]/; | ||
, interpunction = /[\.,!%;:\-\?]/ | ||
, start = new RegExp('^' + interpunction.source) | ||
, end = new RegExp(interpunction.source + '$'); | ||
@@ -74,3 +76,3 @@ /** | ||
return (this.isInline(element) && (flow.test(data) || interpunction.test(data)) | ||
return (this.isInline(element) && (flow.test(data) || end.test(data)) | ||
? ' <' | ||
@@ -141,3 +143,3 @@ : '<') + element.data + '>'; | ||
// Check if the text requires flowing based on last output and interpunction. | ||
if (flow.test(data) && !(new RegExp('^' + interpunction.source)).test(element)) { | ||
if (flow.test(data) && !start.test(element)) { | ||
element = ' ' + element; | ||
@@ -144,0 +146,0 @@ } |
{ | ||
"name": "minimize", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "Minimize HTML", | ||
@@ -5,0 +5,0 @@ "main": "./lib/minimize", |
@@ -117,3 +117,3 @@ 'use strict'; | ||
it('is inline and prepended by text', function () { | ||
expect(helpers.tag(html.inline), html.element, 'text').to.be.equal( | ||
expect(helpers.tag(html.inline, 'text')).to.be.equal( | ||
' <' + html.inline.data + '>' | ||
@@ -125,4 +125,12 @@ ); | ||
it('is inline and prepended by interpunction', function () { | ||
expect(helpers.tag(html.inline, 'text.')).to.be.equal( | ||
' <' + html.inline.data + '>' | ||
); | ||
expect(structure).to.be.calledOnce; | ||
}); | ||
it('is inline and prepended by closing tag', function () { | ||
expect(helpers.tag(html.inline), html.element, 'text</b>').to.be.equal( | ||
expect(helpers.tag(html.inline, 'text</b>')).to.be.equal( | ||
' <' + html.inline.data + '>' | ||
@@ -129,0 +137,0 @@ ); |
28691
736