Socket
Socket
Sign inDemoInstall

highlight.js

Package Overview
Dependencies
Maintainers
6
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

highlight.js - npm Package Compare versions

Comparing version 11.0.0-alpha0 to 11.0.0-alpha1

CHANGES.md

3

lib/core.d.ts

@@ -1,6 +0,3 @@

// commented out
// <reference path="../types/index.d.ts" />
import hljs from "highlight.js";
export default hljs;

@@ -119,2 +119,3 @@ var hljs = require('./core');

hljs.registerLanguage('n1ql', require('./languages/n1ql'));
hljs.registerLanguage('nestedtext', require('./languages/nestedtext'));
hljs.registerLanguage('nginx', require('./languages/nginx'));

@@ -188,2 +189,3 @@ hljs.registerLanguage('nim', require('./languages/nim'));

hljs.registerLanguage('vim', require('./languages/vim'));
hljs.registerLanguage('wasm', require('./languages/wasm'));
hljs.registerLanguage('x86asm', require('./languages/x86asm'));

@@ -190,0 +192,0 @@ hljs.registerLanguage('xl', require('./languages/xl'));

@@ -59,3 +59,3 @@ /**

const TERMINAL_BINARY = {
className: "symbol",
scope: "symbol",
match: /%b[0-1]+(-[0-1]+|(\.[0-1]+)+)?/

@@ -65,3 +65,3 @@ };

const TERMINAL_DECIMAL = {
className: "symbol",
scope: "symbol",
match: /%d[0-9]+(-[0-9]+|(\.[0-9]+)+)?/

@@ -71,3 +71,3 @@ };

const TERMINAL_HEXADECIMAL = {
className: "symbol",
scope: "symbol",
match: /%x[0-9A-F]+(-[0-9A-F]+|(\.[0-9A-F]+)+)?/

@@ -77,3 +77,3 @@ };

const CASE_SENSITIVITY = {
className: "symbol",
scope: "symbol",
match: /%[si](?=".*")/

@@ -83,3 +83,3 @@ };

const RULE_DECLARATION = {
className: "attribute",
scope: "attribute",
match: concat(IDENT, /(?=\s*=)/)

@@ -89,3 +89,3 @@ };

const ASSIGNMENT = {
className: "operator",
scope: "operator",
match: /=\/?/

@@ -92,0 +92,0 @@ };

@@ -43,2 +43,3 @@ /**

Website: https://httpd.apache.org/docs/2.4/logs.html#accesslog
Category: web, logs
Audit: 2020

@@ -45,0 +46,0 @@ */

@@ -122,12 +122,22 @@ /**

{
beforeMatch: /\b(package)\s+/,
keywords: "package",
match: PKG_NAME_RE,
className: "title.class"
match: [
/\bpackage/,
/\s+/,
PKG_NAME_RE
],
className: {
1: "keyword",
3: "title.class"
}
},
{
beforeMatch: /\b(class|interface|extends|implements)\s+/,
keywords: "class interface extends implements",
match: IDENT_RE,
className: "title.class"
match: [
/\b(?:class|interface|extends|implements)/,
/\s+/,
IDENT_RE
],
className: {
1: "keyword",
3: "title.class"
}
},

@@ -134,0 +144,0 @@ {

@@ -7,3 +7,3 @@ /*

Description: language definition for Apache configuration files (httpd.conf & .htaccess)
Category: config
Category: config, web
Audit: 2020

@@ -10,0 +10,0 @@ */

@@ -445,6 +445,12 @@ /**

{
beforeMatch: /\b(enum|class|struct|union)\s+/,
keywords: "enum class struct union",
match: /\w+/,
className: "title.class"
match: [
// extra complexity to deal with `enum class` and `enum struct`
/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,
/\s+/,
/\w+/
],
className: {
1: "keyword",
3: "title.class"
}
}

@@ -451,0 +457,0 @@ ])

@@ -75,3 +75,4 @@ /*

begin: '[\\[\\{]',
end: '[\\]\\}]'
end: '[\\]\\}]',
relevance: 0
};

@@ -78,0 +79,0 @@ const HINT = {

@@ -445,6 +445,12 @@ /**

{
beforeMatch: /\b(enum|class|struct|union)\s+/,
keywords: "enum class struct union",
match: /\w+/,
className: "title.class"
match: [
// extra complexity to deal with `enum class` and `enum struct`
/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,
/\s+/,
/\w+/
],
className: {
1: "keyword",
3: "title.class"
}
}

@@ -451,0 +457,0 @@ ])

@@ -29,2 +29,9 @@ /*

};
// borrowed from Ruby
const VARIABLE = {
// negative-look forward attemps to prevent false matches like:
// @ident@ or $ident$ that might indicate this is not ruby at all
className: "variable",
begin: '(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])' + `(?![A-Za-z])(?![@$?'])`
};
const EXPANSION = {

@@ -215,2 +222,3 @@ className: 'template-variable',

ATTRIBUTE,
VARIABLE,
hljs.HASH_COMMENT_MODE,

@@ -217,0 +225,0 @@ {

@@ -378,3 +378,3 @@ /*

className: 'meta',
begin: '^\\s*\\[',
begin: '^\\s*\\[(?=[\\w])',
excludeBegin: true,

@@ -381,0 +381,0 @@ end: '\\]',

const MODES = (hljs) => {
return {
IMPORTANT: {
className: 'meta',
scope: 'meta',
begin: '!important'
},
HEXCOLOR: {
className: 'number',
scope: 'number',
begin: '#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})'
},
ATTRIBUTE_SELECTOR_MODE: {
className: 'selector-attr',
scope: 'selector-attr',
begin: /\[/,

@@ -22,3 +22,3 @@ end: /\]/,

CSS_NUMBER_MODE: {
className: 'number',
scope: 'number',
begin: hljs.NUMBER_RE + '(' +

@@ -478,3 +478,3 @@ '%|em|ex|ch|rem' +

Language: CSS
Category: common, css
Category: common, css, web
Website: https://developer.mozilla.org/en-US/docs/Web/CSS

@@ -481,0 +481,0 @@ */

@@ -65,2 +65,38 @@ /*

/* See:
- https://www.haskell.org/onlinereport/lexemes.html
- https://downloads.haskell.org/ghc/9.0.1/docs/html/users_guide/exts/binary_literals.html
- https://downloads.haskell.org/ghc/9.0.1/docs/html/users_guide/exts/numeric_underscores.html
- https://downloads.haskell.org/ghc/9.0.1/docs/html/users_guide/exts/hex_float_literals.html
*/
const decimalDigits = '([0-9]_*)+';
const hexDigits = '([0-9a-fA-F]_*)+';
const binaryDigits = '([01]_*)+';
const octalDigits = '([0-7]_*)+';
const NUMBER = {
className: 'number',
relevance: 0,
variants: [
// decimal floating-point-literal (subsumes decimal-literal)
{
match: `\\b(${decimalDigits})(\\.(${decimalDigits}))?` + `([eE][+-]?(${decimalDigits}))?\\b`
},
// hexadecimal floating-point-literal (subsumes hexadecimal-literal)
{
match: `\\b0[xX]_*(${hexDigits})(\\.(${hexDigits}))?` + `([pP][+-]?(${decimalDigits}))?\\b`
},
// octal-literal
{
match: `\\b0[oO](${octalDigits})\\b`
},
// binary-literal
{
match: `\\b0[bB](${binaryDigits})\\b`
}
]
};
return {

@@ -161,3 +197,3 @@ name: 'Haskell',

hljs.QUOTE_STRING_MODE,
hljs.C_NUMBER_MODE,
NUMBER,
CONSTRUCTOR,

@@ -164,0 +200,0 @@ hljs.inherit(hljs.TITLE_MODE, {

@@ -30,3 +30,3 @@ /**

Author: Ivan Sagalaev <maniac@softwaremaniacs.org>
Category: protocols
Category: protocols, web
Website: https://developer.mozilla.org/en-US/docs/Web/HTTP/Overview

@@ -33,0 +33,0 @@ */

@@ -74,3 +74,4 @@ /*

begin: '[\\[\\{]',
end: '[\\]\\}]'
end: '[\\]\\}]',
relevance: 0
};

@@ -77,0 +78,0 @@ const HINT = {

@@ -196,6 +196,11 @@ // https://docs.oracle.com/javase/specs/jls/se15/html/jls-3.html#jls-3.10

{
beforeMatch: /\b(class|interface|enum|extends|implements|new)\s+/,
keywords: "class interface enum extends implements new",
match: JAVA_IDENT_RE,
className: "title.class"
match: [
/\b(?:class|interface|enum|extends|implements|new)/,
/\s+/,
JAVA_IDENT_RE
],
className: {
1: "keyword",
3: "title.class"
}
},

@@ -202,0 +207,0 @@ {

@@ -178,3 +178,3 @@ const IDENT_RE = '[A-Za-z$_][0-9A-Za-z$_]*';

Description: JavaScript (JS) is a lightweight, interpreted, or just-in-time compiled programming language with first-class functions.
Category: common, scripting
Category: common, scripting, web
Website: https://developer.mozilla.org/en-US/docs/Web/JavaScript

@@ -181,0 +181,0 @@ */

@@ -6,55 +6,40 @@ /*

Website: http://www.json.org
Category: common, protocols
Category: common, protocols, web
*/
function json(hljs) {
const LITERALS = {
literal: 'true false null'
const ATTRIBUTE = {
className: 'attr',
begin: /"(\\.|[^\\"\r\n])*"(?=\s*:)/,
relevance: 1.01
};
const ALLOWED_COMMENTS = [
hljs.C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE
];
const TYPES = [
hljs.QUOTE_STRING_MODE,
hljs.C_NUMBER_MODE
];
const VALUE_CONTAINER = {
end: ',',
endsWithParent: true,
excludeEnd: true,
contains: TYPES,
keywords: LITERALS
const PUNCTUATION = {
match: /[{}[\],:]/,
className: "punctuation",
relevance: 0
};
const OBJECT = {
begin: /\{/,
end: /\}/,
contains: [
{
className: 'attr',
begin: /"/,
end: /"/,
contains: [hljs.BACKSLASH_ESCAPE],
illegal: '\\n'
},
hljs.inherit(VALUE_CONTAINER, {
begin: /:/
})
].concat(ALLOWED_COMMENTS),
illegal: '\\S'
// normally we would rely on `keywords` for this but using a mode here allows us
// to use the very tight `illegal: \S` rule later to flag any other character
// as illegal indicating that despite looking like JSON we do not truly have
// JSON and thus improve false-positively greatly since JSON will try and claim
// all sorts of JSON looking stuff
const LITERALS = {
beginKeywords: [
"true",
"false",
"null"
].join(" ")
};
const ARRAY = {
begin: '\\[',
end: '\\]',
contains: [hljs.inherit(VALUE_CONTAINER)], // inherit is a workaround for a bug that makes shared modes with endsWithParent compile only the ending of one of the parents
illegal: '\\S'
};
TYPES.push(OBJECT, ARRAY);
ALLOWED_COMMENTS.forEach(function(rule) {
TYPES.push(rule);
});
return {
name: 'JSON',
contains: TYPES,
keywords: LITERALS,
contains: [
ATTRIBUTE,
PUNCTUATION,
hljs.QUOTE_STRING_MODE,
LITERALS,
hljs.C_NUMBER_MODE,
hljs.C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE
],
illegal: '\\S'

@@ -61,0 +46,0 @@ };

const MODES = (hljs) => {
return {
IMPORTANT: {
className: 'meta',
scope: 'meta',
begin: '!important'
},
HEXCOLOR: {
className: 'number',
scope: 'number',
begin: '#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})'
},
ATTRIBUTE_SELECTOR_MODE: {
className: 'selector-attr',
scope: 'selector-attr',
begin: /\[/,

@@ -22,3 +22,3 @@ end: /\]/,

CSS_NUMBER_MODE: {
className: 'number',
scope: 'number',
begin: hljs.NUMBER_RE + '(' +

@@ -451,3 +451,3 @@ '%|em|ex|ch|rem' +

Website: http://lesscss.org
Category: common, css
Category: common, css, web
*/

@@ -454,0 +454,0 @@

@@ -38,3 +38,3 @@ /**

Contributors: Ivan Sagalaev <maniac@softwaremaniacs.org>
Category: config
Category: config, web
Website: https://www.nginx.com

@@ -41,0 +41,0 @@ */

@@ -12,2 +12,3 @@ /*

name: 'Processing',
aliases: [ 'pde' ],
keywords: {

@@ -14,0 +15,0 @@ keyword: 'BufferedReader PVector PFont PImage PGraphics HashMap boolean byte char color ' +

@@ -158,5 +158,6 @@ /**

{
className: 'number',
relevance: 0,
beforeMatch: /([^a-zA-Z0-9._])/, // not part of an identifier
className: {
2: "number"
},
variants: [

@@ -169,11 +170,20 @@ // TODO: replace with negative look-behind when available

// Special case: only hexadecimal binary powers can contain fractions.
match: /0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/,
match: [
/[^a-zA-Z0-9._]/, // not part of an identifier
/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/
]
},
{
match: /0[xX][0-9a-fA-F]+([pP][+-]?\d+)?[Li]?/
match: [
/[^a-zA-Z0-9._]/, // not part of an identifier
/0[xX][0-9a-fA-F]+(?:[pP][+-]?\d+)?[Li]?/
]
},
{
match: /(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?[Li]?/,
match: [
/[^a-zA-Z0-9._]/, // not part of an identifier
/(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?[Li]?/
]
}
],
]
},

@@ -180,0 +190,0 @@ {

@@ -158,9 +158,11 @@ /**

},
{ // heredocs
begin: /<<[-~]?'?(\w+)\n(?:[^\n]*\n)*?\s*\1\b/,
returnBegin: true,
// heredocs
{
// this guard makes sure that we have an entire heredoc and not a false
// positive (auto-detect, etc.)
begin: concat(
/<<[-~]?'?/,
lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/)
),
contains: [
{
begin: /<<[-~]?'?/
},
hljs.END_SAME_AS_BEGIN({

@@ -167,0 +169,0 @@ begin: /(\w+)/,

const MODES = (hljs) => {
return {
IMPORTANT: {
className: 'meta',
scope: 'meta',
begin: '!important'
},
HEXCOLOR: {
className: 'number',
scope: 'number',
begin: '#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})'
},
ATTRIBUTE_SELECTOR_MODE: {
className: 'selector-attr',
scope: 'selector-attr',
begin: /\[/,

@@ -22,3 +22,3 @@ end: /\]/,

CSS_NUMBER_MODE: {
className: 'number',
scope: 'number',
begin: hljs.NUMBER_RE + '(' +

@@ -448,3 +448,3 @@ '%|em|ex|ch|rem' +

Website: https://sass-lang.com
Category: common, css
Category: common, css, web
*/

@@ -451,0 +451,0 @@

const MODES = (hljs) => {
return {
IMPORTANT: {
className: 'meta',
scope: 'meta',
begin: '!important'
},
HEXCOLOR: {
className: 'number',
scope: 'number',
begin: '#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})'
},
ATTRIBUTE_SELECTOR_MODE: {
className: 'selector-attr',
scope: 'selector-attr',
begin: /\[/,

@@ -22,3 +22,3 @@ end: /\]/,

CSS_NUMBER_MODE: {
className: 'number',
scope: 'number',
begin: hljs.NUMBER_RE + '(' +

@@ -448,3 +448,3 @@ '%|em|ex|ch|rem' +

Website: https://github.com/stylus/stylus
Category: css
Category: css, web
*/

@@ -451,0 +451,0 @@

@@ -340,2 +340,3 @@ /**

'requires_stored_property_inits',
'resultBuilder',
'testable',

@@ -342,0 +343,0 @@ 'UIApplicationMain',

@@ -178,3 +178,3 @@ const IDENT_RE = '[A-Za-z$_][0-9A-Za-z$_]*';

Description: JavaScript (JS) is a lightweight, interpreted, or just-in-time compiled programming language with first-class functions.
Category: common, scripting
Category: common, scripting, web
Website: https://developer.mozilla.org/en-US/docs/Web/JavaScript

@@ -181,0 +181,0 @@ */

@@ -151,3 +151,3 @@ /**

{
// TODO: Use `beforeMatch:` for leading spaces
// TODO: Use multi-class for leading spaces
begin: /([\t ]|^)REM(?=\s)/

@@ -160,3 +160,3 @@ }

className: 'meta',
// TODO: Use `beforeMatch:` for indentation once available
// TODO: Use multi-class for indentation once available
begin: /[\t ]*#(const|disable|else|elseif|enable|end|externalsource|if|region)\b/,

@@ -163,0 +163,0 @@ end: /$/,

@@ -57,3 +57,3 @@ /**

Website: https://www.w3.org/XML/
Category: common
Category: common, web
Audit: 2020

@@ -60,0 +60,0 @@ */

@@ -9,3 +9,3 @@ {

"homepage": "https://highlightjs.org/",
"version": "11.0.0-alpha0",
"version": "11.0.0-alpha1",
"author": {

@@ -36,2 +36,3 @@ "name": "Ivan Sagalaev",

},
"type": "commonjs",
"main": "./lib/index.js",

@@ -89,3 +90,22 @@ "types": "./types/index.d.ts",

"typescript": "^4.0.5"
},
"exports": {
".": {
"require": "./lib/index.js",
"import": "./es/index.js"
},
"./package.json": "./package.json",
"./lib/common": {
"require": "./lib/common.js",
"import": "./es/common.js"
},
"./lib/core": {
"require": "./lib/core.js",
"import": "./es/core.js"
},
"./lib/languages/*": {
"require": "./lib/languages/*.js",
"import": "./es/languages/*.js"
}
}
}

@@ -65,3 +65,3 @@ # Highlight.js

**Latest:** 11.0.0-alpha0
**Latest:** https://github.com/highlightjs/highlight.js/issues/3131

@@ -259,7 +259,12 @@ #### Upgrading to Version 10

For a smaller footprint, load only the languages you need.
For a smaller footprint, load our common subset of languages (the same set used for our default web build).
```js
const hljs = require('highlight.js/lib/core'); // require only the core library
// separately require languages
const hljs = require('highlight.js/lib/common');
```
For the smallest footprint, load only the languages you need:
```js
const hljs = require('highlight.js/lib/core');
hljs.registerLanguage('xml', require('highlight.js/lib/languages/xml'));

@@ -266,0 +271,0 @@

@@ -6,4 +6,16 @@ /* eslint-disable no-unused-vars */

declare module 'highlight.js/private' {
import { CompiledMode, Mode, Language } from "highlight.js";
type MatchType = "begin" | "end" | "illegal"
type EnhancedMatch = RegExpMatchArray & {rule: CompiledMode, type: MatchType}
type AnnotatedError = Error & {mode?: Mode | Language, languageName?: string, badRule?: Mode}
type KeywordData = [string, number];
type KeywordDict = Record<string, KeywordData>
}
declare module 'highlight.js' {
import { KeywordDict} from "highlight.js/private";
export type HLJSApi = PublicApi & ModesAPI

@@ -16,3 +28,3 @@

interface PublicApi {
highlight: (codeOrlanguageName: string, optionsOrCode: string | HighlightOptions, ignoreIllegals?: boolean, continuation?: Mode) => HighlightResult
highlight: (codeOrLanguageName: string, optionsOrCode: string | HighlightOptions, ignoreIllegals?: boolean, continuation?: Mode) => HighlightResult
highlightAuto: (code: string, languageSubset?: string[]) => AutoHighlightResult

@@ -165,13 +177,4 @@ highlightBlock: (element: HTMLElement) => void

/************
PRIVATE API
************/
export type HighlightedHTMLElement = HTMLElement & {result?: object, secondBest?: object, parentNode: HTMLElement}
/* for jsdoc annotations in the JS source files */
type AnnotatedError = Error & {mode?: Mode | Language, languageName?: string, badRule?: Mode}
type HighlightedHTMLElement = HTMLElement & {result?: object, secondBest?: object, parentNode: HTMLElement}
type EnhancedMatch = RegExpMatchArray & {rule: CompiledMode, type: MatchType}
type MatchType = "begin" | "end" | "illegal"
/* modes */

@@ -184,3 +187,3 @@

interface CompiledLanguage extends LanguageDetail, CompiledMode {
export interface CompiledLanguage extends LanguageDetail, CompiledMode {
isCompiled: true

@@ -191,5 +194,2 @@ contains: CompiledMode[]

type KeywordData = [string, number];
type KeywordDict = Record<string, KeywordData>
export type CompiledMode = Omit<Mode, 'contains'> &

@@ -210,2 +210,4 @@ {

parent?: CompiledMode
beginScope?: Record<number, string> & {_emit?: Record<number,boolean>, _multi?: boolean, _wrap?: string}
endScope?: Record<number, string> & {_emit?: Record<number,boolean>, _multi?: boolean, _wrap?: string}
}

@@ -218,2 +220,5 @@

className?: string
_emit?: Record<number, boolean>
scope?: string | Record<number, string>
beginScope?: string | Record<number, string>
contains?: ("self" | Mode)[]

@@ -220,0 +225,0 @@ endsParent?: boolean

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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