hyperx icon indicating copy to clipboard operation
hyperx copied to clipboard

Feature: allow custom optional closed tags

Open SilentCicero opened this issue 7 years ago • 5 comments

In react a custom component can be notated like this: <MyCustomComponent />, in hyperx you have to notate is like this <MyCustomComponent><MyCustomComponent>.

I would like to notate optionally closable, non-html tags that could or could not be closed at the end.

So I would register with hyperx these in opts, under optionallySelfClosing: []. If they are closed (i.e. ending with />) then they are treated as closed tags. If they are not (i.e. ending in >) then they have children and are not yet closed.

Another way would be to have a loose setting in opts. Where any tag, html or otherwise could be optional open or closed. However, this seems like more work to implement.

SilentCicero avatar Feb 24 '17 15:02 SilentCicero

This might be related to issue #34

slaskis avatar Feb 24 '17 22:02 slaskis

Perhaps this feature could take an array to explicitly enumerate options but also a function so that people can use conventions such as checking for the presence of a capital letter as is common in react land? I also think we could rework the parser so self-closing tags don't search for a closing element.

ghost avatar Mar 11 '17 04:03 ghost

@substack re-work the parser, and make the policy strict: if /> then closed. Dont allow <br> only <br />. I think this would be amazing.

You could then remove all this: 'area', 'base', 'basefont', 'bgsound', 'br', 'col', 'command', 'embed', 'frame', 'hr', 'img', 'input', 'isindex', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr', '!--', // SVG TAGS 'animate', 'animateTransform', 'circle', 'cursor', 'desc', 'ellipse', 'feBlend', 'feColorMatrix', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence', 'font-face-format', 'font-face-name', 'font-face-uri', 'glyph', 'glyphRef', 'hkern', 'image', 'line', 'missing-glyph', 'mpath', 'path', 'polygon', 'polyline', 'rect', 'set', 'stop', 'tref', 'use', 'view', 'vkern'

SilentCicero avatar Mar 14 '17 17:03 SilentCicero

@substack this would also speed up parsing times due to not having to test through this large string everytime.

SilentCicero avatar Mar 15 '17 22:03 SilentCicero

@substack how would I go about implementing this, any directions, I could do a branch and PR?

SilentCicero avatar Mar 20 '17 19:03 SilentCicero