$('p.code').each(function (i, c) { var code = $(c).find('tt.codetext').text().replace(/\u00a0/g,' ').replace(/\s+$/,''); var dl = $(c).find('span.embed-code-dl'); var pre = $( '
'
		+ $('
').text(code).html() + '
' ); var footer = $('
'); if (dl.html()) footer.find('small').append(dl.html()); $(c).after(footer); $(c).replaceWith(pre); });