lang-detector
Advanced tools
Comparing version 1.0.4 to 1.0.5
17
index.js
@@ -55,2 +55,4 @@ /** | ||
{ pattern: /(var|const|let)( )+\w+( )*=?/, points: 2 }, | ||
// Array/Object declaration | ||
{ pattern: /(('|").+('|")( )*|\w+):( )*[{\[]/, points: 2 }, | ||
// === operator | ||
@@ -61,3 +63,3 @@ { pattern: /===/g, points: 1 }, | ||
// Function definition | ||
{ pattern: /function(( )+[\$\w]+( )*\(.*\)|( )*\(.*\))/g, points: 1 }, | ||
{ pattern: /function\*?(( )+[\$\w]+( )*\(.*\)|( )*\(.*\))/g, points: 1 }, | ||
// null keyword | ||
@@ -75,2 +77,4 @@ { pattern: /null/g, points: 1 }, | ||
{ pattern: /(\w+)( )*\*( )*\w+/, points: -1 }, | ||
// HTML <script> tag | ||
{ pattern: /<(\/)?script( type=('|")text\/javascript('|"))?>/, points: -50 }, | ||
], | ||
@@ -117,3 +121,3 @@ | ||
// using namespace something | ||
{ pattern: /using( )+namespace( )+.+( )*;/, points: 2, nearTop: true }, | ||
{ pattern: /using( )+namespace( )+.+( )*;/, points: 2 }, | ||
// template declaration | ||
@@ -227,3 +231,3 @@ { pattern: /template( )*<.*>/, points: 2 }, | ||
{ pattern: /[a-z\-]+=("|').+("|')/g, points: 2 }, | ||
// PHP tag (This is a rare case where a lot of penalty points are needed.) | ||
// PHP tag | ||
{ pattern: /<\?php/, points: -50 }, | ||
@@ -235,3 +239,3 @@ ], | ||
{ pattern: /[a-z\-]+:(?!:).+;/, points: 2 }, | ||
// <style> tag from HTML (This is a rare case where a lot of penalty points are needed.) | ||
// <style> tag from HTML | ||
{ pattern: /<(\/)?style>/, points: -50 }, | ||
@@ -404,6 +408,3 @@ ], | ||
} | ||
return { | ||
detected: bestResult.language, | ||
statistics: statistics, | ||
}; | ||
return { detected: bestResult.language, statistics: statistics }; | ||
} | ||
@@ -410,0 +411,0 @@ |
{ | ||
"name": "lang-detector", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "A library for detecting the programming language of a code snippet.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is too big to display
485917
10334