Skip to content

<a> incorrectly classified as block elements #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
kcf-jackson opened this issue Apr 10, 2020 · 0 comments
Open

<a> incorrectly classified as block elements #13

kcf-jackson opened this issue Apr 10, 2020 · 0 comments

Comments

@kcf-jackson
Copy link

In the following lines of htmlparser.js, <a>-tag seems to be classified as a block element.

// 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>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant