Skip to content
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

Self-closing tags for <option> and <optgroup> #525

Closed
FeBe95 opened this issue Jun 1, 2019 · 1 comment · Fixed by #527
Closed

Self-closing tags for <option> and <optgroup> #525

FeBe95 opened this issue Jun 1, 2019 · 1 comment · Fixed by #527

Comments

@FeBe95
Copy link

FeBe95 commented Jun 1, 2019

Description

Self-closing tags for <option> and <optgroup> are marked as invalid although they are valid under specific circumstances. Using them like this breaks the bracket highlighting of the remaining code as they are all marked as invalid from this point on.

HTML 5.0 specifications:
https://www.w3.org/TR/html50/forms.html#the-option-element
https://www.w3.org/TR/html50/forms.html#the-optgroup-element

An option element's end tag may be omitted if the optgroup element is immediately followed by another optgroup element, or if there is no more content in the parent element.

Support Info

  • ST ver.: 3207
  • Platform: windows
  • Arch: x64
  • Plugin ver.: 2.27.6
  • Install via PC: True
  • mdpopups ver.: 3.4.0
  • backrefs ver.: 3.5
  • markdown ver.: 2.6.11
  • pygments ver.: 2.1a0
  • jinja2 ver.: 2.8

Steps to Reproduce Issue

example code:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="initial-scale=1, user-scalable=no">
        <title>Test</title>
    </head>
    <body>
        <input type="text" list="names">
        <datalist id="names">
            <option value="Peter">
            <option value="Lucy">
            <option value="Tim">
            <option value="Paul">
            <option value="Felix">
        </datalist>
        
        <select>
          <optgroup label="Group 1">
          <optgroup label="Group 2">
            <option>Option 2.1</option>
            <option>Option 2.2</option>
          </optgroup>
          <optgroup label="Group 3" disabled>
            <option>Option 3.1</option>
            <option>Option 3.2</option>
            <option>Option 3.3</option>
          </optgroup>
        </select>
    </body>
</html>
@facelessuser
Copy link
Owner

facelessuser commented Jun 1, 2019

Yeah, we were missing optgroup, but option was there, we just had a typo that made the name plural.

We don't parse it with HTML5 logic per se, we just have a list of element names that if we can't find a match, we will just assume they are okay despite not having a closing.

If you edit bh_tags.sublime-settings, you can get the desired behavior:

diff --git a/bh_tag.sublime-settings b/bh_tag.sublime-settings
index ea40ac4..89a3b70 100644
--- a/bh_tag.sublime-settings
+++ b/bh_tag.sublime-settings
@@ -69,8 +69,8 @@
     "optional_tag_patterns": {
         "xml": null,
         "xhtml": null,
-        "html": "colgroup|dd|dt|li|options|p|td|tfoot|th|thead|tr",
-        "cfml": "cf.+|colgroup|dd|dt|li|options|p|td|tfoot|th|thead|tr"
+        "html": "colgroup|dd|dt|li|option|optgroup|p|td|tfoot|th|thead|tr",
+        "cfml": "cf.+|colgroup|dd|dt|li|option|optgroup|p|td|tfoot|th|thead|tr"
     },

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

Successfully merging a pull request may close this issue.

2 participants