Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@markuplint/parser-utils

Package Overview
Dependencies
Maintainers
0
Versions
139
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@markuplint/parser-utils - npm Package Compare versions

Comparing version 4.6.8 to 4.7.0

11

CHANGELOG.md

@@ -6,10 +6,17 @@ # Change Log

## [4.6.8](https://github.com/markuplint/markuplint/compare/@markuplint/parser-utils@4.6.7...@markuplint/parser-utils@4.6.8) (2024-10-14)
# [4.7.0](https://github.com/markuplint/markuplint/compare/@markuplint/parser-utils@4.6.8...@markuplint/parser-utils@4.7.0) (2024-10-15)
**Note:** Version bump only for package @markuplint/parser-utils
### Features
* **parser-utils:** expose `getOffsetsFromCode` function ([8ef7aec](https://github.com/markuplint/markuplint/commit/8ef7aec26d3198328c86ebeffaa0bd9c879a1f0e))
## [4.6.8](https://github.com/markuplint/markuplint/compare/@markuplint/parser-utils@4.6.7...@markuplint/parser-utils@4.6.8) (2024-10-14)
**Note:** Version bump only for package @markuplint/parser-utils
## [4.6.7](https://github.com/markuplint/markuplint/compare/@markuplint/parser-utils@4.6.6...@markuplint/parser-utils@4.6.7) (2024-09-23)

@@ -16,0 +23,0 @@

@@ -15,1 +15,5 @@ /**

export declare function getEndCol(rawCodeFragment: string, startCol: number): number;
export declare function getOffsetsFromCode(rawCode: string, startLine: number, startCol: number, endLine: number, endCol: number): {
offset: number;
endOffset: number;
};

@@ -30,1 +30,23 @@ const LINE_BREAK = '\n';

}
export function getOffsetsFromCode(rawCode, startLine, startCol, endLine, endCol) {
const lines = rawCode.split('\n');
let offset = 0;
let endOffset = 0;
for (let i = 0; i < startLine - 1; i++) {
const line = lines[i];
if (line == null) {
continue;
}
offset += line.length + 1;
}
offset += startCol - 1;
for (let i = 0; i < endLine - 1; i++) {
const line = lines[i];
if (line == null) {
continue;
}
endOffset += line.length + 1;
}
endOffset += endCol - 1;
return { offset, endOffset };
}

23

lib/parser.js

@@ -20,3 +20,3 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {

import { AttrState, TagState } from './enums.js';
import { getEndCol, getEndLine, getPosition } from './get-location.js';
import { getEndCol, getEndLine, getOffsetsFromCode, getPosition } from './get-location.js';
import { ignoreBlock, restoreNode } from './ignore-block.js';

@@ -591,22 +591,3 @@ import { ignoreFrontMatter } from './ignore-front-matter.js';

getOffsetsFromCode(startLine, startCol, endLine, endCol) {
const lines = __classPrivateFieldGet(this, _Parser_rawCode, "f").split('\n');
let offset = 0;
let endOffset = 0;
for (let i = 0; i < startLine - 1; i++) {
const line = lines[i];
if (line == null) {
continue;
}
offset += line.length + 1;
}
offset += startCol - 1;
for (let i = 0; i < endLine - 1; i++) {
const line = lines[i];
if (line == null) {
continue;
}
endOffset += line.length + 1;
}
endOffset += endCol - 1;
return { offset, endOffset };
return getOffsetsFromCode(this.rawCode, startLine, startCol, endLine, endCol);
}

@@ -613,0 +594,0 @@ walk(nodeList, walker, depth = 0) {

{
"name": "@markuplint/parser-utils",
"version": "4.6.8",
"version": "4.7.0",
"description": "Utility module for markuplint parser plugin",

@@ -31,5 +31,5 @@ "repository": "git@github.com:markuplint/markuplint.git",

"dependencies": {
"@markuplint/ml-ast": "4.4.5",
"@markuplint/ml-spec": "4.7.1",
"@markuplint/types": "4.6.1",
"@markuplint/ml-ast": "4.4.6",
"@markuplint/ml-spec": "4.7.2",
"@markuplint/types": "4.6.2",
"@types/uuid": "10.0.0",

@@ -42,5 +42,5 @@ "debug": "4.3.7",

"devDependencies": {
"@typescript-eslint/typescript-estree": "8.8.1"
"@typescript-eslint/typescript-estree": "8.9.0"
},
"gitHead": "e59d4e8b762c66c7e3fb8b0a0d9d99d5160b0afa"
"gitHead": "c8c82d36c2e48d191091cbc22ca1b99ed0704b9f"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc