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: expose position / location / line internal apis #125

Closed DylanPiercey closed 2 years ago

DylanPiercey commented 2 years ago

Expose some apis for generating position and location information.

Method to get line offset information: getLines(code: string): string

Method to get a Position object given an offset a line offset array (from getLines): getPosition(lines: number[], offset: number): Position

Method to get a Location object given a start and end offset and a line offset array (from getLines): getLocation(lines: number[], startOffset: number, endOffset: number): Location

changeset-bot[bot] commented 2 years ago

🦋 Changeset detected

Latest commit: 617d33c9ae2fcaaadab27fbc079a52a9c782a15d

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 | Minor |

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 #125 (617d33c) into main (18a377a) will increase coverage by 1.57%. The diff coverage is 71.42%.

@@            Coverage Diff             @@
##             main     #125      +/-   ##
==========================================
+ Coverage   91.22%   92.79%   +1.57%     
==========================================
  Files          26       26              
  Lines         718      736      +18     
  Branches      224      253      +29     
==========================================
+ Hits          655      683      +28     
+ Misses         39       38       -1     
+ Partials       24       15       -9     
Impacted Files Coverage Δ
src/index.ts 87.50% <ø> (ø)
src/core/Parser.ts 90.42% <50.00%> (+0.53%) :arrow_up:
src/util/util.ts 85.71% <80.00%> (+0.71%) :arrow_up:
src/states/JS_COMMENT_LINE.ts 71.42% <0.00%> (-11.91%) :arrow_down:
src/states/DECLARATION.ts 100.00% <0.00%> (ø)
src/states/HTML_CONTENT.ts 97.61% <0.00%> (+0.11%) :arrow_up:
src/states/ATTRIBUTE.ts 95.08% <0.00%> (+2.09%) :arrow_up:
src/states/TAG_NAME.ts 100.00% <0.00%> (+2.27%) :arrow_up:
src/states/PLACEHOLDER.ts 100.00% <0.00%> (+4.00%) :arrow_up:
... and 2 more

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 18a377a...617d33c. Read the comment docs.