require 'spec_helper' require 'html_prettify' describe HtmlPrettify do def t(source, expected) expect(HtmlPrettify.render(source)).to eq(expected) end it 'correctly prettifies html' do t "

All's well!

", "

All’s well!

" t "

Eatin' Lunch'.

", "

Eatin’ Lunch’.

" t "

a 1/4. is a fraction but not 1/4/2000

", "

a ¼. is a fraction but not 1/4/2000

" t "

Well that'll be the day

", "

Well that’ll be the day

" t %(

"Quoted text"

), %(

“Quoted text”

) t "

I've been meaning to tell you ..

", "

I’ve been meaning to tell you ..

" t "

single `backticks` in HTML should be preserved

", "

single `backticks` in HTML should be preserved

" t "

double hyphen -- ndash --- mdash

", "

double hyphen – ndash — mdash

" t "a long time ago...", "a long time ago…" t "is 'this a mistake'?", "is ‘this a mistake’?" t ERB::Util.html_escape("'that went well'"), "‘that went well’" t '"that went well"', "“that went well”" t ERB::Util.html_escape('"that went well"'), "“that went well”" t 'src="test.png"> yay', "src=“test.png”> yay" t ERB::Util.html_escape(' yay'), "<img src=“test.png”> yay" end end