Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small changes in DocType of languages and formatting #4042

Open
wants to merge 97 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
0db0128
formatting and color change, type import
BhJaipal Apr 22, 2024
bd928c0
markup
BhJaipal Apr 22, 2024
b11c39e
DocType correcting
BhJaipal Apr 23, 2024
e1920c9
Update highlight.js
BhJaipal Apr 24, 2024
ec0010b
Update abnf.js
BhJaipal Apr 24, 2024
859d070
Update 1c.js
BhJaipal Apr 24, 2024
d541c4d
Update accesslog.js
BhJaipal Apr 24, 2024
4f18531
Update actionscript.js
BhJaipal Apr 24, 2024
1b40860
Update ada.js
BhJaipal Apr 24, 2024
59bac45
Update angelscript.js
BhJaipal Apr 24, 2024
2b95bcd
Update apache.js
BhJaipal Apr 24, 2024
2b3c1b2
Update applescript.js
BhJaipal Apr 24, 2024
5bf3603
Update arcade.js
BhJaipal Apr 24, 2024
ab416f8
Update arduino.js
BhJaipal Apr 24, 2024
b25eae1
Update armasm.js
BhJaipal Apr 24, 2024
0c10c3c
Update asciidoc.js
BhJaipal Apr 24, 2024
68f27b6
Update aspectj.js
BhJaipal Apr 24, 2024
4419e73
Update autohotkey.js
BhJaipal Apr 24, 2024
5fa7d0c
Update autoit.js
BhJaipal Apr 24, 2024
c69b82b
Update avrasm.js
BhJaipal Apr 24, 2024
646870c
Update awk.js
BhJaipal Apr 24, 2024
f8a266a
Update axapta.js
BhJaipal Apr 24, 2024
2aac412
Update bash.js
BhJaipal Apr 24, 2024
7c2a859
Update bnf.js
BhJaipal Apr 24, 2024
c1a550a
Update basic.js
BhJaipal Apr 24, 2024
aba2198
Update brainfuck.js
BhJaipal Apr 24, 2024
76ff157
Update c.js
BhJaipal Apr 24, 2024
4494c18
Update cal.js
BhJaipal Apr 24, 2024
59068b5
Update capnproto.js
BhJaipal Apr 24, 2024
35597a2
Update ceylon.js
BhJaipal Apr 24, 2024
4d3110c
Update clean.js
BhJaipal Apr 24, 2024
9a23875
Update clojure-repl.js
BhJaipal Apr 24, 2024
cc057d0
Update clojure.js
BhJaipal Apr 24, 2024
6957fa5
Update cmake.js
BhJaipal Apr 24, 2024
e2107c3
Update coffeescript.js
BhJaipal Apr 24, 2024
1623c41
Update coq.js
BhJaipal Apr 24, 2024
7ecf8e4
Update cos.js
BhJaipal Apr 24, 2024
9baede9
Update cpp.js
BhJaipal Apr 24, 2024
78afd56
Update crmsh.js
BhJaipal Apr 24, 2024
0a5d5b8
Update crystal.js
BhJaipal Apr 24, 2024
2e3f80a
Update csharp.js
BhJaipal Apr 24, 2024
7edefa9
Update csp.js
BhJaipal Apr 24, 2024
6d45096
Update css.js
BhJaipal Apr 24, 2024
bb000f0
Update d.js
BhJaipal Apr 24, 2024
5fb013c
Update dart.js
BhJaipal Apr 24, 2024
ea8a16a
Update delphi.js
BhJaipal Apr 24, 2024
0038e30
Update diff.js
BhJaipal Apr 24, 2024
a6be02b
Update django.js
BhJaipal Apr 24, 2024
4e82b8e
Update dns.js
BhJaipal Apr 24, 2024
991035b
Update dockerfile.js
BhJaipal Apr 24, 2024
4800fa3
Update dos.js
BhJaipal Apr 24, 2024
bb6333f
Update dsconfig.js
BhJaipal Apr 24, 2024
a1bbb95
Update dts.js
BhJaipal Apr 24, 2024
e8dc5d3
Update dust.js
BhJaipal Apr 24, 2024
cd5df78
Update ebnf.js
BhJaipal Apr 24, 2024
c2755e7
Update elixir.js
BhJaipal Apr 24, 2024
742d2b0
Update elm.js
BhJaipal Apr 24, 2024
f849750
Update erb.js
BhJaipal Apr 24, 2024
ac256ac
Update erlang-repl.js
BhJaipal Apr 24, 2024
96b0574
Update zephir.js
BhJaipal Apr 24, 2024
106293e
Update erlang.js
BhJaipal Apr 24, 2024
327101e
Update excel.js
BhJaipal Apr 24, 2024
e939352
Update fix.js
BhJaipal Apr 24, 2024
a994ba9
Update flix.js
BhJaipal Apr 24, 2024
bb20954
Update fortran.js
BhJaipal Apr 24, 2024
1b91964
Update fsharp.js
BhJaipal Apr 24, 2024
d22a8ae
Update gams.js
BhJaipal Apr 24, 2024
e46c8ac
Update graphql.js
BhJaipal Apr 24, 2024
54de7fd
Update irpf90.js
BhJaipal Apr 24, 2024
bcc8171
Update java.js
BhJaipal Apr 24, 2024
44eeb8e
Update javascript.js
BhJaipal Apr 24, 2024
9bfe72c
Update latex.js
BhJaipal Apr 24, 2024
350dfa0
Update ldif.js
BhJaipal Apr 24, 2024
31261cc
Update less.js
BhJaipal Apr 24, 2024
a2c8063
Update css-shared.js
BhJaipal Apr 24, 2024
a7b28b8
Update llvm.js
BhJaipal Apr 24, 2024
45b9b5f
Update mathematica.js
BhJaipal Apr 24, 2024
1c5e6bd
Update nestedtext.js
BhJaipal Apr 24, 2024
848fee5
Update nginx.js
BhJaipal Apr 24, 2024
4f76430
Update node-repl.js
BhJaipal Apr 24, 2024
546c565
Update perl.js
BhJaipal Apr 24, 2024
20d3568
Update properties.js
BhJaipal Apr 24, 2024
372af2d
Update r.js
BhJaipal Apr 24, 2024
2e276f3
Update rust.js
BhJaipal Apr 24, 2024
df6ab73
Update sas.js
BhJaipal Apr 24, 2024
91c348d
Update scss.js
BhJaipal Apr 24, 2024
4380279
Update shell.js
BhJaipal Apr 24, 2024
ca32331
Update stylus.js
BhJaipal Apr 24, 2024
c020678
Update swift.js
BhJaipal Apr 24, 2024
59926e3
Update typescript.js
BhJaipal Apr 24, 2024
834981a
Update vbnet.js
BhJaipal Apr 24, 2024
0ff65c9
Update vbscript.js
BhJaipal Apr 24, 2024
c807f54
Update wasm.js
BhJaipal Apr 24, 2024
93c61db
Update wren.js
BhJaipal Apr 24, 2024
8330458
Update xml.js
BhJaipal Apr 24, 2024
76db679
Update xquery.js
BhJaipal Apr 24, 2024
43376f7
Merge branch 'main' into main
BhJaipal May 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/highlight.js
Expand Up @@ -25,7 +25,7 @@ import HTMLInjectionError from "./lib/html_injection_error.js";
@typedef {import('highlight.js').HLJSPlugin} HLJSPlugin
@typedef {import('highlight.js').PluginEvent} PluginEvent
@typedef {import('highlight.js').HLJSOptions} HLJSOptions
@typedef {import('highlight.js').LanguageFn} LanguageFn
@typedef {import('highlight.js').LanguageFn} {import("highlight.js").LanguageFn}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What makes LanguageFn different from all the other types listed here?

Copy link
Author

@BhJaipal BhJaipal Apr 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LanguageFn is type of this function that takes HLJSApi type parameter and returns Language type output

But in DocCommets it wasn't used correctly

/** @type LanguageFn */

It doesn't assign the LanguageFn type to it

So, it should be changed to

/** 
 * @type {import("highlight.js").LanguageFn} 
 */

It will import all types from highlight.js and then we select LanguageFn type from it and assign it to function to assign type in DocComments, type must be put between {} after @type

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What makes LanguageFn different from all the other types listed here?

It was his type
I didn't do anything more, I just correctly type assignment

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole point of @typedef {import('highlight.js').LanguageFn} LanguageFn should be to allow us to use the short names later on in the file - otherwise what's the point in typedef?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole point of @typedef {import('highlight.js').LanguageFn} LanguageFn should be to allow us to use the short names later on in the file - otherwise what's the point in typedef?

I have updated everything as you asked

@typedef {import('highlight.js').HighlightedHTMLElement} HighlightedHTMLElement
@typedef {import('highlight.js').BeforeHighlightContext} BeforeHighlightContext
@typedef {import('highlight.js/private').MatchType} MatchType
Expand All @@ -47,7 +47,7 @@ const MAX_KEYWORD_HITS = 7;
* @param {any} hljs - object that is extended (legacy)
* @returns {HLJSApi}
*/
const HLJS = function(hljs) {
const HLJS = function (hljs) {
// Global internal variables used within the highlight.js library.
/** @type {Record<string, Language>} */
const languages = Object.create(null);
Expand Down Expand Up @@ -574,7 +574,7 @@ const HLJS = function(hljs) {
if (!language.__emitTokens) {
top.matcher.considerAll();

for (;;) {
for (; ;) {
iterations++;
if (resumeScanAtSamePosition) {
// only regexes not matched previously will now be
Expand Down Expand Up @@ -968,7 +968,7 @@ const HLJS = function(hljs) {
*/
function fire(event, args) {
const cb = event;
plugins.forEach(function(plugin) {
plugins.forEach(function (plugin) {
if (plugin[cb]) {
plugin[cb](args);
}
Expand Down Expand Up @@ -1008,8 +1008,8 @@ const HLJS = function(hljs) {
removePlugin
});

hljs.debugMode = function() { SAFE_MODE = false; };
hljs.safeMode = function() { SAFE_MODE = true; };
hljs.debugMode = function () { SAFE_MODE = false; };
hljs.safeMode = function () { SAFE_MODE = true; };
hljs.versionString = packageJSON.version;

hljs.regex = {
Expand Down
596 changes: 299 additions & 297 deletions src/languages/1c.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/languages/abnf.js
Expand Up @@ -6,8 +6,8 @@ Category: syntax
Audit: 2020
*/

/** @type LanguageFn */
export default function(hljs) {
/** @type {import("highlight.js").LanguageFn} */
export default function (hljs) {
const regex = hljs.regex;
const IDENT = /^[a-zA-Z][a-zA-Z0-9-]*/;

Expand Down
4 changes: 2 additions & 2 deletions src/languages/accesslog.js
Expand Up @@ -7,8 +7,8 @@
Audit: 2020
*/

/** @type LanguageFn */
export default function(hljs) {
/** @type {import("highlight.js").LanguageFn} */
export default function (hljs) {
const regex = hljs.regex;
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods
const HTTP_VERBS = [
Expand Down
6 changes: 3 additions & 3 deletions src/languages/actionscript.js
Expand Up @@ -5,8 +5,8 @@ Category: scripting
Audit: 2020
*/

/** @type LanguageFn */
export default function(hljs) {
/** @type {import("highlight.js").LanguageFn} */
export default function (hljs) {
const regex = hljs.regex;
const IDENT_RE = /[a-zA-Z_$][a-zA-Z0-9_$]*/;
const PKG_NAME_RE = regex.concat(
Expand Down Expand Up @@ -83,7 +83,7 @@ export default function(hljs) {

return {
name: 'ActionScript',
aliases: [ 'as' ],
aliases: ['as'],
keywords: {
keyword: KEYWORDS,
literal: LITERALS
Expand Down
58 changes: 29 additions & 29 deletions src/languages/ada.js
Expand Up @@ -17,8 +17,8 @@ Description: Ada is a general-purpose programming language that has great suppor
// xml (broken by Foo : Bar type), elm (broken by Foo : Bar type), vbscript-html (broken by body keyword)
// sql (ada default.txt has a lot of sql keywords)

/** @type LanguageFn */
export default function(hljs) {
/** @type {import("highlight.js").LanguageFn} */
export default function (hljs) {
// Regular expression for Ada numeric literals.
// stolen form the VHDL highlighter

Expand Down Expand Up @@ -210,34 +210,34 @@ export default function(hljs) {
// the title mode below matches only exactly once
returnBegin: true,
contains:
[
COMMENTS,
{
// name of the function/procedure
className: 'title',
begin: '(\\bwith\\s+)?\\b(function|procedure)\\s+',
end: '(\\(|\\s+|$)',
excludeBegin: true,
excludeEnd: true,
illegal: BAD_CHARS
},
// 'self'
// // parameter types
VAR_DECLS,
{
// return type
className: 'type',
begin: '\\breturn\\s+',
end: '(\\s+|;|$)',
keywords: 'return',
excludeBegin: true,
excludeEnd: true,
// we are done with functions
endsParent: true,
illegal: BAD_CHARS
[
COMMENTS,
{
// name of the function/procedure
className: 'title',
begin: '(\\bwith\\s+)?\\b(function|procedure)\\s+',
end: '(\\(|\\s+|$)',
excludeBegin: true,
excludeEnd: true,
illegal: BAD_CHARS
},
// 'self'
// // parameter types
VAR_DECLS,
{
// return type
className: 'type',
begin: '\\breturn\\s+',
end: '(\\s+|;|$)',
keywords: 'return',
excludeBegin: true,
excludeEnd: true,
// we are done with functions
endsParent: true,
illegal: BAD_CHARS

}
]
}
]
},
{
// new type declarations
Expand Down
14 changes: 7 additions & 7 deletions src/languages/angelscript.js
Expand Up @@ -5,8 +5,8 @@ Category: scripting
Website: https://www.angelcode.com/angelscript/
*/

/** @type LanguageFn */
export default function(hljs) {
/** @type {import("highlight.js").LanguageFn} */
export default function (hljs) {
const builtInTypeMode = {
className: 'built_in',
begin: '\\b(void|bool|int8|int16|int32|int64|int|uint8|uint16|uint32|uint64|uint|string|ref|array|double|float|auto|dictionary)'
Expand All @@ -27,8 +27,8 @@ export default function(hljs) {
]
};

builtInTypeMode.contains = [ genericMode ];
objectHandleMode.contains = [ genericMode ];
builtInTypeMode.contains = [genericMode];
objectHandleMode.contains = [genericMode];

const KEYWORDS = [
"for",
Expand Down Expand Up @@ -81,7 +81,7 @@ export default function(hljs) {

return {
name: 'AngelScript',
aliases: [ 'asc' ],
aliases: ['asc'],

keywords: KEYWORDS,

Expand All @@ -94,7 +94,7 @@ export default function(hljs) {
begin: '\'',
end: '\'',
illegal: '\\n',
contains: [ hljs.BACKSLASH_ESCAPE ],
contains: [hljs.BACKSLASH_ESCAPE],
relevance: 0
},

Expand All @@ -110,7 +110,7 @@ export default function(hljs) {
begin: '"',
end: '"',
illegal: '\\n',
contains: [ hljs.BACKSLASH_ESCAPE ],
contains: [hljs.BACKSLASH_ESCAPE],
relevance: 0
},

Expand Down
44 changes: 23 additions & 21 deletions src/languages/apache.js
Expand Up @@ -8,8 +8,8 @@ Category: config, web
Audit: 2020
*/

/** @type LanguageFn */
export default function(hljs) {
/** @type {import("highlight.js").LanguageFn} */
export default function (hljs) {
const NUMBER_REF = {
className: 'number',
begin: /[$%]\d+/
Expand All @@ -28,7 +28,7 @@ export default function(hljs) {
};
return {
name: 'Apache config',
aliases: [ 'apacheconf' ],
aliases: ['apacheconf'],
case_insensitive: true,
contains: [
hljs.HASH_COMMENT_MODE,
Expand All @@ -50,24 +50,26 @@ export default function(hljs) {
relevance: 0,
// keywords aren’t needed for highlighting per se, they only boost relevance
// for a very generally defined mode (starts with a word, ends with line-end
keywords: { _: [
"order",
"deny",
"allow",
"setenv",
"rewriterule",
"rewriteengine",
"rewritecond",
"documentroot",
"sethandler",
"errordocument",
"loadmodule",
"options",
"header",
"listen",
"serverroot",
"servername"
] },
keywords: {
_: [
"order",
"deny",
"allow",
"setenv",
"rewriterule",
"rewriteengine",
"rewritecond",
"documentroot",
"sethandler",
"errordocument",
"loadmodule",
"options",
"header",
"listen",
"serverroot",
"servername"
]
},
starts: {
end: /$/,
relevance: 0,
Expand Down
16 changes: 9 additions & 7 deletions src/languages/applescript.js
Expand Up @@ -6,8 +6,8 @@ Website: https://developer.apple.com/library/archive/documentation/AppleScript/C
Audit: 2020
*/

/** @type LanguageFn */
export default function(hljs) {
/** @type {import("highlight.js").LanguageFn} */
export default function (hljs) {
const regex = hljs.regex;
const STRING = hljs.inherit(
hljs.QUOTE_STRING_MODE, { illegal: null });
Expand All @@ -25,10 +25,12 @@ export default function(hljs) {
const COMMENT_MODE_2 = hljs.COMMENT(
/\(\*/,
/\*\)/,
{ contains: [
'self', // allow nesting
COMMENT_MODE_1
] }
{
contains: [
'self', // allow nesting
COMMENT_MODE_1
]
}
);
const COMMENTS = [
COMMENT_MODE_1,
Expand Down Expand Up @@ -80,7 +82,7 @@ export default function(hljs) {

return {
name: 'AppleScript',
aliases: [ 'osascript' ],
aliases: ['osascript'],
keywords: {
keyword:
'about above after against and around as at back before beginning '
Expand Down
4 changes: 2 additions & 2 deletions src/languages/arcade.js
Expand Up @@ -6,8 +6,8 @@
Description: ArcGIS Arcade is an expression language used in many Esri ArcGIS products such as Pro, Online, Server, Runtime, JavaScript, and Python
*/

/** @type LanguageFn */
export default function(hljs) {
/** @type {import("highlight.js").LanguageFn} */
export default function (hljs) {
const regex = hljs.regex;
const IDENT_RE = '[A-Za-z_][0-9A-Za-z_]*';
const KEYWORDS = {
Expand Down
6 changes: 3 additions & 3 deletions src/languages/arduino.js
Expand Up @@ -8,8 +8,8 @@ Category: system

import cPlusPlus from './cpp.js';

/** @type LanguageFn */
export default function(hljs) {
/** @type {import("highlight.js").LanguageFn} */
export default function (hljs) {
const ARDUINO_KW = {
type: [
"boolean",
Expand Down Expand Up @@ -396,7 +396,7 @@ export default function(hljs) {
kws._hints = ARDUINO_KW._hints;

ARDUINO.name = 'Arduino';
ARDUINO.aliases = [ 'ino' ];
ARDUINO.aliases = ['ino'];
ARDUINO.supersetOf = "cpp";

return ARDUINO;
Expand Down