marko-js / htmljs-parser

An HTML parser recognizes content and string placeholders and allows JavaScript expressions as attribute values
MIT License
135 stars 20 forks source link

feat: add new parser events and rename 'onTagName' to 'onOpenTagName'. #114

Closed DylanPiercey closed 2 years ago

DylanPiercey commented 2 years ago

Description

Instead of </div> being processed in the single onCloseTag event it is broken into the following segments

onCloseTagStart

</

onCloseTagName

div

onCloseTagStart

>

For consistency, the onTagName event was renamed to onOpenTagName and a new onOpenTagStart even was added which matches the open < bracket.

Note:

onOpenTagStart, onCloseTagStart & onCloseTagName are exclusively called for html mode tags. All of the other events are called for concise tags as well. Eg a concise tag will get onCloseTagEnd, which shows where the tags body content stops, but will not get an onCloseTagStart or onCloseTagName.

Motivation and Context

While working on the language server is was discovered that providing completions for the closing tag could be improved if we were to split up it's events so it could be processed earlier.

Screenshots (if appropriate):

Checklist:

changeset-bot[bot] commented 2 years ago

🦋 Changeset detected

Latest commit: bc94daac71dd34dadebc35ae756894d78c1dde30

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ------------- | ----- | | htmljs-parser | Major |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

codecov[bot] commented 2 years ago

Codecov Report

Merging #114 (bc94daa) into main (b79698c) will increase coverage by 0.02%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #114      +/-   ##
==========================================
+ Coverage   93.26%   93.29%   +0.02%     
==========================================
  Files          26       26              
  Lines         713      716       +3     
  Branches      244      247       +3     
==========================================
+ Hits          665      668       +3     
  Misses         32       32              
  Partials       16       16              
Impacted Files Coverage Δ
src/states/CLOSE_TAG.ts 87.50% <ø> (ø)
src/util/constants.ts 100.00% <ø> (ø)
src/core/Parser.ts 91.30% <100.00%> (+0.09%) :arrow_up:
src/states/CONCISE_HTML_CONTENT.ts 91.48% <100.00%> (ø)
src/states/HTML_CONTENT.ts 96.29% <100.00%> (+0.29%) :arrow_up:
src/states/TAG_NAME.ts 100.00% <100.00%> (ø)
src/util/util.ts 85.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update b79698c...bc94daa. Read the comment docs.