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

vscode-html-languageservice

Package Overview
Dependencies
Maintainers
6
Versions
140
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vscode-html-languageservice - npm Package Compare versions

Comparing version 1.0.0-next.6 to 1.0.0-next.7

62

lib/htmlLanguageService.d.ts

@@ -18,3 +18,62 @@ import { TextDocument, Position, CompletionItem, CompletionList, Hover, Range, SymbolInformation, Diagnostic, TextEdit, DocumentHighlight, FormattingOptions, MarkedString, DocumentLink } from 'vscode-languageserver-types';

}
export declare type HTMLDocument = {};
export interface Node {
tag: string;
start: number;
end: number;
endTagStart: number;
children: Node[];
parent: Node;
}
export declare enum TokenType {
StartCommentTag = 0,
Comment = 1,
EndCommentTag = 2,
StartTagOpen = 3,
StartTagClose = 4,
StartTagSelfClose = 5,
StartTag = 6,
EndTagOpen = 7,
EndTagClose = 8,
EndTag = 9,
DelimiterAssign = 10,
AttributeName = 11,
AttributeValue = 12,
StartDoctypeTag = 13,
Doctype = 14,
EndDoctypeTag = 15,
Content = 16,
Whitespace = 17,
Unknown = 18,
Script = 19,
Styles = 20,
EOS = 21,
}
export declare enum ScannerState {
WithinContent = 0,
AfterOpeningStartTag = 1,
AfterOpeningEndTag = 2,
WithinDoctype = 3,
WithinTag = 4,
WithinEndTag = 5,
WithinComment = 6,
WithinScriptContent = 7,
WithinStyleContent = 8,
AfterAttributeName = 9,
BeforeAttributeValue = 10,
}
export interface Scanner {
scan(): TokenType;
getTokenType(): TokenType;
getTokenOffset(): number;
getTokenLength(): number;
getTokenEnd(): number;
getTokenText(): string;
getTokenError(): string;
getScannerState(): ScannerState;
}
export declare type HTMLDocument = {
roots: Node[];
findNodeBefore(offset: number): Node;
findNodeAt(offset: number): Node;
};
export interface DocumentContext {

@@ -24,2 +83,3 @@ resolveReference(ref: string): string;

export interface LanguageService {
createScanner(input: string): Scanner;
parseHTMLDocument(document: TextDocument): HTMLDocument;

@@ -26,0 +86,0 @@ findDocumentHighlights(document: TextDocument, position: Position, htmlDocument: HTMLDocument): DocumentHighlight[];

@@ -6,3 +6,3 @@ (function (factory) {

else if (typeof define === 'function' && define.amd) {
define(["require", "exports", './parser/htmlParser', './services/htmlCompletion', './services/htmlFormatter', './services/htmlLinks', './services/htmlHighlighting', 'vscode-languageserver-types'], factory);
define(["require", "exports", './parser/htmlScanner', './parser/htmlParser', './services/htmlCompletion', './services/htmlFormatter', './services/htmlLinks', './services/htmlHighlighting', 'vscode-languageserver-types'], factory);
}

@@ -15,2 +15,3 @@ })(function (require, exports) {

'use strict';
var htmlScanner_1 = require('./parser/htmlScanner');
var htmlParser_1 = require('./parser/htmlParser');

@@ -34,4 +35,44 @@ var htmlCompletion_1 = require('./services/htmlCompletion');

exports.DocumentLink = vscode_languageserver_types_1.DocumentLink;
(function (TokenType) {
TokenType[TokenType["StartCommentTag"] = 0] = "StartCommentTag";
TokenType[TokenType["Comment"] = 1] = "Comment";
TokenType[TokenType["EndCommentTag"] = 2] = "EndCommentTag";
TokenType[TokenType["StartTagOpen"] = 3] = "StartTagOpen";
TokenType[TokenType["StartTagClose"] = 4] = "StartTagClose";
TokenType[TokenType["StartTagSelfClose"] = 5] = "StartTagSelfClose";
TokenType[TokenType["StartTag"] = 6] = "StartTag";
TokenType[TokenType["EndTagOpen"] = 7] = "EndTagOpen";
TokenType[TokenType["EndTagClose"] = 8] = "EndTagClose";
TokenType[TokenType["EndTag"] = 9] = "EndTag";
TokenType[TokenType["DelimiterAssign"] = 10] = "DelimiterAssign";
TokenType[TokenType["AttributeName"] = 11] = "AttributeName";
TokenType[TokenType["AttributeValue"] = 12] = "AttributeValue";
TokenType[TokenType["StartDoctypeTag"] = 13] = "StartDoctypeTag";
TokenType[TokenType["Doctype"] = 14] = "Doctype";
TokenType[TokenType["EndDoctypeTag"] = 15] = "EndDoctypeTag";
TokenType[TokenType["Content"] = 16] = "Content";
TokenType[TokenType["Whitespace"] = 17] = "Whitespace";
TokenType[TokenType["Unknown"] = 18] = "Unknown";
TokenType[TokenType["Script"] = 19] = "Script";
TokenType[TokenType["Styles"] = 20] = "Styles";
TokenType[TokenType["EOS"] = 21] = "EOS";
})(exports.TokenType || (exports.TokenType = {}));
var TokenType = exports.TokenType;
(function (ScannerState) {
ScannerState[ScannerState["WithinContent"] = 0] = "WithinContent";
ScannerState[ScannerState["AfterOpeningStartTag"] = 1] = "AfterOpeningStartTag";
ScannerState[ScannerState["AfterOpeningEndTag"] = 2] = "AfterOpeningEndTag";
ScannerState[ScannerState["WithinDoctype"] = 3] = "WithinDoctype";
ScannerState[ScannerState["WithinTag"] = 4] = "WithinTag";
ScannerState[ScannerState["WithinEndTag"] = 5] = "WithinEndTag";
ScannerState[ScannerState["WithinComment"] = 6] = "WithinComment";
ScannerState[ScannerState["WithinScriptContent"] = 7] = "WithinScriptContent";
ScannerState[ScannerState["WithinStyleContent"] = 8] = "WithinStyleContent";
ScannerState[ScannerState["AfterAttributeName"] = 9] = "AfterAttributeName";
ScannerState[ScannerState["BeforeAttributeValue"] = 10] = "BeforeAttributeValue";
})(exports.ScannerState || (exports.ScannerState = {}));
var ScannerState = exports.ScannerState;
function getLanguageService() {
return {
createScanner: htmlScanner_1.createScanner,
parseHTMLDocument: function (document) { return htmlParser_1.parse(document.getText()); },

@@ -38,0 +79,0 @@ doComplete: htmlCompletion_1.doComplete,

4

lib/parser/htmlParser.js

@@ -78,3 +78,3 @@ (function (factory) {

case htmlScanner_1.TokenType.StartTag:
curr.tag = scanner.getTokenText();
curr.tag = scanner.getTokenText().toLowerCase();
break;

@@ -92,3 +92,3 @@ case htmlScanner_1.TokenType.StartTagClose:

case htmlScanner_1.TokenType.EndTag:
var closeTag = scanner.getTokenText();
var closeTag = scanner.getTokenText().toLowerCase();
while (!htmlTags_1.isSameTag(curr.tag, closeTag) && curr !== htmlDocument) {

@@ -95,0 +95,0 @@ curr.end = endTagStart;

@@ -55,3 +55,3 @@ /*---------------------------------------------------------------------------------------------

function isSameTag(t1, t2) {
return t1 && t2 && t1.toLowerCase() === t2.toLowerCase();
return t1 && t2 && t1 === t2;
}

@@ -58,0 +58,0 @@ exports.isSameTag = isSameTag;

@@ -123,4 +123,5 @@ (function (factory) {

var value = isFollowedBy(text, nameEnd, htmlScanner_1.ScannerState.AfterAttributeName, htmlScanner_1.TokenType.DelimiterAssign) ? '' : '="{{}}"';
var tag = currentTag.toLowerCase();
tagProviders.forEach(function (provider) {
provider.collectAttributes(currentTag, function (attribute, type) {
provider.collectAttributes(tag, function (attribute, type) {
var codeSnippet = attribute;

@@ -156,4 +157,6 @@ if (type !== 'v' && value.length) {

}
var tag = currentTag.toLowerCase();
var attribute = currentAttributeName.toLowerCase();
tagProviders.forEach(function (provider) {
provider.collectValues(currentTag, currentAttributeName, function (value) {
provider.collectValues(tag, attribute, function (value) {
var codeSnippet = addQuotes ? '"' + value + '"' : value;

@@ -160,0 +163,0 @@ result.items.push({

@@ -72,3 +72,3 @@ (function (factory) {

case htmlScanner_1.TokenType.AttributeName:
var attributeName = scanner.getTokenText();
var attributeName = scanner.getTokenText().toLowerCase();
afterHrefOrSrc = attributeName === 'src' || attributeName === 'href';

@@ -75,0 +75,0 @@ break;

@@ -309,2 +309,26 @@ (function (factory) {

});
test('Case sensitivity', function (testDone) {
run([
testCompletionFor('<LI></|', {
items: [
{ label: '/li', resultText: '<LI></li>' }
]
}),
testCompletionFor('<lI></|', {
items: [
{ label: '/li', resultText: '<lI></li>' }
]
}),
testCompletionFor('<iNpUt |', {
items: [
{ label: 'type', resultText: '<iNpUt type="{{}}"' }
]
}),
testCompletionFor('<INPUT TYPE=|', {
items: [
{ label: 'color', resultText: '<INPUT TYPE="color"' }
]
})
], testDone);
});
test('Handlebar Completion', function (testDone) {

@@ -311,0 +335,0 @@ run([

@@ -32,3 +32,3 @@ (function (factory) {

assert.equal(actualEndOffset, expectedMatches[i] + elementName.length);
assert.equal(document.getText().substring(actualStartOffset, actualEndOffset), elementName);
assert.equal(document.getText().substring(actualStartOffset, actualEndOffset).toLowerCase(), elementName);
}

@@ -68,4 +68,8 @@ }

});
test('Case insensivity', function () {
assertHighlights('<HTML><diV><Div></dIV></dI|v></html>', [7, 24], 'div');
assertHighlights('<HTML><diV|><Div></dIV></dIv></html>', [7, 24], 'div');
});
});
});
//# sourceMappingURL=highlighting.test.js.map

@@ -70,2 +70,3 @@ (function (factory) {

testLinkDetection('<img src="">', []);
testLinkDetection('<LINK HREF="a.html">', [12]);
});

@@ -72,0 +73,0 @@ });

{
"name": "vscode-html-languageservice",
"version": "1.0.0-next.6",
"version": "1.0.0-next.7",
"description": "Language service for HTML",

@@ -5,0 +5,0 @@ "main": "./lib/htmlLanguageService.js",

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