From e10b80c54a8e115080d6fe8524c31c6adce71b6f Mon Sep 17 00:00:00 2001 From: Loris Witschard Date: Tue, 23 Mar 2021 19:36:11 +0100 Subject: [PATCH 1/3] fix(deps): remove deprecated @types/highlight.js type definitions are included with highlight.js since v10.1.0 --- package-lock.json | 12 +++--------- package.json | 3 +-- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index f2e4ded..c807270 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2443,12 +2443,6 @@ "@babel/types": "^7.3.0" } }, - "@types/highlight.js": { - "version": "9.12.3", - "resolved": "https://registry.npmjs.org/@types/highlight.js/-/highlight.js-9.12.3.tgz", - "integrity": "sha512-pGF/zvYOACZ/gLGWdQH8zSwteQS1epp68yRcVLJMgUck/MjEn/FBYmPub9pXT8C1e4a8YZfHo1CKyV8q1vKUnQ==", - "dev": true - }, "@types/istanbul-lib-coverage": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.1.tgz", @@ -6887,9 +6881,9 @@ } }, "highlight.js": { - "version": "10.0.2", - "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-10.0.2.tgz", - "integrity": "sha512-2gMT2MHU6/2OjAlnaOE2LFdr9dwviDN3Q2lSw7Ois3/5uTtahbgYTkr4EPoY828ps+2eQWiixPTF8+phU6Ofkg==" + "version": "10.7.1", + "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-10.7.1.tgz", + "integrity": "sha512-S6G97tHGqJ/U8DsXcEdnACbirtbx58Bx9CzIVeYli8OuswCfYI/LsXH2EiGcoGio1KAC3x4mmUwulOllJ2ZyRA==" }, "hook-std": { "version": "2.0.0", diff --git a/package.json b/package.json index 665ecf9..06200bb 100644 --- a/package.json +++ b/package.json @@ -99,7 +99,7 @@ "homepage": "https://github.com/felixfbecker/cli-highlight#readme", "dependencies": { "chalk": "^4.0.0", - "highlight.js": "^10.0.0", + "highlight.js": "^10.7.1", "mz": "^2.4.0", "parse5": "^5.1.1", "parse5-htmlparser2-tree-adapter": "^6.0.0", @@ -111,7 +111,6 @@ "@eclass/semantic-release-surge": "^1.0.7", "@sourcegraph/eslint-config": "^0.20.16", "@sourcegraph/prettierrc": "^3.0.3", - "@types/highlight.js": "^9.12.1", "@types/jest": "^24.0.9", "@types/mz": "0.0.32", "@types/node": "^14.14.9", From 59bb2f94edf5c721f8b48807fade9c0ab7208112 Mon Sep 17 00:00:00 2001 From: Loris Witschard Date: Tue, 23 Mar 2021 20:03:38 +0100 Subject: [PATCH 2/3] fix: use new highlight.js API prevents deprecation warnings in console --- src/index.ts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/index.ts b/src/index.ts index 359b8a6..7546aba 100644 --- a/src/index.ts +++ b/src/index.ts @@ -54,14 +54,6 @@ export interface HighlightOptions { */ ignoreIllegals?: boolean - /** - * The continuation is an optional mode stack representing unfinished parsing. When present, - * the function will restart parsing from this state instead of initializing a new one. - * - * See http://highlightjs.readthedocs.io/en/latest/api.html - */ - continuation?: any - /** * Optional array of language names and aliases restricting detection to only those languages. */ @@ -94,7 +86,7 @@ export interface HighlightOptions { export function highlight(code: string, options: HighlightOptions = {}): string { let html: string if (options.language) { - html = hljs.highlight(options.language, code, options.ignoreIllegals, options.continuation).value + html = hljs.highlight(code, { language: options.language, ignoreIllegals: options.ignoreIllegals }).value } else { html = hljs.highlightAuto(code, options.languageSubset).value } From 130d101c315d7adfd41e34f5bbb001c2cbed2627 Mon Sep 17 00:00:00 2001 From: Loris Witschard Date: Sat, 27 Mar 2021 21:31:40 +0100 Subject: [PATCH 3/3] test: update snapshots --- src/test/__snapshots__/test.ts.snap | 448 ++++++++++++++-------------- 1 file changed, 224 insertions(+), 224 deletions(-) diff --git a/src/test/__snapshots__/test.ts.snap b/src/test/__snapshots__/test.ts.snap index a68c0cc..6207a61 100644 --- a/src/test/__snapshots__/test.ts.snap +++ b/src/test/__snapshots__/test.ts.snap @@ -4,7 +4,7 @@ exports[`highlight() should color 1C Enterprise correctly 1`] = ` "#ЗагрузитьИзФайла ext_module.txt // директива 7.7 #Если Клиент ИЛИ НаКлиенте Тогда // инструкции препроцессора &НаКлиентеНаСервереБезКонтекста // директивы компиляции - Функция ТолстыйКлиентОбычноеПриложение(Знач Параметр1 = Неопределено, // комментарий + Функция ТолстыйКлиентОбычноеПриложение(Знач Параметр1 = Неопределено, // комментарий  Параметр2 = \\"\\", ПараметрN = 123.45, ПарамNN) Экспорт // еще комментарий Попытка Результат_Булевы_Значения = Новый Структура(\\"П1, П2\\", Истина, Ложь, NULL, Неопределено); @@ -29,7 +29,7 @@ exports[`highlight() should color 1C Enterprise correctly 1`] = ` КонецПопытки; ~МеткаGOTO: // еще комментарий ВД = ВидДвиженияБухгалтерии.Дебет; - КонецФункции // ТолстыйКлиентОбычноеПриложение() + КонецФункции // ТолстыйКлиентОбычноеПриложение() #КонецЕсли" `; @@ -444,7 +444,7 @@ exports[`highlight() should color BNF correctly 1`] = ` exports[`highlight() should color Bash correctly 1`] = ` "#!/bin/bash - + ###### CONFIG ACCEPTED_HOSTS=\\"/root/.hag_accepted.conf\\" BE_VERBOSE=false @@ -509,10 +509,10 @@ exports[`highlight() should color JSON correctly 1`] = ` exports[`highlight() should color SQL correctly 1`] = ` "-- Create a table -CREATE TABLE \\"topic\\" ( - \\"id\\" serial NOT NULL PRIMARY KEY, - \\"forum_id\\" integer NOT NULL, - \\"subject\\" varchar(255) NOT NULL +CREATE TABLE \\"topic\\" ( + \\"id\\" serial NOT NULL PRIMARY KEY, + \\"forum_id\\" integer NOT NULL, + \\"subject\\" varchar(255) NOT NULL ); " `; @@ -646,11 +646,11 @@ exports[`highlight() should color Zephir correctly 1`] = ` exports[`highlight() should color axapta correctly 1`] = ` "class ExchRateLoadBatch extends RunBaseBatch { ExchRateLoad rbc; - container currencies; - boolean actual; - boolean overwrite; - date beg; - date end; + container currencies; + boolean actual; + boolean overwrite; + date beg; + date end; #define.CurrentVersion(5) @@ -662,9 +662,9 @@ exports[`highlight() should color axapta correctly 1`] = ` #endmacro } -public boolean unpack(container packedClass) { - container base; - boolean ret; +public boolean unpack(container packedClass) { + container base; + boolean ret; Integer version = runbase::getVersion(packedClass); switch (version) { @@ -942,11 +942,11 @@ exports[`highlight() should color cos correctly 1`] = ` /*  * Sub-languages support:  */ -&sql( SELECT * FROM Cinema.Film WHERE Length > 2 ) +&sql( SELECT * FROM Cinema.Film WHERE Length > 2 ) &js<for (var i = 0; i < String(\\"test\\").split(\\"\\").length); ++i) { console.log(i); }> -&html< +&html< <html> <head> <meta name=\\"test\\"/>  <body>Test @@ -963,10 +963,10 @@ exports[`highlight() should color cpp correctly 1`] = ` /* An annoying \\"Hello World\\" example */ for (auto i = 0; i < 0xFFFF; i++) - cout << \\"Hello, World!\\" << endl; + cout << \\"Hello, World!\\" << endl; char c = '\\\\n'; - unordered_map <string, vector<string> > m; + unordered_map > m; m[\\"key\\"] = \\"\\\\\\\\\\\\\\\\\\"; // this is an error return -2e3 + 12l; @@ -990,7 +990,7 @@ exports[`highlight() should color cpp-comment correctly 1`] = ` /* make cpp win deterministically over others with C block comments */ -cout << endl; +cout << endl; " `; @@ -1089,10 +1089,10 @@ exports[`highlight() should color cs correctly 1`] = ` [Obsolete(\\"...\\")] class Program : IInterface { - public static List<int> JustDoIt(int count) + public static List<int> JustDoIt(int count) { Console.WriteLine($\\"Hello {Name}!\\"); - return new List<int>(new int[] { 1, 2, 3 }) + return new List<int>(new int[] { 1, 2, 3 }) } } } @@ -1426,12 +1426,12 @@ exports[`highlight() should color dsconfig correctly 1`] = ` --policy-name \\"Another Client Connection Policy\\" \\\\ --set enabled:true --set evaluation-order-index:100 \\\\ --set 'connection-criteria:User.1 Connection Criteria' \\\\ - --reset maximum-concurrent-connections -# Configure global ACIs + --reset maximum-concurrent-connections +# Configure global ACIs dsconfig set-access-control-handler-prop \\\\ - --add global-aci:'(target=\\"ldap:///cn=config\\")(targetattr=\\"*\\")(version 3.0; acl \\"Allow access to the config tree by cn=admin,c=us\\"; allow(all) groupdn=\\"ldap:///cn=directory administrators,ou=groups,c=us\\";)' \\\\ - --add global-aci:'(target=\\"ldap:///cn=monitor\\")(targetattr=\\"*\\")(version 3.0; acl \\"Allow access to the monitor tree by cn=admin,c=us\\"; allow(all) groupdn=\\"ldap:///cn=directory administrators,ou=groups,c=us\\";)' \\\\ - --remove global-aci:'(target=\\"ldap:///cn=alerts\\")(targetattr=\\"*\\")(version 3.0; acl \\"Allow access to the alerts tree by cn=admin,c=us\\"; allow(all) groupdn=\\"ldap:///cn=directory administrators,ou=groups,c=us\\";)' + --add global-aci:'(target=\\"ldap:///cn=config\\")(targetattr=\\"*\\")(version 3.0; acl \\"Allow access to the config tree by cn=admin,c=us\\"; allow(all) groupdn=\\"ldap:///cn=directory administrators,ou=groups,c=us\\";)' \\\\ + --add global-aci:'(target=\\"ldap:///cn=monitor\\")(targetattr=\\"*\\")(version 3.0; acl \\"Allow access to the monitor tree by cn=admin,c=us\\"; allow(all) groupdn=\\"ldap:///cn=directory administrators,ou=groups,c=us\\";)' \\\\ + --remove global-aci:'(target=\\"ldap:///cn=alerts\\")(targetattr=\\"*\\")(version 3.0; acl \\"Allow access to the alerts tree by cn=admin,c=us\\"; allow(all) groupdn=\\"ldap:///cn=directory administrators,ou=groups,c=us\\";)' # Delete error logger dsconfig delete-log-publisher --publisher-name \\"File-Based Error Logger\\" " @@ -1614,14 +1614,14 @@ view model = exports[`highlight() should color erb correctly 1`] = ` "<%# this is a comment %> -<% @posts.each do |post| %> - <p><%= link_to post.title, post %> -<% end %> +<% @posts.each do |post| %> + <p><%= link_to post.title, post %> +<% end %> -<%- available_things = things.select(&:available?) -%> -<%%- x = 1 + 2 -%%> -<%% value = 'real string #{@value}' %%> -<%%= available_things.inspect %%> +<%- available_things = things.select(&:available?) -%> +<%%- x = 1 + 2 -%%> +<%% value = 'real string #{@value}' %%> +<%%= available_things.inspect %%> " `; @@ -1955,8 +1955,8 @@ N22 G0 X5000 N23 IF [#1 LT 0.370] GOTO 49 N24 X-0.678 Y+.990 N25 G84.3 X-0.1 -N26 #4=#5*COS[45] -N27 #4=#5*SIN[45] +N26 #4=#5*COS[45] +N27 #4=#5*SIN[45] N28 VZOFZ=652.9658 % " @@ -2183,20 +2183,20 @@ exports[`highlight() should color groovy correctly 1`] = ` /**  * description method - * @param cl the closure + * @param cl the closure  */ - void description(Closure cl) { this.description = cl } + void description(Closure cl) { this.description = cl } void version(String name, Closure versionSpec) { def closure = { println \\"hi\\" } as Runnable - MyList ml = [1, 2, [a: 1, b:2,c :3]] + MyList ml = [1, 2, [a: 1, b:2,c :3]] for (ch in \\"name\\") {} // single line comment - DownloadPackage pkg = new DownloadPackage(version: name) + DownloadPackage pkg = new DownloadPackage(version: name) - check that: true + check that: true label: def clone = versionSpec.rehydrate(pkg, pkg, pkg) @@ -2234,7 +2234,7 @@ exports[`highlight() should color handlebars correctly 1`] = ` "<div class=\\"entry\\"> {{!-- only show if author exists --}} {{#if author}} - <h1>{{firstName}} {{lastName}} + <h1>{{firstName}} {{lastName}} {{/if}}  " @@ -2458,17 +2458,17 @@ exports[`highlight() should color htmlbars correctly 1`] = ` "<div class=\\"entry\\"> {{!-- only output this author names if an author exists --}} {{#if author}} - {{#playwright-wrapper playwright=author action=(mut author) as |playwright|}} - <h1>{{playwright.firstName}} {{playwright.lastName}} + {{#playwright-wrapper playwright=author action=(mut author) as |playwright|}} + <h1>{{playwright.firstName}} {{playwright.lastName}} {{/playwright-wrapper}} {{/if}} - {{yield}} + {{yield}}  " `; exports[`highlight() should color http correctly 1`] = ` -"POST /task?id=1 HTTP/1.1 +"POST /task?id=1 HTTP/1.1 Host: example.org Content-Type: application/json; charset=utf-8 Content-Length: 137 @@ -2632,7 +2632,7 @@ exports[`highlight() should color java correctly 1`] = ` exports[`highlight() should color javascript correctly 1`] = ` "function $initHighlight(block, cls) { try { - if (cls.search(/\\\\bno\\\\-highlight\\\\b/) != -1) + if (cls.search(/\\\\bno\\\\-highlight\\\\b/) != -1) return process(block, true, 0x0F) + \` class=\\"\${cls}\\"\`; } catch (e) { @@ -2733,17 +2733,17 @@ exports[`highlight() should color julia correctly 1`] = ` # Old-style definitions -immutable Point{T<:AbstractFloat} +immutable Point{T<:AbstractFloat} index::Int x::T y::T end -abstract A +abstract A -type B <: A end +type B <: A end -typealias P Point{Float16} +typealias P Point{Float16} # New-style definitions @@ -2766,7 +2766,7 @@ exports[`highlight() should color julia correctly 1`] = ` using X import Y -importall Z +importall Z export a, b, c @@ -2798,7 +2798,7 @@ exports[`highlight() should color julia correctly 1`] = `  String  \\"\\"\\" - @assert π > e + @assert π > e s = 1.2 変数 = \\"variable\\" @@ -2822,7 +2822,7 @@ exports[`highlight() should color julia correctly 1`] = ` run(\`ls $opt\`) try - ccall(:lib, (Ptr{Void},), Ref{C_NULL}) + ccall(:lib, (Ptr{Void},), Ref{C_NULL}) catch throw(ArgumentError(\\"wat\\")) finally @@ -2946,29 +2946,29 @@ exports[`highlight() should color lasso correctly 1`] = ` exports[`highlight() should color ldif correctly 1`] = ` "# Example LDAP user -dn: uid=user.0,ou=People,dc=example,dc=com -objectClass: top -objectClass: person -objectClass: organizationalPerson -objectClass: inetOrgPerson -givenName: Morris -sn: Day -cn: Morris Day -initials: MD -employeeNumber: 0 -uid: user.0 -mail: user.0@example.com -userPassword: password -telephoneNumber: +1 042 100 3866 -homePhone: +1 039 680 4135 -pager: +1 284 199 0966 -mobile: +1 793 707 0251 -street: 90280 Spruce Street -l: Minneapolis -st: MN -postalCode: 50401 -postalAddress: Morris Day$90280 Spruce Street$Minneapolis, MN 50401 -description: This is the description for Morris Day. +dn: uid=user.0,ou=People,dc=example,dc=com +objectClass: top +objectClass: person +objectClass: organizationalPerson +objectClass: inetOrgPerson +givenName: Morris +sn: Day +cn: Morris Day +initials: MD +employeeNumber: 0 +uid: user.0 +mail: user.0@example.com +userPassword: password +telephoneNumber: +1 042 100 3866 +homePhone: +1 039 680 4135 +pager: +1 284 199 0966 +mobile: +1 793 707 0251 +street: 90280 Spruce Street +l: Minneapolis +st: MN +postalCode: 50401 +postalAddress: Morris Day$90280 Spruce Street$Minneapolis, MN 50401 +description: This is the description for Morris Day. " `; @@ -3002,11 +3002,11 @@ exports[`highlight() should color less correctly 1`] = ` @rhythm: 1.5em; -@media screen and (min-resolution: 2dppx) { +@media screen and (min-resolution: 2dppx) { body {font-size: 125%} } -section > .foo + #bar:hover [href*=\\"less\\"] { +section > .foo + #bar:hover [href*=\\"less\\"] { margin: @rhythm 0 0 @rhythm; padding: calc(5% + 20px); background: #f00ba7 url(http://placehold.alpha-centauri/42.png) no-repeat; @@ -3089,108 +3089,108 @@ exports[`highlight() should color livecodeserver correctly 1`] = ` exports[`highlight() should color livescript correctly 1`] = ` "# take the first n objects from a list -take = (n, [x, ...xs]:list) --> - | n <= 0 => [] - | empty list => [] - | otherwise => [x] ++ take n - 1, xs +take = (n, [x, ...xs]:list) --> + | n <= 0 => [] + | empty list => [] + | otherwise => [x] ++ take n - 1, xs -take 2, [1, 2, 3, 4, 5] +take 2, [1, 2, 3, 4, 5] # Curried functions -take-three = take 3 -take-three [6, 7, 8, 9, 10] +take-three = take 3 +take-three [6, 7, 8, 9, 10] # Function composition -last-three = reverse >> take-three >> reverse -last-three [1 to 8] +last-three = reverse >> take-three >> reverse +last-three [1 to 8] # List comprehensions and piping -t1 = - * id: 1 - name: 'george' - * id: 2 - name: 'mike' - * id: 3 - name: 'donald' - -t2 = - * id: 2 - age: 21 - * id: 1 - age: 20 - * id: 3 - age: 26 -[{id:id1, name, age} - for {id:id1, name} in t1 - for {id:id2, age} in t2 - where id1 is id2] - |> sort-by \\\\id - |> JSON.stringify +t1 = + * id: 1 + name: 'george' + * id: 2 + name: 'mike' + * id: 3 + name: 'donald' + +t2 = + * id: 2 + age: 21 + * id: 1 + age: 20 + * id: 3 + age: 26 +[{id:id1, name, age} + for {id:id1, name} in t1 + for {id:id2, age} in t2 + where id1 is id2] + |> sort-by \\\\id + |> JSON.stringify " `; exports[`highlight() should color llvm correctly 1`] = ` "; ModuleID = 'test.c' -target datalayout = \\"e-m:e-i64:64-f80:128-n8:16:32:64-S128\\" +target datalayout = \\"e-m:e-i64:64-f80:128-n8:16:32:64-S128\\" target triple = \\"x86_64-unknown-linux-gnu\\" -%struct._IO_FILE = type { i32, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, %struct._IO_marker*, %struct._IO_FILE*, i32, i32, i64, i16, i8, [1 x i8], i8*, i64, i8*, i8*, i8*, i8*, i64, i32, [20 x i8] } -%struct._IO_marker = type { %struct._IO_marker*, %struct._IO_FILE*, i32 } -%struct.what = type { i8, i16 } +%struct._IO_FILE = type { i32, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, %struct._IO_marker*, %struct._IO_FILE*, i32, i32, i64, i16, i8, [1 x i8], i8*, i64, i8*, i8*, i8*, i8*, i64, i32, [20 x i8] } +%struct._IO_marker = type { %struct._IO_marker*, %struct._IO_FILE*, i32 } +%struct.what = type { i8, i16 } -@.str = private unnamed_addr constant [6 x i8] c\\"foo()\\\\00\\", align 1 -@e_long = common global i64 0, align 8 +@.str = private unnamed_addr constant [6 x i8] c\\"foo()\\\\00\\", align 1 +@e_long = common global i64 0, align 8 @g_double = common global double 0.000000e+00, align 8 -@.str.1 = private unnamed_addr constant [7 x i8] c\\"oooooh\\\\00\\", align 1 -@func_ptr = common global i32 (...)* null, align 8 +@.str.1 = private unnamed_addr constant [7 x i8] c\\"oooooh\\\\00\\", align 1 +@func_ptr = common global i32 (...)* null, align 8 @stderr = external global %struct._IO_FILE*, align 8 ; Function Attrs: nounwind uwtable -define i32 @foo() #0 { - %1 = call i32 @puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0)) - ret i32 0 +define i32 @foo() #0 { + %1 = call i32 @puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0)) + ret i32 0 } -declare i32 @puts(i8*) #1 +declare i32 @puts(i8*) #1 ; Function Attrs: nounwind uwtable -define i32 @main(i32 %argc, i8** %argv) #0 { - %1 = alloca i32, align 4 - %2 = alloca i32, align 4 - %3 = alloca i8**, align 8 +define i32 @main(i32 %argc, i8** %argv) #0 { + %1 = alloca i32, align 4 + %2 = alloca i32, align 4 + %3 = alloca i8**, align 8 ;