Skip to content

<a> incorrectly classified as block elements #13

Description

@kcf-jackson

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>"

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions