Skip to content
This repository has been archived by the owner on Mar 28, 2019. It is now read-only.

Autoclose tags #89

Closed
wants to merge 2 commits into from
Closed

Autoclose tags #89

wants to merge 2 commits into from

Conversation

Pomax
Copy link
Contributor

@Pomax Pomax commented Sep 27, 2017

Only took years, but this should close #66 by introducing a new error, MISMATCHED_CLOSE_TAG_DUE_TO_EARLIER_AUTO_CLOSING, which reports a mismatch between "the code" and "the DOM" when it comes to code like:

<body><p><h1>lol</h1></h2></p></body>

This will generate an error like:

{
  "type": "MISMATCHED_CLOSE_TAG_DUE_TO_EARLIER_AUTO_CLOSING",
  "openTag": {
    "start": 9,
    "end": 12
  },
  "closeTag": {
    "name": "h2",
    "start": 32,
    "end": 36
  },
  "cursor": 32
}

in which the start tag is <p> and the end tag is </h2>, but the end tag cannot be resolved due and the element the user thinks it should be in is the <p> element, despite that getting auto-closed in the DOM by that <h1>.

As such, rather than a straight forward mismatch to whatever is the parent element according to the DOM, we see a mismatch that is linked to a sibling, not a parent.

This PR also introduces a MISSING_CLOSING_TAG_NAME to catch the following error in the HTML:

<body><div><p><h1>lol</h1></</div></body>

yielding the following error:

{
  type: 'MISSING_CLOSING_TAG_NAME',
  openTag: { name: 'p', start: 11, end: 14 },
  cursor: 26
}

This signals that a </ was seen, and that it should match the <p> but that the DOM is already considered closed for that node.

@Pomax
Copy link
Contributor Author

Pomax commented Sep 27, 2017

This leaves an issue for <body><div><p>lol</</div></body> signalling the wrong pairing, but that is follow-up, to be dealt with in #90

@flukeout
Copy link

Closing this as I've cherry-picked the changes into my work in progress branch that pairs with the work in Thimble. Cool?

@flukeout flukeout closed this Sep 27, 2017
@Pomax
Copy link
Contributor Author

Pomax commented Sep 27, 2017

👍

@flukeout flukeout reopened this Sep 28, 2017
@Pomax Pomax closed this Jan 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A message that could be improved with automatically closed tags
2 participants