wrap naked inline html elements

This commit is contained in:
Christopher Jeffrey 2012-01-14 03:39:32 -06:00
parent 5d83d1e375
commit 8bc19d831d

View File

@ -35,9 +35,18 @@ block.list = (function() {
block.html = (function() { block.html = (function() {
var html = block.html.source; var html = block.html.source;
// The real markdown checks for block elements.
// It's better to check for non-inline elements.
// Unknown elements will then be treated as block elements.
var closed = '<(?!(?:'
+ 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code'
+ '|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo'
+ '|span|br|wbr|ins|del|img)\\b)'
+ '(\\w+)[^\\0]+?</\\1>';
html = html html = html
.replace('comment', /<!--[^\0]*?-->/.source) .replace('comment', /<!--[^\0]*?-->/.source)
.replace('closed', /<(\w+)[^\0]+?<\/\1>/.source) .replace('closed', closed)
.replace('closing', /<\w+(?!:\/|@)\b(?:"[^"]*"|'[^']*'|[^>])*>/.source); .replace('closing', /<\w+(?!:\/|@)\b(?:"[^"]*"|'[^']*'|[^>])*>/.source);
return new RegExp(html); return new RegExp(html);