hyntax icon indicating copy to clipboard operation
hyntax copied to clipboard

TreeConstructor.NodeContents.Tag.selfClosing is misleading

Open BlackGlory opened this issue 5 years ago • 4 comments

In the source code, this property actually represents void elements.

https://github.com/mykolaharmash/hyntax/blob/b09cd799498474ccf38da7f7545530062ee239ab/lib/tree-constructor-context-handlers/tag.js#L34-L50

Therefore, selfClosing of HTML tags like <div /> will always be false.

BlackGlory avatar Aug 24 '20 06:08 BlackGlory

Thanks, that is true, misleading indeed. There is a long-overdue issue with SVG support, it will introduce parsing of "real" self-closing tags. Then I'll refactor and change current self-closing tags to be void elements, and rename the property in AST.

mykolaharmash avatar Aug 24 '20 08:08 mykolaharmash

I meet the same problem, is there any way to parse the code correctly, when a tag appears in both selfclosing and non-self closing states? I expect the result that selfclosing attribute of the second one is true.

<div></div>
<div />

Anyway, thank you for providing such an excellent parser!!

shuerguo999 avatar May 15 '21 16:05 shuerguo999

Hey @shuerguo999, thank you!

Could you please explain your usecase? Are you parsing some extension of HTML syntax like JSX? Asking because <div /> is not part of HTML5 standard and is not a valid syntax.

mykolaharmash avatar May 17 '21 08:05 mykolaharmash

Yes,

is not part of HTML5 standard. But I hope hyntax can support it, I use it parsing many extension of HTML syntax like 'Mini apps'、'mustache'.... I didn't find other better parser!

shuerguo999 avatar May 17 '21 11:05 shuerguo999