-
Notifications
You must be signed in to change notification settings - Fork 113
Open
Description
In the following lines of htmlparser.js, <a>-tag seems to be classified as a block element.
Pure-JavaScript-HTML5-Parser/htmlparser.js
Lines 92 to 96 in 3e8b2b1
| // Block Elements - HTML 5 | |
| var block = makeMap("a,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video"); | |
| // Inline Elements - HTML 5 | |
| var inline = makeMap("abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var"); |
But the w3c spec and this summary suggest it should be an inline element instead.
This causes an issue with parsing <a>-tag within an inline element, forcing the latter tag to close before the <a>-tag begins.
Minimal examples:
HTMLtoXML('<div>foo <span>bar</span> buz</div>')
// returns "<div>foo <span>bar</span> buz</div>"
HTMLtoXML('<span> hi <a href=\"https://www.w3schools.com\">Visit W3Schools.com!</a></span>')
//returns "<span> hi </span><a href=\"https://www.w3schools.com\">Visit W3Schools.com!</a>"
Metadata
Metadata
Assignees
Labels
No labels