Socket
Socket
Sign inDemoInstall

highlight.js

Package Overview
Dependencies
Maintainers
5
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 10.1.2 to 10.2.0

scss/gradient-light.scss

109

lib/core.js

@@ -907,2 +907,6 @@ // https://github.com/substack/deep-freeze/blob/master/index.js

resumingScanAtSamePosition() {
return this.regexIndex != 0;
}
considerAll() {

@@ -1215,4 +1219,67 @@ this.regexIndex = 0;

var version = "10.1.2";
var version = "10.2.0";
// @ts-nocheck
function hasValueOrEmptyAttribute(value) {
return Boolean(value || value === "");
}
const Component = {
props: ["language", "code", "autodetect"],
data: function() {
return {
detectedLanguage: "",
unknownLanguage: false
};
},
computed: {
className() {
if (this.unknownLanguage) return "";
return "hljs " + this.detectedLanguage;
},
highlighted() {
// no idea what language to use, return raw code
if (!this.autoDetect && !hljs.getLanguage(this.language)) {
console.warn(`The language "${this.language}" you specified could not be found.`);
this.unknownLanguage = true;
return escapeHTML(this.code);
}
let result;
if (this.autoDetect) {
result = hljs.highlightAuto(this.code);
this.detectedLanguage = result.language;
} else {
result = hljs.highlight(this.language, this.code, this.ignoreIllegals);
this.detectectLanguage = this.language;
}
return result.value;
},
autoDetect() {
return !this.language || hasValueOrEmptyAttribute(this.autodetect);
},
ignoreIllegals() {
return true;
}
},
// this avoids needing to use a whole Vue compilation pipeline just
// to build Highlight.js
render(createElement) {
return createElement("pre", {}, [
createElement("code", {
class: this.className,
domProps: { innerHTML: this.highlighted }})
]);
}
// template: `<pre><code :class="className" v-html="highlighted"></code></pre>`
};
const VuePlugin = {
install(Vue) {
Vue.component('highlightjs', Component);
}
};
/*

@@ -1472,2 +1539,10 @@ Syntax highlighting with language autodetection.

/**
* Advance a single character
*/
function advanceOne() {
mode_buffer += codeToHighlight[index];
index += 1;
}
/**
* Handle matching but then ignoring a sequence of text

@@ -1486,3 +1561,3 @@ *

// match at this very spot
continueScanAtSamePosition = true;
resumeScanAtSamePosition = true;
return 0;

@@ -1690,3 +1765,3 @@ }

var iterations = 0;
var continueScanAtSamePosition = false;
var resumeScanAtSamePosition = false;

@@ -1698,6 +1773,6 @@ try {

iterations++;
if (continueScanAtSamePosition) {
if (resumeScanAtSamePosition) {
// only regexes not matched previously will now be
// considered for a potential match
continueScanAtSamePosition = false;
resumeScanAtSamePosition = false;
} else {

@@ -1707,4 +1782,13 @@ top.matcher.lastIndex = index;

}
const match = top.matcher.exec(codeToHighlight);
// console.log("match", match[0], match.rule && match.rule.begin)
// if our failure to match was the result of a "resumed scan" then we
// need to advance one position and revert to full scanning before we
// decide there are truly no more matches at all to be had
if (!match && top.matcher.resumingScanAtSamePosition()) {
advanceOne();
continue;
}
if (!match) break;

@@ -2046,8 +2130,15 @@

/* fixMarkup is deprecated and will be removed entirely in v11 */
function deprecate_fixMarkup(arg) {
console.warn("fixMarkup is deprecated and will be removed entirely in v11.0");
console.warn("Please see https://github.com/highlightjs/highlight.js/issues/2534");
return fixMarkup(arg)
}
/* Interface definition */
Object.assign(hljs, {
highlight,
highlightAuto,
fixMarkup,
fixMarkup: deprecate_fixMarkup,
highlightBlock,

@@ -2064,3 +2155,5 @@ configure,

inherit: inherit$1,
addPlugin
addPlugin,
// plugins for frameworks
vuePlugin: VuePlugin
});

@@ -2067,0 +2160,0 @@

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

ARDUINO.name = 'Arduino';
ARDUINO.aliases = ['ino'];

@@ -109,0 +110,0 @@ return ARDUINO;

2

lib/languages/autohotkey.js

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

{
className: 'title', //symbol would be most accurate however is higlighted just like built_in and that makes up a lot of AutoHotkey code
className: 'title', //symbol would be most accurate however is highlighted just like built_in and that makes up a lot of AutoHotkey code
//meaning that it would fail to highlight anything

@@ -46,0 +46,0 @@ variants: [

@@ -86,3 +86,3 @@ /*

keywords: {
$pattern: /\b-?[a-z\._]+\b/,
$pattern: /\b-?[a-z\._-]+\b/,
keyword:

@@ -89,0 +89,0 @@ 'if then else elif fi for while in do done case esac function',

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

function c(hljs) {
var lang = hljs.getLanguage('c-like').rawDefinition();
var lang = hljs.requireLanguage('c-like').rawDefinition();
// Until C is actually different than C++ there is no reason to auto-detect C

@@ -23,5 +22,4 @@ // as it's own language since it would just fail auto-detect testing or

return lang;
}
module.exports = c;

@@ -10,3 +10,3 @@ /*

function cpp(hljs) {
var lang = hljs.getLanguage('c-like').rawDefinition();
var lang = hljs.requireLanguage('c-like').rawDefinition();
// return auto-detection back on

@@ -13,0 +13,0 @@ lang.disableAutodetect = false;

@@ -16,3 +16,3 @@ /*

'default delegate do double enum event explicit extern finally fixed float ' +
'for foreach goto if implicit in int interface internal is lock long ' +
'for foreach goto if implicit in init int interface internal is lock long ' +
'object operator out override params private protected public readonly ref sbyte ' +

@@ -169,2 +169,12 @@ 'sealed short sizeof stackalloc static string struct switch this try typeof ' +

{
beginKeywords: 'record', end: /[{;=]/,
illegal: /[^\s:]/,
contains: [
TITLE_MODE,
GENERIC_MODIFIER,
hljs.C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE
]
},
{
// [Attributes("")]

@@ -171,0 +181,0 @@ className: 'meta',

@@ -144,4 +144,4 @@ /**

className: 'class',
beginKeywords: 'class interface', end: /[{;=]/, excludeEnd: true,
keywords: 'class interface',
beginKeywords: 'class interface enum', end: /[{;=]/, excludeEnd: true,
keywords: 'class interface enum',
illegal: /[:"\[\]]/,

@@ -148,0 +148,0 @@ contains: [

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

// the first key:value pairing
/(((\/\/.*)|(\/\*(.|\n)*\*\/))\s*)*/,
/(((\/\/.*$)|(\/\*(.|\n)*\*\/))\s*)*/,
IDENT_RE$1 + '\\s*:'))),

@@ -338,0 +338,0 @@ relevance: 0,

@@ -17,5 +17,3 @@ /*

'interface annotation data sealed internal infix operator out by constructor super ' +
'tailrec where const inner suspend typealias external expect actual ' +
// to be deleted soon
'trait volatile transient native default',
'tailrec where const inner suspend typealias external expect actual',
built_in:

@@ -22,0 +20,0 @@ 'Byte Short Char Int Long Boolean Float Double Void Unit Nothing',

@@ -27,3 +27,3 @@ /*

keyword:
'break case catch classdef continue else elseif end enumerated events for function ' +
'arguments break case catch classdef continue else elseif end enumeration events for function ' +
'global if methods otherwise parfor persistent properties return spmd switch try while',

@@ -30,0 +30,0 @@ built_in:

@@ -85,3 +85,3 @@ /*

keyword:
'Abort AddBrandingImage AddSize AllowRootDirInstall AllowSkipFiles AutoCloseWindow BGFont BGGradient BrandingText BringToFront Call CallInstDLL Caption ChangeUI CheckBitmap ClearErrors CompletedText ComponentText CopyFiles CRCCheck CreateDirectory CreateFont CreateShortCut Delete DeleteINISec DeleteINIStr DeleteRegKey DeleteRegValue DetailPrint DetailsButtonText DirText DirVar DirVerify EnableWindow EnumRegKey EnumRegValue Exch Exec ExecShell ExecShellWait ExecWait ExpandEnvStrings File FileBufSize FileClose FileErrorText FileOpen FileRead FileReadByte FileReadUTF16LE FileReadWord FileSeek FileWrite FileWriteByte FileWriteUTF16LE FileWriteWord FindClose FindFirst FindNext FindWindow FlushINI FunctionEnd GetCurInstType GetCurrentAddress GetDlgItem GetDLLVersion GetDLLVersionLocal GetErrorLevel GetFileTime GetFileTimeLocal GetFullPathName GetFunctionAddress GetInstDirError GetLabelAddress GetTempFileName Goto HideWindow Icon IfAbort IfErrors IfFileExists IfRebootFlag IfSilent InitPluginsDir InstallButtonText InstallColors InstallDir InstallDirRegKey InstProgressFlags InstType InstTypeGetText InstTypeSetText Int64Cmp Int64CmpU Int64Fmt IntCmp IntCmpU IntFmt IntOp IntPtrCmp IntPtrCmpU IntPtrOp IsWindow LangString LicenseBkColor LicenseData LicenseForceSelection LicenseLangString LicenseText LoadLanguageFile LockWindow LogSet LogText ManifestDPIAware ManifestSupportedOS MessageBox MiscButtonText Name Nop OutFile Page PageCallbacks PageExEnd Pop Push Quit ReadEnvStr ReadINIStr ReadRegDWORD ReadRegStr Reboot RegDLL Rename RequestExecutionLevel ReserveFile Return RMDir SearchPath SectionEnd SectionGetFlags SectionGetInstTypes SectionGetSize SectionGetText SectionGroupEnd SectionIn SectionSetFlags SectionSetInstTypes SectionSetSize SectionSetText SendMessage SetAutoClose SetBrandingImage SetCompress SetCompressor SetCompressorDictSize SetCtlColors SetCurInstType SetDatablockOptimize SetDateSave SetDetailsPrint SetDetailsView SetErrorLevel SetErrors SetFileAttributes SetFont SetOutPath SetOverwrite SetRebootFlag SetRegView SetShellVarContext SetSilent ShowInstDetails ShowUninstDetails ShowWindow SilentInstall SilentUnInstall Sleep SpaceTexts StrCmp StrCmpS StrCpy StrLen SubCaption Unicode UninstallButtonText UninstallCaption UninstallIcon UninstallSubCaption UninstallText UninstPage UnRegDLL Var VIAddVersionKey VIFileVersion VIProductVersion WindowIcon WriteINIStr WriteRegBin WriteRegDWORD WriteRegExpandStr WriteRegMultiStr WriteRegNone WriteRegStr WriteUninstaller XPStyle',
'Abort AddBrandingImage AddSize AllowRootDirInstall AllowSkipFiles AutoCloseWindow BGFont BGGradient BrandingText BringToFront Call CallInstDLL Caption ChangeUI CheckBitmap ClearErrors CompletedText ComponentText CopyFiles CRCCheck CreateDirectory CreateFont CreateShortCut Delete DeleteINISec DeleteINIStr DeleteRegKey DeleteRegValue DetailPrint DetailsButtonText DirText DirVar DirVerify EnableWindow EnumRegKey EnumRegValue Exch Exec ExecShell ExecShellWait ExecWait ExpandEnvStrings File FileBufSize FileClose FileErrorText FileOpen FileRead FileReadByte FileReadUTF16LE FileReadWord FileWriteUTF16LE FileSeek FileWrite FileWriteByte FileWriteWord FindClose FindFirst FindNext FindWindow FlushINI GetCurInstType GetCurrentAddress GetDlgItem GetDLLVersion GetDLLVersionLocal GetErrorLevel GetFileTime GetFileTimeLocal GetFullPathName GetFunctionAddress GetInstDirError GetKnownFolderPath GetLabelAddress GetTempFileName Goto HideWindow Icon IfAbort IfErrors IfFileExists IfRebootFlag IfRtlLanguage IfShellVarContextAll IfSilent InitPluginsDir InstallButtonText InstallColors InstallDir InstallDirRegKey InstProgressFlags InstType InstTypeGetText InstTypeSetText Int64Cmp Int64CmpU Int64Fmt IntCmp IntCmpU IntFmt IntOp IntPtrCmp IntPtrCmpU IntPtrOp IsWindow LangString LicenseBkColor LicenseData LicenseForceSelection LicenseLangString LicenseText LoadAndSetImage LoadLanguageFile LockWindow LogSet LogText ManifestDPIAware ManifestLongPathAware ManifestMaxVersionTested ManifestSupportedOS MessageBox MiscButtonText Name Nop OutFile Page PageCallbacks PEAddResource PEDllCharacteristics PERemoveResource PESubsysVer Pop Push Quit ReadEnvStr ReadINIStr ReadRegDWORD ReadRegStr Reboot RegDLL Rename RequestExecutionLevel ReserveFile Return RMDir SearchPath SectionGetFlags SectionGetInstTypes SectionGetSize SectionGetText SectionIn SectionSetFlags SectionSetInstTypes SectionSetSize SectionSetText SendMessage SetAutoClose SetBrandingImage SetCompress SetCompressor SetCompressorDictSize SetCtlColors SetCurInstType SetDatablockOptimize SetDateSave SetDetailsPrint SetDetailsView SetErrorLevel SetErrors SetFileAttributes SetFont SetOutPath SetOverwrite SetRebootFlag SetRegView SetShellVarContext SetSilent ShowInstDetails ShowUninstDetails ShowWindow SilentInstall SilentUnInstall Sleep SpaceTexts StrCmp StrCmpS StrCpy StrLen SubCaption Unicode UninstallButtonText UninstallCaption UninstallIcon UninstallSubCaption UninstallText UninstPage UnRegDLL Var VIAddVersionKey VIFileVersion VIProductVersion WindowIcon WriteINIStr WriteRegBin WriteRegDWORD WriteRegExpandStr WriteRegMultiStr WriteRegNone WriteRegStr WriteUninstaller XPStyle',
literal:

@@ -88,0 +88,0 @@ 'admin all auto both bottom bzip2 colored components current custom directory false force hide highest ifdiff ifnewer instfiles lastused leave left license listonly lzma nevershow none normal notset off on open print right show silent silentlog smooth textonly top true try un.components un.custom un.directory un.instfiles un.license uninstConfirm user Win10 Win7 Win8 WinVista zlib'

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

/**
* @param {HLJSApi} hljs
* @returns {LanguageDetail}
* */
function php(hljs) {

@@ -22,2 +26,21 @@ var VARIABLE = {

};
var SUBST = {
className: 'subst',
variants: [
{ begin: /\$\w+/ },
{ begin: /\{\$/, end: /\}/ }
]
};
var SINGLE_QUOTED = hljs.inherit(hljs.APOS_STRING_MODE, {
illegal: null,
});
var DOUBLE_QUOTED = hljs.inherit(hljs.QUOTE_STRING_MODE, {
illegal: null,
contains: hljs.QUOTE_STRING_MODE.contains.concat(SUBST),
});
var HEREDOC = hljs.END_SAME_AS_BEGIN({
begin: /<<<[ \t]*(\w+)\n/,
end: /[ \t]*(\w+)\b/,
contains: hljs.QUOTE_STRING_MODE.contains.concat(SUBST),
});
var STRING = {

@@ -27,10 +50,11 @@ className: 'string',

variants: [
{
begin: 'b"', end: '"'
},
{
begin: 'b\'', end: '\''
},
hljs.inherit(hljs.APOS_STRING_MODE, {illegal: null}),
hljs.inherit(hljs.QUOTE_STRING_MODE, {illegal: null})
hljs.inherit(SINGLE_QUOTED, {
begin: "b'", end: "'",
}),
hljs.inherit(DOUBLE_QUOTED, {
begin: 'b"', end: '"',
}),
DOUBLE_QUOTED,
SINGLE_QUOTED,
HEREDOC
]

@@ -93,16 +117,2 @@ };

),
{
className: 'string',
begin: /<<<['"]?\w+['"]?$/, end: /^\w+;?$/,
contains: [
hljs.BACKSLASH_ESCAPE,
{
className: 'subst',
variants: [
{begin: /\$\w+/},
{begin: /\{\$/, end: /\}/}
]
}
]
},
PREPROCESSOR,

@@ -109,0 +119,0 @@ {

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

},
{ // prevent references like module.id from being higlighted as module definitions
{ // prevent references like module.id from being highlighted as module definitions
begin: /module\./,

@@ -347,0 +347,0 @@ keywords: { built_in: 'module' },

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

"homepage": "https://highlightjs.org/",
"version": "10.1.2",
"version": "10.2.0",
"author": {

@@ -1174,4 +1174,4 @@ "name": "Ivan Sagalaev",

"jsdom": "^16.2.2",
"lodash": "^4.17.15",
"mocha": "^8.0.1",
"lodash": "^4.17.19",
"mocha": "^8.1.3",
"rollup": "^2.0.0",

@@ -1178,0 +1178,0 @@ "rollup-plugin-commonjs": "^10.1.0",

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

## Upgrading from Version 9
#### Upgrading to Version 10

@@ -19,7 +19,10 @@ Version 10 is one of the biggest releases in quite some time. If you're

##### Support for older versions
Please see [OLD_VERSIONS.md](https://github.com/highlightjs/highlight.js/blob/master/OLD_VERSIONS.md) for support information.
## Getting Started
The bare minimum for using highlight.js on a web page is linking to the
library along with one of the styles and calling
[`initHighlightingOnLoad`][1]:
library along with one of the styles and calling [`initHighlightingOnLoad`][1]:

@@ -99,2 +102,22 @@ ```html

## Using with Vue.js
Simply register the plugin with Vue:
```js
Vue.use(hljs.vuePlugin);
```
And you'll be provided with a `highlightjs` component for use
in your templates:
```html
<div id="app">
<!-- bind to a data property named `code` -->
<highlightjs autodetect :code="code" />
<!-- or literal code works as well -->
<highlightjs language='javascript' code="var x = 5;" />
</div>
```
## Web Workers

@@ -101,0 +124,0 @@

@@ -0,1 +1,4 @@

// For TS consumers who use Node and don't have dom in their tsconfig lib, import the necessary types here.
/// <reference lib="dom" />
/* Public API */

@@ -8,2 +11,6 @@

interface VuePlugin {
install: (vue: any) => void
}
interface PublicApi {

@@ -28,2 +35,3 @@ highlight: (languageName: string, code: string, ignoreIllegals?: boolean, continuation?: Mode) => HighlightResult

versionString: string
vuePlugin: () => VuePlugin
}

@@ -30,0 +38,0 @@

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