Init project
This commit is contained in:
+1
@@ -0,0 +1 @@
|
||||
../marked/bin/marked.js
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
{
|
||||
"name": "markdowrender",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"node_modules/chokidar": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-5.0.0.tgz",
|
||||
"integrity": "sha512-TQMmc3w+5AxjpL8iIiwebF73dRDF4fBIieAqGn9RGCWaEVwQ6Fb2cGe31Yns0RRIzii5goJ1Y7xbMwo1TxMplw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"readdirp": "^5.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 20.19.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://paulmillr.com/funding/"
|
||||
}
|
||||
},
|
||||
"node_modules/highlight.js": {
|
||||
"version": "11.11.1",
|
||||
"resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-11.11.1.tgz",
|
||||
"integrity": "sha512-Xwwo44whKBVCYoliBQwaPvtd/2tYFkRQtXDWj1nackaV2JPXx3L0+Jvd8/qCJ2p+ML0/XVkJ2q+Mr+UVdpJK5w==",
|
||||
"license": "BSD-3-Clause",
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/marked": {
|
||||
"version": "18.0.4",
|
||||
"resolved": "https://registry.npmjs.org/marked/-/marked-18.0.4.tgz",
|
||||
"integrity": "sha512-c/BTaKzg0G6ezQx97DAkYU7k0HM6ys0FqYeKBL6hlBByZwy+ycA1+f0vDdjMHKKeEjdgkx0GOv9Il6D+85cOqA==",
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"marked": "bin/marked.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 20"
|
||||
}
|
||||
},
|
||||
"node_modules/marked-highlight": {
|
||||
"version": "2.2.4",
|
||||
"resolved": "https://registry.npmjs.org/marked-highlight/-/marked-highlight-2.2.4.tgz",
|
||||
"integrity": "sha512-PZxisNMJDduSjc0q6uvjsnqqHCXc9s0eyzxDO9sB1eNGJnd/H1/Fu+z6g/liC1dfJdFW4SftMwMlLvsBhUPrqQ==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"marked": ">=4 <19"
|
||||
}
|
||||
},
|
||||
"node_modules/minimist": {
|
||||
"version": "1.2.8",
|
||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
|
||||
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/readdirp": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-5.0.0.tgz",
|
||||
"integrity": "sha512-9u/XQ1pvrQtYyMpZe7DXKv2p5CNvyVwzUB6uhLAnQwHMSgKMBR62lc7AHljaeteeHXn11XTAaLLUVZYVZyuRBQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 20.19.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "individual",
|
||||
"url": "https://paulmillr.com/funding/"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2012 Paul Miller (https://paulmillr.com), Elan Shanker
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the “Software”), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
+305
@@ -0,0 +1,305 @@
|
||||
# Chokidar [](https://github.com/paulmillr/chokidar)
|
||||
|
||||
Minimal and efficient cross-platform file watching library
|
||||
|
||||
## Why?
|
||||
|
||||
There are many reasons to prefer Chokidar to raw fs.watch / fs.watchFile in 2026:
|
||||
|
||||
- Events are properly reported
|
||||
- macOS events report filenames
|
||||
- events are not reported twice
|
||||
- changes are reported as add / change / unlink instead of useless `rename`
|
||||
- Atomic writes are supported, using `atomic` option
|
||||
- Some file editors use them
|
||||
- Chunked writes are supported, using `awaitWriteFinish` option
|
||||
- Large files are commonly written in chunks
|
||||
- File / dir filtering is supported
|
||||
- Symbolic links are supported
|
||||
- Recursive watching is always supported, instead of partial when using raw events
|
||||
- Includes a way to limit recursion depth
|
||||
|
||||
Chokidar relies on the Node.js core `fs` module, but when using
|
||||
`fs.watch` and `fs.watchFile` for watching, it normalizes the events it
|
||||
receives, often checking for truth by getting file stats and/or dir contents.
|
||||
The `fs.watch`-based implementation is the default, which
|
||||
avoids polling and keeps CPU usage down. Be advised that chokidar will initiate
|
||||
watchers recursively for everything within scope of the paths that have been
|
||||
specified, so be judicious about not wasting system resources by watching much
|
||||
more than needed. For some cases, `fs.watchFile`, which utilizes polling and uses more resources, is used.
|
||||
|
||||
Made for [Brunch](https://brunch.io/) in 2012,
|
||||
it is now used in [~30 million repositories](https://www.npmjs.com/browse/depended/chokidar) and
|
||||
has proven itself in production environments.
|
||||
|
||||
- **Nov 2025 update:** v5 is out. Makes package ESM-only and increases minimum node.js requirement to v20.
|
||||
- **Sep 2024 update:** v4 is out! It decreases dependency count from 13 to 1, removes
|
||||
support for globs, adds support for ESM / Common.js modules, and bumps minimum node.js version from v8 to v14.
|
||||
Check out [upgrading](#upgrading).
|
||||
|
||||
## Getting started
|
||||
|
||||
Install with npm:
|
||||
|
||||
```sh
|
||||
npm install chokidar
|
||||
```
|
||||
|
||||
Use it in your code:
|
||||
|
||||
```javascript
|
||||
import chokidar from 'chokidar';
|
||||
|
||||
// One-liner for current directory
|
||||
chokidar.watch('.').on('all', (event, path) => {
|
||||
console.log(event, path);
|
||||
});
|
||||
|
||||
// Extended options
|
||||
// ----------------
|
||||
|
||||
// Initialize watcher.
|
||||
const watcher = chokidar.watch('file, dir, or array', {
|
||||
ignored: (path, stats) => stats?.isFile() && !path.endsWith('.js'), // only watch js files
|
||||
persistent: true,
|
||||
});
|
||||
|
||||
// Something to use when events are received.
|
||||
const log = console.log.bind(console);
|
||||
// Add event listeners.
|
||||
watcher
|
||||
.on('add', (path) => log(`File ${path} has been added`))
|
||||
.on('change', (path) => log(`File ${path} has been changed`))
|
||||
.on('unlink', (path) => log(`File ${path} has been removed`));
|
||||
|
||||
// More possible events.
|
||||
watcher
|
||||
.on('addDir', (path) => log(`Directory ${path} has been added`))
|
||||
.on('unlinkDir', (path) => log(`Directory ${path} has been removed`))
|
||||
.on('error', (error) => log(`Watcher error: ${error}`))
|
||||
.on('ready', () => log('Initial scan complete. Ready for changes'))
|
||||
.on('raw', (event, path, details) => {
|
||||
// internal
|
||||
log('Raw event info:', event, path, details);
|
||||
});
|
||||
|
||||
// 'add', 'addDir' and 'change' events also receive stat() results as second
|
||||
// argument when available: https://nodejs.org/api/fs.html#fs_class_fs_stats
|
||||
watcher.on('change', (path, stats) => {
|
||||
if (stats) console.log(`File ${path} changed size to ${stats.size}`);
|
||||
});
|
||||
|
||||
// Watch new files.
|
||||
watcher.add('new-file');
|
||||
watcher.add(['new-file-2', 'new-file-3']);
|
||||
|
||||
// Get list of actual paths being watched on the filesystem
|
||||
let watchedPaths = watcher.getWatched();
|
||||
|
||||
// Un-watch some files.
|
||||
await watcher.unwatch('new-file');
|
||||
|
||||
// Stop watching. The method is async!
|
||||
await watcher.close().then(() => console.log('closed'));
|
||||
|
||||
// Full list of options. See below for descriptions.
|
||||
// Do not use this example!
|
||||
chokidar.watch('file', {
|
||||
persistent: true,
|
||||
|
||||
// ignore .txt files
|
||||
ignored: (file) => file.endsWith('.txt'),
|
||||
// watch only .txt files
|
||||
// ignored: (file, _stats) => _stats?.isFile() && !file.endsWith('.txt'),
|
||||
|
||||
awaitWriteFinish: true, // emit single event when chunked writes are completed
|
||||
atomic: true, // emit proper events when "atomic writes" (mv _tmp file) are used
|
||||
|
||||
// The options also allow specifying custom intervals in ms
|
||||
// awaitWriteFinish: {
|
||||
// stabilityThreshold: 2000,
|
||||
// pollInterval: 100
|
||||
// },
|
||||
// atomic: 100,
|
||||
|
||||
interval: 100,
|
||||
binaryInterval: 300,
|
||||
|
||||
cwd: '.',
|
||||
depth: 99,
|
||||
|
||||
followSymlinks: true,
|
||||
ignoreInitial: false,
|
||||
ignorePermissionErrors: false,
|
||||
usePolling: false,
|
||||
alwaysStat: false,
|
||||
});
|
||||
```
|
||||
|
||||
`chokidar.watch(paths, [options])`
|
||||
|
||||
- `paths` (string or array of strings). Paths to files, dirs to be watched
|
||||
recursively.
|
||||
- `options` (object) Options object as defined below:
|
||||
|
||||
#### Persistence
|
||||
|
||||
- `persistent` (default: `true`). Indicates whether the process
|
||||
should continue to run as long as files are being watched.
|
||||
|
||||
#### Path filtering
|
||||
|
||||
- `ignored` function, regex, or path. Defines files/paths to be ignored.
|
||||
The whole relative or absolute path is tested, not just filename. If a function with two arguments
|
||||
is provided, it gets called twice per path - once with a single argument (the path), second
|
||||
time with two arguments (the path and the
|
||||
[`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats)
|
||||
object of that path).
|
||||
- `ignoreInitial` (default: `false`). If set to `false` then `add`/`addDir` events are also emitted for matching paths while
|
||||
instantiating the watching as chokidar discovers these file paths (before the `ready` event).
|
||||
- `followSymlinks` (default: `true`). When `false`, only the
|
||||
symlinks themselves will be watched for changes instead of following
|
||||
the link references and bubbling events through the link's path.
|
||||
- `cwd` (no default). The base directory from which watch `paths` are to be
|
||||
derived. Paths emitted with events will be relative to this.
|
||||
|
||||
#### Performance
|
||||
|
||||
- `usePolling` (default: `false`).
|
||||
Whether to use fs.watchFile (backed by polling), or fs.watch. If polling
|
||||
leads to high CPU utilization, consider setting this to `false`. It is
|
||||
typically necessary to **set this to `true` to successfully watch files over
|
||||
a network**, and it may be necessary to successfully watch files in other
|
||||
non-standard situations. Setting to `true` explicitly on MacOS overrides the
|
||||
`useFsEvents` default. You may also set the CHOKIDAR_USEPOLLING env variable
|
||||
to true (1) or false (0) in order to override this option.
|
||||
- _Polling-specific settings_ (effective when `usePolling: true`)
|
||||
- `interval` (default: `100`). Interval of file system polling, in milliseconds. You may also
|
||||
set the CHOKIDAR_INTERVAL env variable to override this option.
|
||||
- `binaryInterval` (default: `300`). Interval of file system
|
||||
polling for binary files.
|
||||
([see list of binary extensions](https://github.com/sindresorhus/binary-extensions/blob/master/binary-extensions.json))
|
||||
- `alwaysStat` (default: `false`). If relying upon the
|
||||
[`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats)
|
||||
object that may get passed with `add`, `addDir`, and `change` events, set
|
||||
this to `true` to ensure it is provided even in cases where it wasn't
|
||||
already available from the underlying watch events.
|
||||
- `depth` (default: `undefined`). If set, limits how many levels of
|
||||
subdirectories will be traversed.
|
||||
- `awaitWriteFinish` (default: `false`).
|
||||
By default, the `add` event will fire when a file first appears on disk, before
|
||||
the entire file has been written. Furthermore, in some cases some `change`
|
||||
events will be emitted while the file is being written. In some cases,
|
||||
especially when watching for large files there will be a need to wait for the
|
||||
write operation to finish before responding to a file creation or modification.
|
||||
Setting `awaitWriteFinish` to `true` (or a truthy value) will poll file size,
|
||||
holding its `add` and `change` events until the size does not change for a
|
||||
configurable amount of time. The appropriate duration setting is heavily
|
||||
dependent on the OS and hardware. For accurate detection this parameter should
|
||||
be relatively high, making file watching much less responsive.
|
||||
Use with caution.
|
||||
- _`options.awaitWriteFinish` can be set to an object in order to adjust
|
||||
timing params:_
|
||||
- `awaitWriteFinish.stabilityThreshold` (default: 2000). Amount of time in
|
||||
milliseconds for a file size to remain constant before emitting its event.
|
||||
- `awaitWriteFinish.pollInterval` (default: 100). File size polling interval, in milliseconds.
|
||||
|
||||
#### Errors
|
||||
|
||||
- `ignorePermissionErrors` (default: `false`). Indicates whether to watch files
|
||||
that don't have read permissions if possible. If watching fails due to `EPERM`
|
||||
or `EACCES` with this set to `true`, the errors will be suppressed silently.
|
||||
- `atomic` (default: `true` if `useFsEvents` and `usePolling` are `false`).
|
||||
Automatically filters out artifacts that occur when using editors that use
|
||||
"atomic writes" instead of writing directly to the source file. If a file is
|
||||
re-added within 100 ms of being deleted, Chokidar emits a `change` event
|
||||
rather than `unlink` then `add`. If the default of 100 ms does not work well
|
||||
for you, you can override it by setting `atomic` to a custom value, in
|
||||
milliseconds.
|
||||
|
||||
### Methods & Events
|
||||
|
||||
`chokidar.watch()` produces an instance of `FSWatcher`. Methods of `FSWatcher`:
|
||||
|
||||
- `.add(path / paths)`: Add files, directories for tracking.
|
||||
Takes an array of strings or just one string.
|
||||
- `.on(event, callback)`: Listen for an FS event.
|
||||
Available events: `add`, `addDir`, `change`, `unlink`, `unlinkDir`, `ready`,
|
||||
`raw`, `error`.
|
||||
Additionally `all` is available which gets emitted with the underlying event
|
||||
name and path for every event other than `ready`, `raw`, and `error`. `raw` is internal, use it carefully.
|
||||
- `.unwatch(path / paths)`: Stop watching files or directories.
|
||||
Takes an array of strings or just one string.
|
||||
- `.close()`: **async** Removes all listeners from watched files. Asynchronous, returns Promise. Use with `await` to ensure bugs don't happen.
|
||||
- `.getWatched()`: Returns an object representing all the paths on the file
|
||||
system being watched by this `FSWatcher` instance. The object's keys are all the
|
||||
directories (using absolute paths unless the `cwd` option was used), and the
|
||||
values are arrays of the names of the items contained in each directory.
|
||||
|
||||
### CLI
|
||||
|
||||
Check out third party [chokidar-cli](https://github.com/open-cli-tools/chokidar-cli),
|
||||
which allows to execute a command on each change, or get a stdio stream of change events.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
Sometimes, Chokidar runs out of file handles, causing `EMFILE` and `ENOSP` errors:
|
||||
|
||||
- `bash: cannot set terminal process group (-1): Inappropriate ioctl for device bash: no job control in this shell`
|
||||
- `Error: watch /home/ ENOSPC`
|
||||
|
||||
There are two things that can cause it.
|
||||
|
||||
1. Exhausted file handles for generic fs operations
|
||||
- Can be solved by using [graceful-fs](https://www.npmjs.com/package/graceful-fs),
|
||||
which can monkey-patch native `fs` module used by chokidar: `let fs = require('fs'); let grfs = require('graceful-fs'); grfs.gracefulify(fs);`
|
||||
- Can also be solved by tuning OS: `echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p`.
|
||||
2. Exhausted file handles for `fs.watch`
|
||||
- Can't seem to be solved by graceful-fs or OS tuning
|
||||
- It's possible to start using `usePolling: true`, which will switch backend to resource-intensive `fs.watchFile`
|
||||
|
||||
All fsevents-related issues (`WARN optional dep failed`, `fsevents is not a constructor`) are solved by upgrading to v4+.
|
||||
|
||||
## Changelog
|
||||
|
||||
- **v4 (Sep 2024):** remove glob support and bundled fsevents. Decrease dependency count from 13 to 1. Rewrite in typescript. Bumps minimum node.js requirement to v14+
|
||||
- **v3 (Apr 2019):** massive CPU & RAM consumption improvements; reduces deps / package size by a factor of 17x and bumps Node.js requirement to v8.16+.
|
||||
- **v2 (Dec 2017):** globs are now posix-style-only. Tons of bugfixes.
|
||||
- **v1 (Apr 2015):** glob support, symlink support, tons of bugfixes. Node 0.8+ is supported
|
||||
- **v0.1 (Apr 2012):** Initial release, extracted from [Brunch](https://github.com/brunch/brunch/blob/9847a065aea300da99bd0753f90354cde9de1261/src/helpers.coffee#L66)
|
||||
|
||||
### Upgrading
|
||||
|
||||
If you've used globs before and want do replicate the functionality with v4:
|
||||
|
||||
```js
|
||||
// v3
|
||||
chok.watch('**/*.js');
|
||||
chok.watch('./directory/**/*');
|
||||
|
||||
// v4
|
||||
chok.watch('.', {
|
||||
ignored: (path, stats) => stats?.isFile() && !path.endsWith('.js'), // only watch js files
|
||||
});
|
||||
chok.watch('./directory');
|
||||
|
||||
// other way
|
||||
import { glob } from 'node:fs/promises';
|
||||
const watcher = watch(await Array.fromAsync(glob('**/*.js')));
|
||||
|
||||
// unwatching
|
||||
// v3
|
||||
chok.unwatch('**/*.js');
|
||||
// v4
|
||||
chok.unwatch(await Array.fromAsync(glob('**/*.js')));
|
||||
```
|
||||
|
||||
## Also
|
||||
|
||||
Why was chokidar named this way? What's the meaning behind it?
|
||||
|
||||
> Chowkidar is a transliteration of a Hindi word meaning 'watchman, gatekeeper', चौकीदार. This ultimately comes from Sanskrit _ चतुष्क_ (crossway, quadrangle, consisting-of-four). This word is also used in other languages like Urdu as (چوکیدار) which is widely used in Pakistan and India.
|
||||
|
||||
## License
|
||||
|
||||
MIT (c) Paul Miller (<https://paulmillr.com>), see [LICENSE](LICENSE) file.
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
import type { FSWatcher as NativeFsWatcher, Stats, WatchEventType } from 'node:fs';
|
||||
import type { EntryInfo } from 'readdirp';
|
||||
import type { FSWatcher, Throttler, WatchHelper } from './index.js';
|
||||
export type Path = string;
|
||||
export declare const STR_DATA = "data";
|
||||
export declare const STR_END = "end";
|
||||
export declare const STR_CLOSE = "close";
|
||||
export declare const EMPTY_FN: () => void;
|
||||
export declare const IDENTITY_FN: (val: unknown) => unknown;
|
||||
export declare const isWindows: boolean;
|
||||
export declare const isMacos: boolean;
|
||||
export declare const isLinux: boolean;
|
||||
export declare const isFreeBSD: boolean;
|
||||
export declare const isIBMi: boolean;
|
||||
export declare const EVENTS: {
|
||||
readonly ALL: "all";
|
||||
readonly READY: "ready";
|
||||
readonly ADD: "add";
|
||||
readonly CHANGE: "change";
|
||||
readonly ADD_DIR: "addDir";
|
||||
readonly UNLINK: "unlink";
|
||||
readonly UNLINK_DIR: "unlinkDir";
|
||||
readonly RAW: "raw";
|
||||
readonly ERROR: "error";
|
||||
};
|
||||
export type EventName = (typeof EVENTS)[keyof typeof EVENTS];
|
||||
export type FsWatchContainer = {
|
||||
listeners: (path: string) => void | Set<any>;
|
||||
errHandlers: (err: unknown) => void | Set<any>;
|
||||
rawEmitters: (ev: WatchEventType, path: string, opts: unknown) => void | Set<any>;
|
||||
watcher: NativeFsWatcher;
|
||||
watcherUnusable?: boolean;
|
||||
};
|
||||
export interface WatchHandlers {
|
||||
listener: (path: string) => void;
|
||||
errHandler: (err: unknown) => void;
|
||||
rawEmitter: (ev: WatchEventType, path: string, opts: unknown) => void;
|
||||
}
|
||||
/**
|
||||
* @mixin
|
||||
*/
|
||||
export declare class NodeFsHandler {
|
||||
fsw: FSWatcher;
|
||||
_boundHandleError: (error: unknown) => void;
|
||||
constructor(fsW: FSWatcher);
|
||||
/**
|
||||
* Watch file for changes with fs_watchFile or fs_watch.
|
||||
* @param path to file or dir
|
||||
* @param listener on fs change
|
||||
* @returns closer for the watcher instance
|
||||
*/
|
||||
_watchWithNodeFs(path: string, listener: (path: string, newStats?: any) => void | Promise<void>): (() => void) | undefined;
|
||||
/**
|
||||
* Watch a file and emit add event if warranted.
|
||||
* @returns closer for the watcher instance
|
||||
*/
|
||||
_handleFile(file: Path, stats: Stats, initialAdd: boolean): (() => void) | undefined;
|
||||
/**
|
||||
* Handle symlinks encountered while reading a dir.
|
||||
* @param entry returned by readdirp
|
||||
* @param directory path of dir being read
|
||||
* @param path of this item
|
||||
* @param item basename of this item
|
||||
* @returns true if no more processing is needed for this entry.
|
||||
*/
|
||||
_handleSymlink(entry: EntryInfo, directory: string, path: Path, item: string): Promise<boolean | undefined>;
|
||||
_handleRead(directory: string, initialAdd: boolean, wh: WatchHelper, target: Path | undefined, dir: Path, depth: number, throttler: Throttler): Promise<unknown> | undefined;
|
||||
/**
|
||||
* Read directory to add / remove files from `@watched` list and re-read it on change.
|
||||
* @param dir fs path
|
||||
* @param stats
|
||||
* @param initialAdd
|
||||
* @param depth relative to user-supplied path
|
||||
* @param target child path targeted for watch
|
||||
* @param wh Common watch helpers for this path
|
||||
* @param realpath
|
||||
* @returns closer for the watcher instance.
|
||||
*/
|
||||
_handleDir(dir: string, stats: Stats, initialAdd: boolean, depth: number, target: string | undefined, wh: WatchHelper, realpath: string): Promise<(() => void) | undefined>;
|
||||
/**
|
||||
* Handle added file, directory, or glob pattern.
|
||||
* Delegates call to _handleFile / _handleDir after checks.
|
||||
* @param path to file or ir
|
||||
* @param initialAdd was the file added at watch instantiation?
|
||||
* @param priorWh depth relative to user-supplied path
|
||||
* @param depth Child path actually targeted for watch
|
||||
* @param target Child path actually targeted for watch
|
||||
*/
|
||||
_addToNodeFs(path: string, initialAdd: boolean, priorWh: WatchHelper | undefined, depth: number, target?: string): Promise<string | false | undefined>;
|
||||
}
|
||||
+632
@@ -0,0 +1,632 @@
|
||||
import { watch as fs_watch, unwatchFile, watchFile } from 'node:fs';
|
||||
import { realpath as fsrealpath, lstat, open, stat } from 'node:fs/promises';
|
||||
import { type as osType } from 'node:os';
|
||||
import * as sp from 'node:path';
|
||||
export const STR_DATA = 'data';
|
||||
export const STR_END = 'end';
|
||||
export const STR_CLOSE = 'close';
|
||||
export const EMPTY_FN = () => { };
|
||||
export const IDENTITY_FN = (val) => val;
|
||||
const pl = process.platform;
|
||||
export const isWindows = pl === 'win32';
|
||||
export const isMacos = pl === 'darwin';
|
||||
export const isLinux = pl === 'linux';
|
||||
export const isFreeBSD = pl === 'freebsd';
|
||||
export const isIBMi = osType() === 'OS400';
|
||||
export const EVENTS = {
|
||||
ALL: 'all',
|
||||
READY: 'ready',
|
||||
ADD: 'add',
|
||||
CHANGE: 'change',
|
||||
ADD_DIR: 'addDir',
|
||||
UNLINK: 'unlink',
|
||||
UNLINK_DIR: 'unlinkDir',
|
||||
RAW: 'raw',
|
||||
ERROR: 'error',
|
||||
};
|
||||
const EV = EVENTS;
|
||||
const THROTTLE_MODE_WATCH = 'watch';
|
||||
const statMethods = { lstat, stat };
|
||||
const KEY_LISTENERS = 'listeners';
|
||||
const KEY_ERR = 'errHandlers';
|
||||
const KEY_RAW = 'rawEmitters';
|
||||
const HANDLER_KEYS = [KEY_LISTENERS, KEY_ERR, KEY_RAW];
|
||||
// prettier-ignore
|
||||
const binaryExtensions = new Set([
|
||||
'3dm', '3ds', '3g2', '3gp', '7z', 'a', 'aac', 'adp', 'afdesign', 'afphoto', 'afpub', 'ai',
|
||||
'aif', 'aiff', 'alz', 'ape', 'apk', 'appimage', 'ar', 'arj', 'asf', 'au', 'avi',
|
||||
'bak', 'baml', 'bh', 'bin', 'bk', 'bmp', 'btif', 'bz2', 'bzip2',
|
||||
'cab', 'caf', 'cgm', 'class', 'cmx', 'cpio', 'cr2', 'cur', 'dat', 'dcm', 'deb', 'dex', 'djvu',
|
||||
'dll', 'dmg', 'dng', 'doc', 'docm', 'docx', 'dot', 'dotm', 'dra', 'DS_Store', 'dsk', 'dts',
|
||||
'dtshd', 'dvb', 'dwg', 'dxf',
|
||||
'ecelp4800', 'ecelp7470', 'ecelp9600', 'egg', 'eol', 'eot', 'epub', 'exe',
|
||||
'f4v', 'fbs', 'fh', 'fla', 'flac', 'flatpak', 'fli', 'flv', 'fpx', 'fst', 'fvt',
|
||||
'g3', 'gh', 'gif', 'graffle', 'gz', 'gzip',
|
||||
'h261', 'h263', 'h264', 'icns', 'ico', 'ief', 'img', 'ipa', 'iso',
|
||||
'jar', 'jpeg', 'jpg', 'jpgv', 'jpm', 'jxr', 'key', 'ktx',
|
||||
'lha', 'lib', 'lvp', 'lz', 'lzh', 'lzma', 'lzo',
|
||||
'm3u', 'm4a', 'm4v', 'mar', 'mdi', 'mht', 'mid', 'midi', 'mj2', 'mka', 'mkv', 'mmr', 'mng',
|
||||
'mobi', 'mov', 'movie', 'mp3',
|
||||
'mp4', 'mp4a', 'mpeg', 'mpg', 'mpga', 'mxu',
|
||||
'nef', 'npx', 'numbers', 'nupkg',
|
||||
'o', 'odp', 'ods', 'odt', 'oga', 'ogg', 'ogv', 'otf', 'ott',
|
||||
'pages', 'pbm', 'pcx', 'pdb', 'pdf', 'pea', 'pgm', 'pic', 'png', 'pnm', 'pot', 'potm',
|
||||
'potx', 'ppa', 'ppam',
|
||||
'ppm', 'pps', 'ppsm', 'ppsx', 'ppt', 'pptm', 'pptx', 'psd', 'pya', 'pyc', 'pyo', 'pyv',
|
||||
'qt',
|
||||
'rar', 'ras', 'raw', 'resources', 'rgb', 'rip', 'rlc', 'rmf', 'rmvb', 'rpm', 'rtf', 'rz',
|
||||
's3m', 's7z', 'scpt', 'sgi', 'shar', 'snap', 'sil', 'sketch', 'slk', 'smv', 'snk', 'so',
|
||||
'stl', 'suo', 'sub', 'swf',
|
||||
'tar', 'tbz', 'tbz2', 'tga', 'tgz', 'thmx', 'tif', 'tiff', 'tlz', 'ttc', 'ttf', 'txz',
|
||||
'udf', 'uvh', 'uvi', 'uvm', 'uvp', 'uvs', 'uvu',
|
||||
'viv', 'vob',
|
||||
'war', 'wav', 'wax', 'wbmp', 'wdp', 'weba', 'webm', 'webp', 'whl', 'wim', 'wm', 'wma',
|
||||
'wmv', 'wmx', 'woff', 'woff2', 'wrm', 'wvx',
|
||||
'xbm', 'xif', 'xla', 'xlam', 'xls', 'xlsb', 'xlsm', 'xlsx', 'xlt', 'xltm', 'xltx', 'xm',
|
||||
'xmind', 'xpi', 'xpm', 'xwd', 'xz',
|
||||
'z', 'zip', 'zipx',
|
||||
]);
|
||||
const isBinaryPath = (filePath) => binaryExtensions.has(sp.extname(filePath).slice(1).toLowerCase());
|
||||
// TODO: emit errors properly. Example: EMFILE on Macos.
|
||||
const foreach = (val, fn) => {
|
||||
if (val instanceof Set) {
|
||||
val.forEach(fn);
|
||||
}
|
||||
else {
|
||||
fn(val);
|
||||
}
|
||||
};
|
||||
const addAndConvert = (main, prop, item) => {
|
||||
let container = main[prop];
|
||||
if (!(container instanceof Set)) {
|
||||
main[prop] = container = new Set([container]);
|
||||
}
|
||||
container.add(item);
|
||||
};
|
||||
const clearItem = (cont) => (key) => {
|
||||
const set = cont[key];
|
||||
if (set instanceof Set) {
|
||||
set.clear();
|
||||
}
|
||||
else {
|
||||
delete cont[key];
|
||||
}
|
||||
};
|
||||
const delFromSet = (main, prop, item) => {
|
||||
const container = main[prop];
|
||||
if (container instanceof Set) {
|
||||
container.delete(item);
|
||||
}
|
||||
else if (container === item) {
|
||||
delete main[prop];
|
||||
}
|
||||
};
|
||||
const isEmptySet = (val) => (val instanceof Set ? val.size === 0 : !val);
|
||||
const FsWatchInstances = new Map();
|
||||
/**
|
||||
* Instantiates the fs_watch interface
|
||||
* @param path to be watched
|
||||
* @param options to be passed to fs_watch
|
||||
* @param listener main event handler
|
||||
* @param errHandler emits info about errors
|
||||
* @param emitRaw emits raw event data
|
||||
* @returns {NativeFsWatcher}
|
||||
*/
|
||||
function createFsWatchInstance(path, options, listener, errHandler, emitRaw) {
|
||||
const handleEvent = (rawEvent, evPath) => {
|
||||
listener(path);
|
||||
emitRaw(rawEvent, evPath, { watchedPath: path });
|
||||
// emit based on events occurring for files from a directory's watcher in
|
||||
// case the file's watcher misses it (and rely on throttling to de-dupe)
|
||||
if (evPath && path !== evPath) {
|
||||
fsWatchBroadcast(sp.resolve(path, evPath), KEY_LISTENERS, sp.join(path, evPath));
|
||||
}
|
||||
};
|
||||
try {
|
||||
return fs_watch(path, {
|
||||
persistent: options.persistent,
|
||||
}, handleEvent);
|
||||
}
|
||||
catch (error) {
|
||||
errHandler(error);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Helper for passing fs_watch event data to a collection of listeners
|
||||
* @param fullPath absolute path bound to fs_watch instance
|
||||
*/
|
||||
const fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
|
||||
const cont = FsWatchInstances.get(fullPath);
|
||||
if (!cont)
|
||||
return;
|
||||
foreach(cont[listenerType], (listener) => {
|
||||
listener(val1, val2, val3);
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Instantiates the fs_watch interface or binds listeners
|
||||
* to an existing one covering the same file system entry
|
||||
* @param path
|
||||
* @param fullPath absolute path
|
||||
* @param options to be passed to fs_watch
|
||||
* @param handlers container for event listener functions
|
||||
*/
|
||||
const setFsWatchListener = (path, fullPath, options, handlers) => {
|
||||
const { listener, errHandler, rawEmitter } = handlers;
|
||||
let cont = FsWatchInstances.get(fullPath);
|
||||
let watcher;
|
||||
if (!options.persistent) {
|
||||
watcher = createFsWatchInstance(path, options, listener, errHandler, rawEmitter);
|
||||
if (!watcher)
|
||||
return;
|
||||
return watcher.close.bind(watcher);
|
||||
}
|
||||
if (cont) {
|
||||
addAndConvert(cont, KEY_LISTENERS, listener);
|
||||
addAndConvert(cont, KEY_ERR, errHandler);
|
||||
addAndConvert(cont, KEY_RAW, rawEmitter);
|
||||
}
|
||||
else {
|
||||
watcher = createFsWatchInstance(path, options, fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS), errHandler, // no need to use broadcast here
|
||||
fsWatchBroadcast.bind(null, fullPath, KEY_RAW));
|
||||
if (!watcher)
|
||||
return;
|
||||
watcher.on(EV.ERROR, async (error) => {
|
||||
const broadcastErr = fsWatchBroadcast.bind(null, fullPath, KEY_ERR);
|
||||
if (cont)
|
||||
cont.watcherUnusable = true; // documented since Node 10.4.1
|
||||
// Workaround for https://github.com/joyent/node/issues/4337
|
||||
if (isWindows && error.code === 'EPERM') {
|
||||
try {
|
||||
const fd = await open(path, 'r');
|
||||
await fd.close();
|
||||
broadcastErr(error);
|
||||
}
|
||||
catch (err) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
else {
|
||||
broadcastErr(error);
|
||||
}
|
||||
});
|
||||
cont = {
|
||||
listeners: listener,
|
||||
errHandlers: errHandler,
|
||||
rawEmitters: rawEmitter,
|
||||
watcher,
|
||||
};
|
||||
FsWatchInstances.set(fullPath, cont);
|
||||
}
|
||||
// const index = cont.listeners.indexOf(listener);
|
||||
// removes this instance's listeners and closes the underlying fs_watch
|
||||
// instance if there are no more listeners left
|
||||
return () => {
|
||||
delFromSet(cont, KEY_LISTENERS, listener);
|
||||
delFromSet(cont, KEY_ERR, errHandler);
|
||||
delFromSet(cont, KEY_RAW, rawEmitter);
|
||||
if (isEmptySet(cont.listeners)) {
|
||||
// Check to protect against issue gh-730.
|
||||
// if (cont.watcherUnusable) {
|
||||
cont.watcher.close();
|
||||
// }
|
||||
FsWatchInstances.delete(fullPath);
|
||||
HANDLER_KEYS.forEach(clearItem(cont));
|
||||
// @ts-ignore
|
||||
cont.watcher = undefined;
|
||||
Object.freeze(cont);
|
||||
}
|
||||
};
|
||||
};
|
||||
// fs_watchFile helpers
|
||||
// object to hold per-process fs_watchFile instances
|
||||
// (may be shared across chokidar FSWatcher instances)
|
||||
const FsWatchFileInstances = new Map();
|
||||
/**
|
||||
* Instantiates the fs_watchFile interface or binds listeners
|
||||
* to an existing one covering the same file system entry
|
||||
* @param path to be watched
|
||||
* @param fullPath absolute path
|
||||
* @param options options to be passed to fs_watchFile
|
||||
* @param handlers container for event listener functions
|
||||
* @returns closer
|
||||
*/
|
||||
const setFsWatchFileListener = (path, fullPath, options, handlers) => {
|
||||
const { listener, rawEmitter } = handlers;
|
||||
let cont = FsWatchFileInstances.get(fullPath);
|
||||
// let listeners = new Set();
|
||||
// let rawEmitters = new Set();
|
||||
const copts = cont && cont.options;
|
||||
if (copts && (copts.persistent < options.persistent || copts.interval > options.interval)) {
|
||||
// "Upgrade" the watcher to persistence or a quicker interval.
|
||||
// This creates some unlikely edge case issues if the user mixes
|
||||
// settings in a very weird way, but solving for those cases
|
||||
// doesn't seem worthwhile for the added complexity.
|
||||
// listeners = cont.listeners;
|
||||
// rawEmitters = cont.rawEmitters;
|
||||
unwatchFile(fullPath);
|
||||
cont = undefined;
|
||||
}
|
||||
if (cont) {
|
||||
addAndConvert(cont, KEY_LISTENERS, listener);
|
||||
addAndConvert(cont, KEY_RAW, rawEmitter);
|
||||
}
|
||||
else {
|
||||
// TODO
|
||||
// listeners.add(listener);
|
||||
// rawEmitters.add(rawEmitter);
|
||||
cont = {
|
||||
listeners: listener,
|
||||
rawEmitters: rawEmitter,
|
||||
options,
|
||||
watcher: watchFile(fullPath, options, (curr, prev) => {
|
||||
foreach(cont.rawEmitters, (rawEmitter) => {
|
||||
rawEmitter(EV.CHANGE, fullPath, { curr, prev });
|
||||
});
|
||||
const currmtime = curr.mtimeMs;
|
||||
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
|
||||
foreach(cont.listeners, (listener) => listener(path, curr));
|
||||
}
|
||||
}),
|
||||
};
|
||||
FsWatchFileInstances.set(fullPath, cont);
|
||||
}
|
||||
// const index = cont.listeners.indexOf(listener);
|
||||
// Removes this instance's listeners and closes the underlying fs_watchFile
|
||||
// instance if there are no more listeners left.
|
||||
return () => {
|
||||
delFromSet(cont, KEY_LISTENERS, listener);
|
||||
delFromSet(cont, KEY_RAW, rawEmitter);
|
||||
if (isEmptySet(cont.listeners)) {
|
||||
FsWatchFileInstances.delete(fullPath);
|
||||
unwatchFile(fullPath);
|
||||
cont.options = cont.watcher = undefined;
|
||||
Object.freeze(cont);
|
||||
}
|
||||
};
|
||||
};
|
||||
/**
|
||||
* @mixin
|
||||
*/
|
||||
export class NodeFsHandler {
|
||||
fsw;
|
||||
_boundHandleError;
|
||||
constructor(fsW) {
|
||||
this.fsw = fsW;
|
||||
this._boundHandleError = (error) => fsW._handleError(error);
|
||||
}
|
||||
/**
|
||||
* Watch file for changes with fs_watchFile or fs_watch.
|
||||
* @param path to file or dir
|
||||
* @param listener on fs change
|
||||
* @returns closer for the watcher instance
|
||||
*/
|
||||
_watchWithNodeFs(path, listener) {
|
||||
const opts = this.fsw.options;
|
||||
const directory = sp.dirname(path);
|
||||
const basename = sp.basename(path);
|
||||
const parent = this.fsw._getWatchedDir(directory);
|
||||
parent.add(basename);
|
||||
const absolutePath = sp.resolve(path);
|
||||
const options = {
|
||||
persistent: opts.persistent,
|
||||
};
|
||||
if (!listener)
|
||||
listener = EMPTY_FN;
|
||||
let closer;
|
||||
if (opts.usePolling) {
|
||||
const enableBin = opts.interval !== opts.binaryInterval;
|
||||
options.interval = enableBin && isBinaryPath(basename) ? opts.binaryInterval : opts.interval;
|
||||
closer = setFsWatchFileListener(path, absolutePath, options, {
|
||||
listener,
|
||||
rawEmitter: this.fsw._emitRaw,
|
||||
});
|
||||
}
|
||||
else {
|
||||
closer = setFsWatchListener(path, absolutePath, options, {
|
||||
listener,
|
||||
errHandler: this._boundHandleError,
|
||||
rawEmitter: this.fsw._emitRaw,
|
||||
});
|
||||
}
|
||||
return closer;
|
||||
}
|
||||
/**
|
||||
* Watch a file and emit add event if warranted.
|
||||
* @returns closer for the watcher instance
|
||||
*/
|
||||
_handleFile(file, stats, initialAdd) {
|
||||
if (this.fsw.closed) {
|
||||
return;
|
||||
}
|
||||
const dirname = sp.dirname(file);
|
||||
const basename = sp.basename(file);
|
||||
const parent = this.fsw._getWatchedDir(dirname);
|
||||
// stats is always present
|
||||
let prevStats = stats;
|
||||
// if the file is already being watched, do nothing
|
||||
if (parent.has(basename))
|
||||
return;
|
||||
const listener = async (path, newStats) => {
|
||||
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
|
||||
return;
|
||||
if (!newStats || newStats.mtimeMs === 0) {
|
||||
try {
|
||||
const newStats = await stat(file);
|
||||
if (this.fsw.closed)
|
||||
return;
|
||||
// Check that change event was not fired because of changed only accessTime.
|
||||
const at = newStats.atimeMs;
|
||||
const mt = newStats.mtimeMs;
|
||||
if (!at || at <= mt || mt !== prevStats.mtimeMs) {
|
||||
this.fsw._emit(EV.CHANGE, file, newStats);
|
||||
}
|
||||
if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats.ino) {
|
||||
this.fsw._closeFile(path);
|
||||
prevStats = newStats;
|
||||
const closer = this._watchWithNodeFs(file, listener);
|
||||
if (closer)
|
||||
this.fsw._addPathCloser(path, closer);
|
||||
}
|
||||
else {
|
||||
prevStats = newStats;
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
// Fix issues where mtime is null but file is still present
|
||||
this.fsw._remove(dirname, basename);
|
||||
}
|
||||
// add is about to be emitted if file not already tracked in parent
|
||||
}
|
||||
else if (parent.has(basename)) {
|
||||
// Check that change event was not fired because of changed only accessTime.
|
||||
const at = newStats.atimeMs;
|
||||
const mt = newStats.mtimeMs;
|
||||
if (!at || at <= mt || mt !== prevStats.mtimeMs) {
|
||||
this.fsw._emit(EV.CHANGE, file, newStats);
|
||||
}
|
||||
prevStats = newStats;
|
||||
}
|
||||
};
|
||||
// kick off the watcher
|
||||
const closer = this._watchWithNodeFs(file, listener);
|
||||
// emit an add event if we're supposed to
|
||||
if (!(initialAdd && this.fsw.options.ignoreInitial) && this.fsw._isntIgnored(file)) {
|
||||
if (!this.fsw._throttle(EV.ADD, file, 0))
|
||||
return;
|
||||
this.fsw._emit(EV.ADD, file, stats);
|
||||
}
|
||||
return closer;
|
||||
}
|
||||
/**
|
||||
* Handle symlinks encountered while reading a dir.
|
||||
* @param entry returned by readdirp
|
||||
* @param directory path of dir being read
|
||||
* @param path of this item
|
||||
* @param item basename of this item
|
||||
* @returns true if no more processing is needed for this entry.
|
||||
*/
|
||||
async _handleSymlink(entry, directory, path, item) {
|
||||
if (this.fsw.closed) {
|
||||
return;
|
||||
}
|
||||
const full = entry.fullPath;
|
||||
const dir = this.fsw._getWatchedDir(directory);
|
||||
if (!this.fsw.options.followSymlinks) {
|
||||
// watch symlink directly (don't follow) and detect changes
|
||||
this.fsw._incrReadyCount();
|
||||
let linkPath;
|
||||
try {
|
||||
linkPath = await fsrealpath(path);
|
||||
}
|
||||
catch (e) {
|
||||
this.fsw._emitReady();
|
||||
return true;
|
||||
}
|
||||
if (this.fsw.closed)
|
||||
return;
|
||||
if (dir.has(item)) {
|
||||
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
||||
this.fsw._symlinkPaths.set(full, linkPath);
|
||||
this.fsw._emit(EV.CHANGE, path, entry.stats);
|
||||
}
|
||||
}
|
||||
else {
|
||||
dir.add(item);
|
||||
this.fsw._symlinkPaths.set(full, linkPath);
|
||||
this.fsw._emit(EV.ADD, path, entry.stats);
|
||||
}
|
||||
this.fsw._emitReady();
|
||||
return true;
|
||||
}
|
||||
// don't follow the same symlink more than once
|
||||
if (this.fsw._symlinkPaths.has(full)) {
|
||||
return true;
|
||||
}
|
||||
this.fsw._symlinkPaths.set(full, true);
|
||||
}
|
||||
_handleRead(directory, initialAdd, wh, target, dir, depth, throttler) {
|
||||
// Normalize the directory name on Windows
|
||||
directory = sp.join(directory, '');
|
||||
const throttleKey = target ? `${directory}:${target}` : directory;
|
||||
throttler = this.fsw._throttle('readdir', throttleKey, 1000);
|
||||
if (!throttler)
|
||||
return;
|
||||
const previous = this.fsw._getWatchedDir(wh.path);
|
||||
const current = new Set();
|
||||
let stream = this.fsw._readdirp(directory, {
|
||||
fileFilter: (entry) => wh.filterPath(entry),
|
||||
directoryFilter: (entry) => wh.filterDir(entry),
|
||||
});
|
||||
if (!stream)
|
||||
return;
|
||||
stream
|
||||
.on(STR_DATA, async (entry) => {
|
||||
if (this.fsw.closed) {
|
||||
stream = undefined;
|
||||
return;
|
||||
}
|
||||
const item = entry.path;
|
||||
let path = sp.join(directory, item);
|
||||
current.add(item);
|
||||
if (entry.stats.isSymbolicLink() &&
|
||||
(await this._handleSymlink(entry, directory, path, item))) {
|
||||
return;
|
||||
}
|
||||
if (this.fsw.closed) {
|
||||
stream = undefined;
|
||||
return;
|
||||
}
|
||||
// Files that present in current directory snapshot
|
||||
// but absent in previous are added to watch list and
|
||||
// emit `add` event.
|
||||
if (item === target || (!target && !previous.has(item))) {
|
||||
this.fsw._incrReadyCount();
|
||||
// ensure relativeness of path is preserved in case of watcher reuse
|
||||
path = sp.join(dir, sp.relative(dir, path));
|
||||
this._addToNodeFs(path, initialAdd, wh, depth + 1);
|
||||
}
|
||||
})
|
||||
.on(EV.ERROR, this._boundHandleError);
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!stream)
|
||||
return reject();
|
||||
stream.once(STR_END, () => {
|
||||
if (this.fsw.closed) {
|
||||
stream = undefined;
|
||||
return;
|
||||
}
|
||||
const wasThrottled = throttler ? throttler.clear() : false;
|
||||
resolve(undefined);
|
||||
// Files that absent in current directory snapshot
|
||||
// but present in previous emit `remove` event
|
||||
// and are removed from @watched[directory].
|
||||
previous
|
||||
.getChildren()
|
||||
.filter((item) => {
|
||||
return item !== directory && !current.has(item);
|
||||
})
|
||||
.forEach((item) => {
|
||||
this.fsw._remove(directory, item);
|
||||
});
|
||||
stream = undefined;
|
||||
// one more time for any missed in case changes came in extremely quickly
|
||||
if (wasThrottled)
|
||||
this._handleRead(directory, false, wh, target, dir, depth, throttler);
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Read directory to add / remove files from `@watched` list and re-read it on change.
|
||||
* @param dir fs path
|
||||
* @param stats
|
||||
* @param initialAdd
|
||||
* @param depth relative to user-supplied path
|
||||
* @param target child path targeted for watch
|
||||
* @param wh Common watch helpers for this path
|
||||
* @param realpath
|
||||
* @returns closer for the watcher instance.
|
||||
*/
|
||||
async _handleDir(dir, stats, initialAdd, depth, target, wh, realpath) {
|
||||
const parentDir = this.fsw._getWatchedDir(sp.dirname(dir));
|
||||
const tracked = parentDir.has(sp.basename(dir));
|
||||
if (!(initialAdd && this.fsw.options.ignoreInitial) && !target && !tracked) {
|
||||
this.fsw._emit(EV.ADD_DIR, dir, stats);
|
||||
}
|
||||
// ensure dir is tracked (harmless if redundant)
|
||||
parentDir.add(sp.basename(dir));
|
||||
this.fsw._getWatchedDir(dir);
|
||||
let throttler;
|
||||
let closer;
|
||||
const oDepth = this.fsw.options.depth;
|
||||
if ((oDepth == null || depth <= oDepth) && !this.fsw._symlinkPaths.has(realpath)) {
|
||||
if (!target) {
|
||||
await this._handleRead(dir, initialAdd, wh, target, dir, depth, throttler);
|
||||
if (this.fsw.closed)
|
||||
return;
|
||||
}
|
||||
closer = this._watchWithNodeFs(dir, (dirPath, stats) => {
|
||||
// if current directory is removed, do nothing
|
||||
if (stats && stats.mtimeMs === 0)
|
||||
return;
|
||||
this._handleRead(dirPath, false, wh, target, dir, depth, throttler);
|
||||
});
|
||||
}
|
||||
return closer;
|
||||
}
|
||||
/**
|
||||
* Handle added file, directory, or glob pattern.
|
||||
* Delegates call to _handleFile / _handleDir after checks.
|
||||
* @param path to file or ir
|
||||
* @param initialAdd was the file added at watch instantiation?
|
||||
* @param priorWh depth relative to user-supplied path
|
||||
* @param depth Child path actually targeted for watch
|
||||
* @param target Child path actually targeted for watch
|
||||
*/
|
||||
async _addToNodeFs(path, initialAdd, priorWh, depth, target) {
|
||||
const ready = this.fsw._emitReady;
|
||||
if (this.fsw._isIgnored(path) || this.fsw.closed) {
|
||||
ready();
|
||||
return false;
|
||||
}
|
||||
const wh = this.fsw._getWatchHelpers(path);
|
||||
if (priorWh) {
|
||||
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
||||
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
||||
}
|
||||
// evaluate what is at the path we're being asked to watch
|
||||
try {
|
||||
const stats = await statMethods[wh.statMethod](wh.watchPath);
|
||||
if (this.fsw.closed)
|
||||
return;
|
||||
if (this.fsw._isIgnored(wh.watchPath, stats)) {
|
||||
ready();
|
||||
return false;
|
||||
}
|
||||
const follow = this.fsw.options.followSymlinks;
|
||||
let closer;
|
||||
if (stats.isDirectory()) {
|
||||
const absPath = sp.resolve(path);
|
||||
const targetPath = follow ? await fsrealpath(path) : path;
|
||||
if (this.fsw.closed)
|
||||
return;
|
||||
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
||||
if (this.fsw.closed)
|
||||
return;
|
||||
// preserve this symlink's target path
|
||||
if (absPath !== targetPath && targetPath !== undefined) {
|
||||
this.fsw._symlinkPaths.set(absPath, targetPath);
|
||||
}
|
||||
}
|
||||
else if (stats.isSymbolicLink()) {
|
||||
const targetPath = follow ? await fsrealpath(path) : path;
|
||||
if (this.fsw.closed)
|
||||
return;
|
||||
const parent = sp.dirname(wh.watchPath);
|
||||
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
||||
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
||||
closer = await this._handleDir(parent, stats, initialAdd, depth, path, wh, targetPath);
|
||||
if (this.fsw.closed)
|
||||
return;
|
||||
// preserve this symlink's target path
|
||||
if (targetPath !== undefined) {
|
||||
this.fsw._symlinkPaths.set(sp.resolve(path), targetPath);
|
||||
}
|
||||
}
|
||||
else {
|
||||
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
||||
}
|
||||
ready();
|
||||
if (closer)
|
||||
this.fsw._addPathCloser(path, closer);
|
||||
return false;
|
||||
}
|
||||
catch (error) {
|
||||
if (this.fsw._handleError(error)) {
|
||||
ready();
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+217
@@ -0,0 +1,217 @@
|
||||
/*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */
|
||||
import { EventEmitter } from 'node:events';
|
||||
import { Stats } from 'node:fs';
|
||||
import { type EntryInfo, type ReaddirpOptions, ReaddirpStream } from 'readdirp';
|
||||
import { EVENTS as EV, type EventName, NodeFsHandler, type Path, type WatchHandlers } from './handler.js';
|
||||
export type AWF = {
|
||||
stabilityThreshold: number;
|
||||
pollInterval: number;
|
||||
};
|
||||
type BasicOpts = {
|
||||
persistent: boolean;
|
||||
ignoreInitial: boolean;
|
||||
followSymlinks: boolean;
|
||||
cwd?: string;
|
||||
usePolling: boolean;
|
||||
interval: number;
|
||||
binaryInterval: number;
|
||||
alwaysStat?: boolean;
|
||||
depth?: number;
|
||||
ignorePermissionErrors: boolean;
|
||||
atomic: boolean | number;
|
||||
};
|
||||
export type Throttler = {
|
||||
timeoutObject: NodeJS.Timeout;
|
||||
clear: () => void;
|
||||
count: number;
|
||||
};
|
||||
export type ChokidarOptions = Partial<BasicOpts & {
|
||||
ignored: Matcher | Matcher[];
|
||||
awaitWriteFinish: boolean | Partial<AWF>;
|
||||
}>;
|
||||
export type FSWInstanceOptions = BasicOpts & {
|
||||
ignored: Matcher[];
|
||||
awaitWriteFinish: false | AWF;
|
||||
};
|
||||
export type ThrottleType = 'readdir' | 'watch' | 'add' | 'remove' | 'change';
|
||||
export type EmitArgs = [path: Path, stats?: Stats];
|
||||
export type EmitErrorArgs = [error: Error, stats?: Stats];
|
||||
export type EmitArgsWithName = [event: EventName, ...EmitArgs];
|
||||
export type MatchFunction = (val: string, stats?: Stats) => boolean;
|
||||
export interface MatcherObject {
|
||||
path: string;
|
||||
recursive?: boolean;
|
||||
}
|
||||
export type Matcher = string | RegExp | MatchFunction | MatcherObject;
|
||||
/**
|
||||
* Directory entry.
|
||||
*/
|
||||
declare class DirEntry {
|
||||
path: Path;
|
||||
_removeWatcher: (dir: string, base: string) => void;
|
||||
items: Set<Path>;
|
||||
constructor(dir: Path, removeWatcher: (dir: string, base: string) => void);
|
||||
add(item: string): void;
|
||||
remove(item: string): Promise<void>;
|
||||
has(item: string): boolean | undefined;
|
||||
getChildren(): string[];
|
||||
dispose(): void;
|
||||
}
|
||||
export declare class WatchHelper {
|
||||
fsw: FSWatcher;
|
||||
path: string;
|
||||
watchPath: string;
|
||||
fullWatchPath: string;
|
||||
dirParts: string[][];
|
||||
followSymlinks: boolean;
|
||||
statMethod: 'stat' | 'lstat';
|
||||
constructor(path: string, follow: boolean, fsw: FSWatcher);
|
||||
entryPath(entry: EntryInfo): Path;
|
||||
filterPath(entry: EntryInfo): boolean;
|
||||
filterDir(entry: EntryInfo): boolean;
|
||||
}
|
||||
export interface FSWatcherEventMap {
|
||||
[EV.READY]: [];
|
||||
[EV.RAW]: Parameters<WatchHandlers['rawEmitter']>;
|
||||
[EV.ERROR]: Parameters<WatchHandlers['errHandler']>;
|
||||
[EV.ALL]: [event: EventName, ...EmitArgs];
|
||||
[EV.ADD]: EmitArgs;
|
||||
[EV.CHANGE]: EmitArgs;
|
||||
[EV.ADD_DIR]: EmitArgs;
|
||||
[EV.UNLINK]: EmitArgs;
|
||||
[EV.UNLINK_DIR]: EmitArgs;
|
||||
}
|
||||
/**
|
||||
* Watches files & directories for changes. Emitted events:
|
||||
* `add`, `addDir`, `change`, `unlink`, `unlinkDir`, `all`, `error`
|
||||
*
|
||||
* new FSWatcher()
|
||||
* .add(directories)
|
||||
* .on('add', path => log('File', path, 'was added'))
|
||||
*/
|
||||
export declare class FSWatcher extends EventEmitter<FSWatcherEventMap> {
|
||||
closed: boolean;
|
||||
options: FSWInstanceOptions;
|
||||
_closers: Map<string, Array<any>>;
|
||||
_ignoredPaths: Set<Matcher>;
|
||||
_throttled: Map<ThrottleType, Map<any, any>>;
|
||||
_streams: Set<ReaddirpStream>;
|
||||
_symlinkPaths: Map<Path, string | boolean>;
|
||||
_watched: Map<string, DirEntry>;
|
||||
_pendingWrites: Map<string, any>;
|
||||
_pendingUnlinks: Map<string, EmitArgsWithName>;
|
||||
_readyCount: number;
|
||||
_emitReady: () => void;
|
||||
_closePromise?: Promise<void>;
|
||||
_userIgnored?: MatchFunction;
|
||||
_readyEmitted: boolean;
|
||||
_emitRaw: WatchHandlers['rawEmitter'];
|
||||
_boundRemove: (dir: string, item: string) => void;
|
||||
_nodeFsHandler: NodeFsHandler;
|
||||
constructor(_opts?: ChokidarOptions);
|
||||
_addIgnoredPath(matcher: Matcher): void;
|
||||
_removeIgnoredPath(matcher: Matcher): void;
|
||||
/**
|
||||
* Adds paths to be watched on an existing FSWatcher instance.
|
||||
* @param paths_ file or file list. Other arguments are unused
|
||||
*/
|
||||
add(paths_: Path | Path[], _origAdd?: string, _internal?: boolean): FSWatcher;
|
||||
/**
|
||||
* Close watchers or start ignoring events from specified paths.
|
||||
*/
|
||||
unwatch(paths_: Path | Path[]): FSWatcher;
|
||||
/**
|
||||
* Close watchers and remove all listeners from watched paths.
|
||||
*/
|
||||
close(): Promise<void>;
|
||||
/**
|
||||
* Expose list of watched paths
|
||||
* @returns for chaining
|
||||
*/
|
||||
getWatched(): Record<string, string[]>;
|
||||
emitWithAll(event: EventName, args: EmitArgs): void;
|
||||
/**
|
||||
* Normalize and emit events.
|
||||
* Calling _emit DOES NOT MEAN emit() would be called!
|
||||
* @param event Type of event
|
||||
* @param path File or directory path
|
||||
* @param stats arguments to be passed with event
|
||||
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
||||
*/
|
||||
_emit(event: EventName, path: Path, stats?: Stats): Promise<this | undefined>;
|
||||
/**
|
||||
* Common handler for errors
|
||||
* @returns The error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
||||
*/
|
||||
_handleError(error: Error): Error | boolean;
|
||||
/**
|
||||
* Helper utility for throttling
|
||||
* @param actionType type being throttled
|
||||
* @param path being acted upon
|
||||
* @param timeout duration of time to suppress duplicate actions
|
||||
* @returns tracking object or false if action should be suppressed
|
||||
*/
|
||||
_throttle(actionType: ThrottleType, path: Path, timeout: number): Throttler | false;
|
||||
_incrReadyCount(): number;
|
||||
/**
|
||||
* Awaits write operation to finish.
|
||||
* Polls a newly created file for size variations. When files size does not change for 'threshold' milliseconds calls callback.
|
||||
* @param path being acted upon
|
||||
* @param threshold Time in milliseconds a file size must be fixed before acknowledging write OP is finished
|
||||
* @param event
|
||||
* @param awfEmit Callback to be called when ready for event to be emitted.
|
||||
*/
|
||||
_awaitWriteFinish(path: Path, threshold: number, event: EventName, awfEmit: (err?: Error, stat?: Stats) => void): void;
|
||||
/**
|
||||
* Determines whether user has asked to ignore this path.
|
||||
*/
|
||||
_isIgnored(path: Path, stats?: Stats): boolean;
|
||||
_isntIgnored(path: Path, stat?: Stats): boolean;
|
||||
/**
|
||||
* Provides a set of common helpers and properties relating to symlink handling.
|
||||
* @param path file or directory pattern being watched
|
||||
*/
|
||||
_getWatchHelpers(path: Path): WatchHelper;
|
||||
/**
|
||||
* Provides directory tracking objects
|
||||
* @param directory path of the directory
|
||||
*/
|
||||
_getWatchedDir(directory: string): DirEntry;
|
||||
/**
|
||||
* Check for read permissions: https://stackoverflow.com/a/11781404/1358405
|
||||
*/
|
||||
_hasReadPermissions(stats: Stats): boolean;
|
||||
/**
|
||||
* Handles emitting unlink events for
|
||||
* files and directories, and via recursion, for
|
||||
* files and directories within directories that are unlinked
|
||||
* @param directory within which the following item is located
|
||||
* @param item base path of item/directory
|
||||
*/
|
||||
_remove(directory: string, item: string, isDirectory?: boolean): void;
|
||||
/**
|
||||
* Closes all watchers for a path
|
||||
*/
|
||||
_closePath(path: Path): void;
|
||||
/**
|
||||
* Closes only file-specific watchers
|
||||
*/
|
||||
_closeFile(path: Path): void;
|
||||
_addPathCloser(path: Path, closer: () => void): void;
|
||||
_readdirp(root: Path, opts?: Partial<ReaddirpOptions>): ReaddirpStream | undefined;
|
||||
}
|
||||
/**
|
||||
* Instantiates watcher with paths to be tracked.
|
||||
* @param paths file / directory paths
|
||||
* @param options opts, such as `atomic`, `awaitWriteFinish`, `ignored`, and others
|
||||
* @returns an instance of FSWatcher for chaining.
|
||||
* @example
|
||||
* const watcher = watch('.').on('all', (event, path) => { console.log(event, path); });
|
||||
* watch('.', { atomic: true, awaitWriteFinish: true, ignored: (f, stats) => stats?.isFile() && !f.endsWith('.js') })
|
||||
*/
|
||||
export declare function watch(paths: string | string[], options?: ChokidarOptions): FSWatcher;
|
||||
declare const _default: {
|
||||
watch: typeof watch;
|
||||
FSWatcher: typeof FSWatcher;
|
||||
};
|
||||
export default _default;
|
||||
+822
@@ -0,0 +1,822 @@
|
||||
/*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */
|
||||
import { EventEmitter } from 'node:events';
|
||||
import { stat as statcb, Stats } from 'node:fs';
|
||||
import { readdir, stat } from 'node:fs/promises';
|
||||
import * as sp from 'node:path';
|
||||
import { readdirp, ReaddirpStream } from 'readdirp';
|
||||
import { EMPTY_FN, EVENTS as EV, isIBMi, isWindows, NodeFsHandler, STR_CLOSE, STR_END, } from './handler.js';
|
||||
const SLASH = '/';
|
||||
const SLASH_SLASH = '//';
|
||||
const ONE_DOT = '.';
|
||||
const TWO_DOTS = '..';
|
||||
const STRING_TYPE = 'string';
|
||||
const BACK_SLASH_RE = /\\/g;
|
||||
const DOUBLE_SLASH_RE = /\/\//g;
|
||||
const DOT_RE = /\..*\.(sw[px])$|~$|\.subl.*\.tmp/;
|
||||
const REPLACER_RE = /^\.[/\\]/;
|
||||
function arrify(item) {
|
||||
return Array.isArray(item) ? item : [item];
|
||||
}
|
||||
const isMatcherObject = (matcher) => typeof matcher === 'object' && matcher !== null && !(matcher instanceof RegExp);
|
||||
function createPattern(matcher) {
|
||||
if (typeof matcher === 'function')
|
||||
return matcher;
|
||||
if (typeof matcher === 'string')
|
||||
return (string) => matcher === string;
|
||||
if (matcher instanceof RegExp)
|
||||
return (string) => matcher.test(string);
|
||||
if (typeof matcher === 'object' && matcher !== null) {
|
||||
return (string) => {
|
||||
if (matcher.path === string)
|
||||
return true;
|
||||
if (matcher.recursive) {
|
||||
const relative = sp.relative(matcher.path, string);
|
||||
if (!relative) {
|
||||
return false;
|
||||
}
|
||||
return !relative.startsWith('..') && !sp.isAbsolute(relative);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
return () => false;
|
||||
}
|
||||
function normalizePath(path) {
|
||||
if (typeof path !== 'string')
|
||||
throw new Error('string expected');
|
||||
path = sp.normalize(path);
|
||||
path = path.replace(/\\/g, '/');
|
||||
let prepend = false;
|
||||
if (path.startsWith('//'))
|
||||
prepend = true;
|
||||
path = path.replace(DOUBLE_SLASH_RE, '/');
|
||||
if (prepend)
|
||||
path = '/' + path;
|
||||
return path;
|
||||
}
|
||||
function matchPatterns(patterns, testString, stats) {
|
||||
const path = normalizePath(testString);
|
||||
for (let index = 0; index < patterns.length; index++) {
|
||||
const pattern = patterns[index];
|
||||
if (pattern(path, stats)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function anymatch(matchers, testString) {
|
||||
if (matchers == null) {
|
||||
throw new TypeError('anymatch: specify first argument');
|
||||
}
|
||||
// Early cache for matchers.
|
||||
const matchersArray = arrify(matchers);
|
||||
const patterns = matchersArray.map((matcher) => createPattern(matcher));
|
||||
if (testString == null) {
|
||||
return (testString, stats) => {
|
||||
return matchPatterns(patterns, testString, stats);
|
||||
};
|
||||
}
|
||||
return matchPatterns(patterns, testString);
|
||||
}
|
||||
const unifyPaths = (paths_) => {
|
||||
const paths = arrify(paths_).flat();
|
||||
if (!paths.every((p) => typeof p === STRING_TYPE)) {
|
||||
throw new TypeError(`Non-string provided as watch path: ${paths}`);
|
||||
}
|
||||
return paths.map(normalizePathToUnix);
|
||||
};
|
||||
// If SLASH_SLASH occurs at the beginning of path, it is not replaced
|
||||
// because "//StoragePC/DrivePool/Movies" is a valid network path
|
||||
const toUnix = (string) => {
|
||||
let str = string.replace(BACK_SLASH_RE, SLASH);
|
||||
let prepend = false;
|
||||
if (str.startsWith(SLASH_SLASH)) {
|
||||
prepend = true;
|
||||
}
|
||||
str = str.replace(DOUBLE_SLASH_RE, SLASH);
|
||||
if (prepend) {
|
||||
str = SLASH + str;
|
||||
}
|
||||
return str;
|
||||
};
|
||||
// Our version of upath.normalize
|
||||
// TODO: this is not equal to path-normalize module - investigate why
|
||||
const normalizePathToUnix = (path) => toUnix(sp.normalize(toUnix(path)));
|
||||
// TODO: refactor
|
||||
const normalizeIgnored = (cwd = '') => (path) => {
|
||||
if (typeof path === 'string') {
|
||||
return normalizePathToUnix(sp.isAbsolute(path) ? path : sp.join(cwd, path));
|
||||
}
|
||||
else {
|
||||
return path;
|
||||
}
|
||||
};
|
||||
const getAbsolutePath = (path, cwd) => {
|
||||
if (sp.isAbsolute(path)) {
|
||||
return path;
|
||||
}
|
||||
return sp.join(cwd, path);
|
||||
};
|
||||
const EMPTY_SET = Object.freeze(new Set());
|
||||
/**
|
||||
* Directory entry.
|
||||
*/
|
||||
class DirEntry {
|
||||
path;
|
||||
_removeWatcher;
|
||||
items;
|
||||
constructor(dir, removeWatcher) {
|
||||
this.path = dir;
|
||||
this._removeWatcher = removeWatcher;
|
||||
this.items = new Set();
|
||||
}
|
||||
add(item) {
|
||||
const { items } = this;
|
||||
if (!items)
|
||||
return;
|
||||
if (item !== ONE_DOT && item !== TWO_DOTS)
|
||||
items.add(item);
|
||||
}
|
||||
async remove(item) {
|
||||
const { items } = this;
|
||||
if (!items)
|
||||
return;
|
||||
items.delete(item);
|
||||
if (items.size > 0)
|
||||
return;
|
||||
const dir = this.path;
|
||||
try {
|
||||
await readdir(dir);
|
||||
}
|
||||
catch (err) {
|
||||
if (this._removeWatcher) {
|
||||
this._removeWatcher(sp.dirname(dir), sp.basename(dir));
|
||||
}
|
||||
}
|
||||
}
|
||||
has(item) {
|
||||
const { items } = this;
|
||||
if (!items)
|
||||
return;
|
||||
return items.has(item);
|
||||
}
|
||||
getChildren() {
|
||||
const { items } = this;
|
||||
if (!items)
|
||||
return [];
|
||||
return [...items.values()];
|
||||
}
|
||||
dispose() {
|
||||
this.items.clear();
|
||||
this.path = '';
|
||||
this._removeWatcher = EMPTY_FN;
|
||||
this.items = EMPTY_SET;
|
||||
Object.freeze(this);
|
||||
}
|
||||
}
|
||||
const STAT_METHOD_F = 'stat';
|
||||
const STAT_METHOD_L = 'lstat';
|
||||
export class WatchHelper {
|
||||
fsw;
|
||||
path;
|
||||
watchPath;
|
||||
fullWatchPath;
|
||||
dirParts;
|
||||
followSymlinks;
|
||||
statMethod;
|
||||
constructor(path, follow, fsw) {
|
||||
this.fsw = fsw;
|
||||
const watchPath = path;
|
||||
this.path = path = path.replace(REPLACER_RE, '');
|
||||
this.watchPath = watchPath;
|
||||
this.fullWatchPath = sp.resolve(watchPath);
|
||||
this.dirParts = [];
|
||||
this.dirParts.forEach((parts) => {
|
||||
if (parts.length > 1)
|
||||
parts.pop();
|
||||
});
|
||||
this.followSymlinks = follow;
|
||||
this.statMethod = follow ? STAT_METHOD_F : STAT_METHOD_L;
|
||||
}
|
||||
entryPath(entry) {
|
||||
return sp.join(this.watchPath, sp.relative(this.watchPath, entry.fullPath));
|
||||
}
|
||||
filterPath(entry) {
|
||||
const { stats } = entry;
|
||||
if (stats && stats.isSymbolicLink())
|
||||
return this.filterDir(entry);
|
||||
const resolvedPath = this.entryPath(entry);
|
||||
// TODO: what if stats is undefined? remove !
|
||||
return this.fsw._isntIgnored(resolvedPath, stats) && this.fsw._hasReadPermissions(stats);
|
||||
}
|
||||
filterDir(entry) {
|
||||
return this.fsw._isntIgnored(this.entryPath(entry), entry.stats);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Watches files & directories for changes. Emitted events:
|
||||
* `add`, `addDir`, `change`, `unlink`, `unlinkDir`, `all`, `error`
|
||||
*
|
||||
* new FSWatcher()
|
||||
* .add(directories)
|
||||
* .on('add', path => log('File', path, 'was added'))
|
||||
*/
|
||||
export class FSWatcher extends EventEmitter {
|
||||
closed;
|
||||
options;
|
||||
_closers;
|
||||
_ignoredPaths;
|
||||
_throttled;
|
||||
_streams;
|
||||
_symlinkPaths;
|
||||
_watched;
|
||||
_pendingWrites;
|
||||
_pendingUnlinks;
|
||||
_readyCount;
|
||||
_emitReady;
|
||||
_closePromise;
|
||||
_userIgnored;
|
||||
_readyEmitted;
|
||||
_emitRaw;
|
||||
_boundRemove;
|
||||
_nodeFsHandler;
|
||||
// Not indenting methods for history sake; for now.
|
||||
constructor(_opts = {}) {
|
||||
super();
|
||||
this.closed = false;
|
||||
this._closers = new Map();
|
||||
this._ignoredPaths = new Set();
|
||||
this._throttled = new Map();
|
||||
this._streams = new Set();
|
||||
this._symlinkPaths = new Map();
|
||||
this._watched = new Map();
|
||||
this._pendingWrites = new Map();
|
||||
this._pendingUnlinks = new Map();
|
||||
this._readyCount = 0;
|
||||
this._readyEmitted = false;
|
||||
const awf = _opts.awaitWriteFinish;
|
||||
const DEF_AWF = { stabilityThreshold: 2000, pollInterval: 100 };
|
||||
const opts = {
|
||||
// Defaults
|
||||
persistent: true,
|
||||
ignoreInitial: false,
|
||||
ignorePermissionErrors: false,
|
||||
interval: 100,
|
||||
binaryInterval: 300,
|
||||
followSymlinks: true,
|
||||
usePolling: false,
|
||||
// useAsync: false,
|
||||
atomic: true, // NOTE: overwritten later (depends on usePolling)
|
||||
..._opts,
|
||||
// Change format
|
||||
ignored: _opts.ignored ? arrify(_opts.ignored) : arrify([]),
|
||||
awaitWriteFinish: awf === true ? DEF_AWF : typeof awf === 'object' ? { ...DEF_AWF, ...awf } : false,
|
||||
};
|
||||
// Always default to polling on IBM i because fs.watch() is not available on IBM i.
|
||||
if (isIBMi)
|
||||
opts.usePolling = true;
|
||||
// Editor atomic write normalization enabled by default with fs.watch
|
||||
if (opts.atomic === undefined)
|
||||
opts.atomic = !opts.usePolling;
|
||||
// opts.atomic = typeof _opts.atomic === 'number' ? _opts.atomic : 100;
|
||||
// Global override. Useful for developers, who need to force polling for all
|
||||
// instances of chokidar, regardless of usage / dependency depth
|
||||
const envPoll = process.env.CHOKIDAR_USEPOLLING;
|
||||
if (envPoll !== undefined) {
|
||||
const envLower = envPoll.toLowerCase();
|
||||
if (envLower === 'false' || envLower === '0')
|
||||
opts.usePolling = false;
|
||||
else if (envLower === 'true' || envLower === '1')
|
||||
opts.usePolling = true;
|
||||
else
|
||||
opts.usePolling = !!envLower;
|
||||
}
|
||||
const envInterval = process.env.CHOKIDAR_INTERVAL;
|
||||
if (envInterval)
|
||||
opts.interval = Number.parseInt(envInterval, 10);
|
||||
// This is done to emit ready only once, but each 'add' will increase that?
|
||||
let readyCalls = 0;
|
||||
this._emitReady = () => {
|
||||
readyCalls++;
|
||||
if (readyCalls >= this._readyCount) {
|
||||
this._emitReady = EMPTY_FN;
|
||||
this._readyEmitted = true;
|
||||
// use process.nextTick to allow time for listener to be bound
|
||||
process.nextTick(() => this.emit(EV.READY));
|
||||
}
|
||||
};
|
||||
this._emitRaw = (...args) => this.emit(EV.RAW, ...args);
|
||||
this._boundRemove = this._remove.bind(this);
|
||||
this.options = opts;
|
||||
this._nodeFsHandler = new NodeFsHandler(this);
|
||||
// You’re frozen when your heart’s not open.
|
||||
Object.freeze(opts);
|
||||
}
|
||||
_addIgnoredPath(matcher) {
|
||||
if (isMatcherObject(matcher)) {
|
||||
// return early if we already have a deeply equal matcher object
|
||||
for (const ignored of this._ignoredPaths) {
|
||||
if (isMatcherObject(ignored) &&
|
||||
ignored.path === matcher.path &&
|
||||
ignored.recursive === matcher.recursive) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
this._ignoredPaths.add(matcher);
|
||||
}
|
||||
_removeIgnoredPath(matcher) {
|
||||
this._ignoredPaths.delete(matcher);
|
||||
// now find any matcher objects with the matcher as path
|
||||
if (typeof matcher === 'string') {
|
||||
for (const ignored of this._ignoredPaths) {
|
||||
// TODO (43081j): make this more efficient.
|
||||
// probably just make a `this._ignoredDirectories` or some
|
||||
// such thing.
|
||||
if (isMatcherObject(ignored) && ignored.path === matcher) {
|
||||
this._ignoredPaths.delete(ignored);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Public methods
|
||||
/**
|
||||
* Adds paths to be watched on an existing FSWatcher instance.
|
||||
* @param paths_ file or file list. Other arguments are unused
|
||||
*/
|
||||
add(paths_, _origAdd, _internal) {
|
||||
const { cwd } = this.options;
|
||||
this.closed = false;
|
||||
this._closePromise = undefined;
|
||||
let paths = unifyPaths(paths_);
|
||||
if (cwd) {
|
||||
paths = paths.map((path) => {
|
||||
const absPath = getAbsolutePath(path, cwd);
|
||||
// Check `path` instead of `absPath` because the cwd portion can't be a glob
|
||||
return absPath;
|
||||
});
|
||||
}
|
||||
paths.forEach((path) => {
|
||||
this._removeIgnoredPath(path);
|
||||
});
|
||||
this._userIgnored = undefined;
|
||||
if (!this._readyCount)
|
||||
this._readyCount = 0;
|
||||
this._readyCount += paths.length;
|
||||
Promise.all(paths.map(async (path) => {
|
||||
const res = await this._nodeFsHandler._addToNodeFs(path, !_internal, undefined, 0, _origAdd);
|
||||
if (res)
|
||||
this._emitReady();
|
||||
return res;
|
||||
})).then((results) => {
|
||||
if (this.closed)
|
||||
return;
|
||||
results.forEach((item) => {
|
||||
if (item)
|
||||
this.add(sp.dirname(item), sp.basename(_origAdd || item));
|
||||
});
|
||||
});
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Close watchers or start ignoring events from specified paths.
|
||||
*/
|
||||
unwatch(paths_) {
|
||||
if (this.closed)
|
||||
return this;
|
||||
const paths = unifyPaths(paths_);
|
||||
const { cwd } = this.options;
|
||||
paths.forEach((path) => {
|
||||
// convert to absolute path unless relative path already matches
|
||||
if (!sp.isAbsolute(path) && !this._closers.has(path)) {
|
||||
if (cwd)
|
||||
path = sp.join(cwd, path);
|
||||
path = sp.resolve(path);
|
||||
}
|
||||
this._closePath(path);
|
||||
this._addIgnoredPath(path);
|
||||
if (this._watched.has(path)) {
|
||||
this._addIgnoredPath({
|
||||
path,
|
||||
recursive: true,
|
||||
});
|
||||
}
|
||||
// reset the cached userIgnored anymatch fn
|
||||
// to make ignoredPaths changes effective
|
||||
this._userIgnored = undefined;
|
||||
});
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Close watchers and remove all listeners from watched paths.
|
||||
*/
|
||||
close() {
|
||||
if (this._closePromise) {
|
||||
return this._closePromise;
|
||||
}
|
||||
this.closed = true;
|
||||
// Memory management.
|
||||
this.removeAllListeners();
|
||||
const closers = [];
|
||||
this._closers.forEach((closerList) => closerList.forEach((closer) => {
|
||||
const promise = closer();
|
||||
if (promise instanceof Promise)
|
||||
closers.push(promise);
|
||||
}));
|
||||
this._streams.forEach((stream) => stream.destroy());
|
||||
this._userIgnored = undefined;
|
||||
this._readyCount = 0;
|
||||
this._readyEmitted = false;
|
||||
this._watched.forEach((dirent) => dirent.dispose());
|
||||
this._closers.clear();
|
||||
this._watched.clear();
|
||||
this._streams.clear();
|
||||
this._symlinkPaths.clear();
|
||||
this._throttled.clear();
|
||||
this._closePromise = closers.length
|
||||
? Promise.all(closers).then(() => undefined)
|
||||
: Promise.resolve();
|
||||
return this._closePromise;
|
||||
}
|
||||
/**
|
||||
* Expose list of watched paths
|
||||
* @returns for chaining
|
||||
*/
|
||||
getWatched() {
|
||||
const watchList = {};
|
||||
this._watched.forEach((entry, dir) => {
|
||||
const key = this.options.cwd ? sp.relative(this.options.cwd, dir) : dir;
|
||||
const index = key || ONE_DOT;
|
||||
watchList[index] = entry.getChildren().sort();
|
||||
});
|
||||
return watchList;
|
||||
}
|
||||
emitWithAll(event, args) {
|
||||
this.emit(event, ...args);
|
||||
if (event !== EV.ERROR)
|
||||
this.emit(EV.ALL, event, ...args);
|
||||
}
|
||||
// Common helpers
|
||||
// --------------
|
||||
/**
|
||||
* Normalize and emit events.
|
||||
* Calling _emit DOES NOT MEAN emit() would be called!
|
||||
* @param event Type of event
|
||||
* @param path File or directory path
|
||||
* @param stats arguments to be passed with event
|
||||
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
||||
*/
|
||||
async _emit(event, path, stats) {
|
||||
if (this.closed)
|
||||
return;
|
||||
const opts = this.options;
|
||||
if (isWindows)
|
||||
path = sp.normalize(path);
|
||||
if (opts.cwd)
|
||||
path = sp.relative(opts.cwd, path);
|
||||
const args = [path];
|
||||
if (stats != null)
|
||||
args.push(stats);
|
||||
const awf = opts.awaitWriteFinish;
|
||||
let pw;
|
||||
if (awf && (pw = this._pendingWrites.get(path))) {
|
||||
pw.lastChange = new Date();
|
||||
return this;
|
||||
}
|
||||
if (opts.atomic) {
|
||||
if (event === EV.UNLINK) {
|
||||
this._pendingUnlinks.set(path, [event, ...args]);
|
||||
setTimeout(() => {
|
||||
this._pendingUnlinks.forEach((entry, path) => {
|
||||
this.emit(...entry);
|
||||
this.emit(EV.ALL, ...entry);
|
||||
this._pendingUnlinks.delete(path);
|
||||
});
|
||||
}, typeof opts.atomic === 'number' ? opts.atomic : 100);
|
||||
return this;
|
||||
}
|
||||
if (event === EV.ADD && this._pendingUnlinks.has(path)) {
|
||||
event = EV.CHANGE;
|
||||
this._pendingUnlinks.delete(path);
|
||||
}
|
||||
}
|
||||
if (awf && (event === EV.ADD || event === EV.CHANGE) && this._readyEmitted) {
|
||||
const awfEmit = (err, stats) => {
|
||||
if (err) {
|
||||
event = EV.ERROR;
|
||||
args[0] = err;
|
||||
this.emitWithAll(event, args);
|
||||
}
|
||||
else if (stats) {
|
||||
// if stats doesn't exist the file must have been deleted
|
||||
if (args.length > 1) {
|
||||
args[1] = stats;
|
||||
}
|
||||
else {
|
||||
args.push(stats);
|
||||
}
|
||||
this.emitWithAll(event, args);
|
||||
}
|
||||
};
|
||||
this._awaitWriteFinish(path, awf.stabilityThreshold, event, awfEmit);
|
||||
return this;
|
||||
}
|
||||
if (event === EV.CHANGE) {
|
||||
const isThrottled = !this._throttle(EV.CHANGE, path, 50);
|
||||
if (isThrottled)
|
||||
return this;
|
||||
}
|
||||
if (opts.alwaysStat &&
|
||||
stats === undefined &&
|
||||
(event === EV.ADD || event === EV.ADD_DIR || event === EV.CHANGE)) {
|
||||
const fullPath = opts.cwd ? sp.join(opts.cwd, path) : path;
|
||||
let stats;
|
||||
try {
|
||||
stats = await stat(fullPath);
|
||||
}
|
||||
catch (err) {
|
||||
// do nothing
|
||||
}
|
||||
// Suppress event when fs_stat fails, to avoid sending undefined 'stat'
|
||||
if (!stats || this.closed)
|
||||
return;
|
||||
args.push(stats);
|
||||
}
|
||||
this.emitWithAll(event, args);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Common handler for errors
|
||||
* @returns The error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
||||
*/
|
||||
_handleError(error) {
|
||||
const code = error && error.code;
|
||||
if (error &&
|
||||
code !== 'ENOENT' &&
|
||||
code !== 'ENOTDIR' &&
|
||||
(!this.options.ignorePermissionErrors || (code !== 'EPERM' && code !== 'EACCES'))) {
|
||||
this.emit(EV.ERROR, error);
|
||||
}
|
||||
return error || this.closed;
|
||||
}
|
||||
/**
|
||||
* Helper utility for throttling
|
||||
* @param actionType type being throttled
|
||||
* @param path being acted upon
|
||||
* @param timeout duration of time to suppress duplicate actions
|
||||
* @returns tracking object or false if action should be suppressed
|
||||
*/
|
||||
_throttle(actionType, path, timeout) {
|
||||
if (!this._throttled.has(actionType)) {
|
||||
this._throttled.set(actionType, new Map());
|
||||
}
|
||||
const action = this._throttled.get(actionType);
|
||||
if (!action)
|
||||
throw new Error('invalid throttle');
|
||||
const actionPath = action.get(path);
|
||||
if (actionPath) {
|
||||
actionPath.count++;
|
||||
return false;
|
||||
}
|
||||
// eslint-disable-next-line prefer-const
|
||||
let timeoutObject;
|
||||
const clear = () => {
|
||||
const item = action.get(path);
|
||||
const count = item ? item.count : 0;
|
||||
action.delete(path);
|
||||
clearTimeout(timeoutObject);
|
||||
if (item)
|
||||
clearTimeout(item.timeoutObject);
|
||||
return count;
|
||||
};
|
||||
timeoutObject = setTimeout(clear, timeout);
|
||||
const thr = { timeoutObject, clear, count: 0 };
|
||||
action.set(path, thr);
|
||||
return thr;
|
||||
}
|
||||
_incrReadyCount() {
|
||||
return this._readyCount++;
|
||||
}
|
||||
/**
|
||||
* Awaits write operation to finish.
|
||||
* Polls a newly created file for size variations. When files size does not change for 'threshold' milliseconds calls callback.
|
||||
* @param path being acted upon
|
||||
* @param threshold Time in milliseconds a file size must be fixed before acknowledging write OP is finished
|
||||
* @param event
|
||||
* @param awfEmit Callback to be called when ready for event to be emitted.
|
||||
*/
|
||||
_awaitWriteFinish(path, threshold, event, awfEmit) {
|
||||
const awf = this.options.awaitWriteFinish;
|
||||
if (typeof awf !== 'object')
|
||||
return;
|
||||
const pollInterval = awf.pollInterval;
|
||||
let timeoutHandler;
|
||||
let fullPath = path;
|
||||
if (this.options.cwd && !sp.isAbsolute(path)) {
|
||||
fullPath = sp.join(this.options.cwd, path);
|
||||
}
|
||||
const now = new Date();
|
||||
const writes = this._pendingWrites;
|
||||
function awaitWriteFinishFn(prevStat) {
|
||||
statcb(fullPath, (err, curStat) => {
|
||||
if (err || !writes.has(path)) {
|
||||
if (err && err.code !== 'ENOENT')
|
||||
awfEmit(err);
|
||||
return;
|
||||
}
|
||||
const now = Number(new Date());
|
||||
if (prevStat && curStat.size !== prevStat.size) {
|
||||
writes.get(path).lastChange = now;
|
||||
}
|
||||
const pw = writes.get(path);
|
||||
const df = now - pw.lastChange;
|
||||
if (df >= threshold) {
|
||||
writes.delete(path);
|
||||
awfEmit(undefined, curStat);
|
||||
}
|
||||
else {
|
||||
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!writes.has(path)) {
|
||||
writes.set(path, {
|
||||
lastChange: now,
|
||||
cancelWait: () => {
|
||||
writes.delete(path);
|
||||
clearTimeout(timeoutHandler);
|
||||
return event;
|
||||
},
|
||||
});
|
||||
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Determines whether user has asked to ignore this path.
|
||||
*/
|
||||
_isIgnored(path, stats) {
|
||||
if (this.options.atomic && DOT_RE.test(path))
|
||||
return true;
|
||||
if (!this._userIgnored) {
|
||||
const { cwd } = this.options;
|
||||
const ign = this.options.ignored;
|
||||
const ignored = (ign || []).map(normalizeIgnored(cwd));
|
||||
const ignoredPaths = [...this._ignoredPaths];
|
||||
const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
|
||||
this._userIgnored = anymatch(list, undefined);
|
||||
}
|
||||
return this._userIgnored(path, stats);
|
||||
}
|
||||
_isntIgnored(path, stat) {
|
||||
return !this._isIgnored(path, stat);
|
||||
}
|
||||
/**
|
||||
* Provides a set of common helpers and properties relating to symlink handling.
|
||||
* @param path file or directory pattern being watched
|
||||
*/
|
||||
_getWatchHelpers(path) {
|
||||
return new WatchHelper(path, this.options.followSymlinks, this);
|
||||
}
|
||||
// Directory helpers
|
||||
// -----------------
|
||||
/**
|
||||
* Provides directory tracking objects
|
||||
* @param directory path of the directory
|
||||
*/
|
||||
_getWatchedDir(directory) {
|
||||
const dir = sp.resolve(directory);
|
||||
if (!this._watched.has(dir))
|
||||
this._watched.set(dir, new DirEntry(dir, this._boundRemove));
|
||||
return this._watched.get(dir);
|
||||
}
|
||||
// File helpers
|
||||
// ------------
|
||||
/**
|
||||
* Check for read permissions: https://stackoverflow.com/a/11781404/1358405
|
||||
*/
|
||||
_hasReadPermissions(stats) {
|
||||
if (this.options.ignorePermissionErrors)
|
||||
return true;
|
||||
return Boolean(Number(stats.mode) & 0o400);
|
||||
}
|
||||
/**
|
||||
* Handles emitting unlink events for
|
||||
* files and directories, and via recursion, for
|
||||
* files and directories within directories that are unlinked
|
||||
* @param directory within which the following item is located
|
||||
* @param item base path of item/directory
|
||||
*/
|
||||
_remove(directory, item, isDirectory) {
|
||||
// if what is being deleted is a directory, get that directory's paths
|
||||
// for recursive deleting and cleaning of watched object
|
||||
// if it is not a directory, nestedDirectoryChildren will be empty array
|
||||
const path = sp.join(directory, item);
|
||||
const fullPath = sp.resolve(path);
|
||||
isDirectory =
|
||||
isDirectory != null ? isDirectory : this._watched.has(path) || this._watched.has(fullPath);
|
||||
// prevent duplicate handling in case of arriving here nearly simultaneously
|
||||
// via multiple paths (such as _handleFile and _handleDir)
|
||||
if (!this._throttle('remove', path, 100))
|
||||
return;
|
||||
// if the only watched file is removed, watch for its return
|
||||
if (!isDirectory && this._watched.size === 1) {
|
||||
this.add(directory, item, true);
|
||||
}
|
||||
// This will create a new entry in the watched object in either case
|
||||
// so we got to do the directory check beforehand
|
||||
const wp = this._getWatchedDir(path);
|
||||
const nestedDirectoryChildren = wp.getChildren();
|
||||
// Recursively remove children directories / files.
|
||||
nestedDirectoryChildren.forEach((nested) => this._remove(path, nested));
|
||||
// Check if item was on the watched list and remove it
|
||||
const parent = this._getWatchedDir(directory);
|
||||
const wasTracked = parent.has(item);
|
||||
parent.remove(item);
|
||||
// Fixes issue #1042 -> Relative paths were detected and added as symlinks
|
||||
// (https://github.com/paulmillr/chokidar/blob/e1753ddbc9571bdc33b4a4af172d52cb6e611c10/lib/nodefs-handler.js#L612),
|
||||
// but never removed from the map in case the path was deleted.
|
||||
// This leads to an incorrect state if the path was recreated:
|
||||
// https://github.com/paulmillr/chokidar/blob/e1753ddbc9571bdc33b4a4af172d52cb6e611c10/lib/nodefs-handler.js#L553
|
||||
if (this._symlinkPaths.has(fullPath)) {
|
||||
this._symlinkPaths.delete(fullPath);
|
||||
}
|
||||
// If we wait for this file to be fully written, cancel the wait.
|
||||
let relPath = path;
|
||||
if (this.options.cwd)
|
||||
relPath = sp.relative(this.options.cwd, path);
|
||||
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
||||
const event = this._pendingWrites.get(relPath).cancelWait();
|
||||
if (event === EV.ADD)
|
||||
return;
|
||||
}
|
||||
// The Entry will either be a directory that just got removed
|
||||
// or a bogus entry to a file, in either case we have to remove it
|
||||
this._watched.delete(path);
|
||||
this._watched.delete(fullPath);
|
||||
const eventName = isDirectory ? EV.UNLINK_DIR : EV.UNLINK;
|
||||
if (wasTracked && !this._isIgnored(path))
|
||||
this._emit(eventName, path);
|
||||
// Avoid conflicts if we later create another file with the same name
|
||||
this._closePath(path);
|
||||
}
|
||||
/**
|
||||
* Closes all watchers for a path
|
||||
*/
|
||||
_closePath(path) {
|
||||
this._closeFile(path);
|
||||
const dir = sp.dirname(path);
|
||||
this._getWatchedDir(dir).remove(sp.basename(path));
|
||||
}
|
||||
/**
|
||||
* Closes only file-specific watchers
|
||||
*/
|
||||
_closeFile(path) {
|
||||
const closers = this._closers.get(path);
|
||||
if (!closers)
|
||||
return;
|
||||
closers.forEach((closer) => closer());
|
||||
this._closers.delete(path);
|
||||
}
|
||||
_addPathCloser(path, closer) {
|
||||
if (!closer)
|
||||
return;
|
||||
let list = this._closers.get(path);
|
||||
if (!list) {
|
||||
list = [];
|
||||
this._closers.set(path, list);
|
||||
}
|
||||
list.push(closer);
|
||||
}
|
||||
_readdirp(root, opts) {
|
||||
if (this.closed)
|
||||
return;
|
||||
const options = { type: EV.ALL, alwaysStat: true, lstat: true, ...opts, depth: 0 };
|
||||
let stream = readdirp(root, options);
|
||||
this._streams.add(stream);
|
||||
stream.once(STR_CLOSE, () => {
|
||||
stream = undefined;
|
||||
});
|
||||
stream.once(STR_END, () => {
|
||||
if (stream) {
|
||||
this._streams.delete(stream);
|
||||
stream = undefined;
|
||||
}
|
||||
});
|
||||
return stream;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Instantiates watcher with paths to be tracked.
|
||||
* @param paths file / directory paths
|
||||
* @param options opts, such as `atomic`, `awaitWriteFinish`, `ignored`, and others
|
||||
* @returns an instance of FSWatcher for chaining.
|
||||
* @example
|
||||
* const watcher = watch('.').on('all', (event, path) => { console.log(event, path); });
|
||||
* watch('.', { atomic: true, awaitWriteFinish: true, ignored: (f, stats) => stats?.isFile() && !f.endsWith('.js') })
|
||||
*/
|
||||
export function watch(paths, options = {}) {
|
||||
const watcher = new FSWatcher(options);
|
||||
watcher.add(paths);
|
||||
return watcher;
|
||||
}
|
||||
export default { watch: watch, FSWatcher: FSWatcher };
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"name": "chokidar",
|
||||
"description": "Minimal and efficient cross-platform file watching library",
|
||||
"version": "5.0.0",
|
||||
"type": "module",
|
||||
"homepage": "https://github.com/paulmillr/chokidar",
|
||||
"author": "Paul Miller (https://paulmillr.com)",
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts",
|
||||
"handler.js",
|
||||
"handler.d.ts"
|
||||
],
|
||||
"main": "./index.js",
|
||||
"exports": {
|
||||
".": {
|
||||
"default": "./index.js"
|
||||
},
|
||||
"./handler.js": {
|
||||
"default": "./handler.js"
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"readdirp": "^5.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@paulmillr/jsbt": "0.4.5",
|
||||
"@types/node": "24.10.1",
|
||||
"prettier": "3.5.2",
|
||||
"tinyspy": "3.0.2",
|
||||
"typescript": "5.9.2",
|
||||
"upath": "2.0.1"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"engines": {
|
||||
"node": ">= 20.19.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/paulmillr/chokidar.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/paulmillr/chokidar/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"lint": "prettier --check src",
|
||||
"format": "prettier --write src",
|
||||
"test": "node index.test.js",
|
||||
"test:bun1": "bun index.test.js"
|
||||
},
|
||||
"keywords": [
|
||||
"fs",
|
||||
"watch",
|
||||
"watchFile",
|
||||
"watcher",
|
||||
"watching",
|
||||
"file",
|
||||
"fsevents"
|
||||
],
|
||||
"funding": "https://paulmillr.com/funding/"
|
||||
}
|
||||
+3556
File diff suppressed because it is too large
Load Diff
+29
@@ -0,0 +1,29 @@
|
||||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2006, Ivan Sagalaev.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
+521
@@ -0,0 +1,521 @@
|
||||
# Highlight.js
|
||||
|
||||
[](https://www.npmjs.com/package/highlight.js)
|
||||
[](https://github.com/highlightjs/highlight.js/blob/main/LICENSE)
|
||||
[](https://packagephobia.now.sh/result?p=highlight.js)
|
||||

|
||||
[](https://www.npmjs.com/package/highlight.js)
|
||||
[](https://www.jsdelivr.com/package/gh/highlightjs/cdn-release)
|
||||
|
||||
[](https://github.com/highlightjs/highlight.js/actions/workflows/tests.js.yml)
|
||||
[](https://github.com/highlightjs/highlight.js/actions/workflows/github-code-scanning/codeql)
|
||||
[](https://snyk.io/test/github/highlightjs/highlight.js?targetFile=package.json)
|
||||
|
||||
[](https://discord.gg/M24EbU7ja9)
|
||||
[](https://github.com/highlightjs/highlight.js/issues)
|
||||
[](https://github.com/highlightjs/highlight.js/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+welcome%22)
|
||||
[](https://github.com/highlightjs/highlight.js/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22)
|
||||
|
||||
<!-- [](https://github.com/highlightjs/highlight.js/actions?query=workflow%3A%22Node.js+CI%22) -->
|
||||
<!-- [](https://github.com/highlightjs/highlight.js/commits/main) -->
|
||||
<!-- [](https://www.jsdelivr.com/package/gh/highlightjs/cdn-release) -->
|
||||
<!-- []() -->
|
||||
<!-- [](https://bundlephobia.com/result?p=highlight.js) -->
|
||||
|
||||
|
||||
Highlight.js is a syntax highlighter written in JavaScript. It works in
|
||||
the browser as well as on the server. It can work with pretty much any
|
||||
markup, doesn’t depend on any other frameworks, and has automatic language
|
||||
detection.
|
||||
|
||||
**Contents**
|
||||
|
||||
- [Basic Usage](#basic-usage)
|
||||
- [In the Browser](#in-the-browser)
|
||||
- [Plaintext Code Blocks](#plaintext-code-blocks)
|
||||
- [Ignoring a Code Block](#ignoring-a-code-block)
|
||||
- [Node.js on the Server](#nodejs-on-the-server)
|
||||
- [Supported Languages](#supported-languages)
|
||||
- [Custom Usage](#custom-usage)
|
||||
- [Using custom HTML](#using-custom-html)
|
||||
- [Using with Vue.js](#using-with-vuejs)
|
||||
- [Using Web Workers](#using-web-workers)
|
||||
- [Importing the Library](#importing-the-library)
|
||||
- [Node.js CommonJS Modules / `require`](#nodejs-commonjs-modules--require)
|
||||
- [Node.js ES6 Modules / `import`](#nodejs-es6-modules--import)
|
||||
- [Browser ES6 Modules](#browser-es6-modules)
|
||||
- [Getting the Library](#getting-the-library)
|
||||
- [Fetch via CDN](#fetch-via-cdn)
|
||||
- [cdnjs (link)](#cdnjs-link)
|
||||
- [jsdelivr (link)](#jsdelivr-link)
|
||||
- [unpkg (link)](#unpkg-link)
|
||||
- [Download prebuilt CDN assets](#download-prebuilt-cdn-assets)
|
||||
- [Download from our website](#download-from-our-website)
|
||||
- [Install via NPM package](#install-via-npm-package)
|
||||
- [Build from Source](#build-from-source)
|
||||
- [Requirements](#requirements)
|
||||
- [License](#license)
|
||||
- [Links](#links)
|
||||
|
||||
---
|
||||
|
||||
#### Upgrading to Version 11
|
||||
|
||||
As always, major releases do contain breaking changes which may require action from users. Please read [VERSION_11_UPGRADE.md](https://github.com/highlightjs/highlight.js/blob/main/VERSION_11_UPGRADE.md) for a detailed summary of breaking changes and any actions you may need to take.
|
||||
|
||||
|
||||
#### Support for older versions <!-- omit in toc -->
|
||||
|
||||
Please see [SECURITY.md](https://github.com/highlightjs/highlight.js/blob/main/SECURITY.md) for long-term support information.
|
||||
|
||||
---
|
||||
|
||||
## Basic Usage
|
||||
### In the Browser
|
||||
|
||||
The bare minimum for using highlight.js on a web page is linking to the
|
||||
library along with one of the themes and calling [`highlightAll`][1]:
|
||||
|
||||
```html
|
||||
<link rel="stylesheet" href="/path/to/styles/default.min.css">
|
||||
<script src="/path/to/highlight.min.js"></script>
|
||||
<script>hljs.highlightAll();</script>
|
||||
```
|
||||
|
||||
This will find and highlight code inside of `<pre><code>` tags; it tries
|
||||
to detect the language automatically. If automatic detection doesn’t
|
||||
work for you, or you simply prefer to be explicit, you can specify the language manually by using the `class` attribute:
|
||||
|
||||
|
||||
```html
|
||||
<pre><code class="language-html">...</code></pre>
|
||||
```
|
||||
|
||||
#### Plaintext Code Blocks
|
||||
|
||||
To apply the Highlight.js styling to plaintext without actually highlighting it, use the `plaintext` language:
|
||||
|
||||
```html
|
||||
<pre><code class="language-plaintext">...</code></pre>
|
||||
```
|
||||
|
||||
#### Ignoring a Code Block
|
||||
|
||||
To skip highlighting of a code block completely, use the `nohighlight` class:
|
||||
|
||||
```html
|
||||
<pre><code class="nohighlight">...</code></pre>
|
||||
```
|
||||
|
||||
### Node.js on the Server
|
||||
|
||||
The bare minimum to auto-detect the language and highlight some code.
|
||||
|
||||
```js
|
||||
// load the library and ALL languages
|
||||
hljs = require('highlight.js');
|
||||
html = hljs.highlightAuto('<h1>Hello World!</h1>').value
|
||||
```
|
||||
|
||||
To load only a "common" subset of popular languages:
|
||||
|
||||
```js
|
||||
hljs = require('highlight.js/lib/common');
|
||||
```
|
||||
|
||||
To highlight code with a specific language, use `highlight`:
|
||||
|
||||
```js
|
||||
html = hljs.highlight('<h1>Hello World!</h1>', {language: 'xml'}).value
|
||||
```
|
||||
|
||||
See [Importing the Library](#importing-the-library) for more examples of `require` vs `import` usage, etc. For more information about the result object returned by `highlight` or `highlightAuto` refer to the [api docs](https://highlightjs.readthedocs.io/en/latest/api.html).
|
||||
|
||||
|
||||
|
||||
## Supported Languages
|
||||
|
||||
Highlight.js supports over 180 languages in the core library. There are also 3rd party
|
||||
language definitions available to support even more languages. You can find the full list of supported languages in [SUPPORTED_LANGUAGES.md][9].
|
||||
|
||||
## Custom Usage
|
||||
|
||||
If you need a bit more control over the initialization of
|
||||
Highlight.js, you can use the [`highlightElement`][3] and [`configure`][4]
|
||||
functions. This allows you to better control *what* to highlight and *when*.
|
||||
|
||||
For example, here’s the rough equivalent of calling [`highlightAll`][1] but doing the work manually instead:
|
||||
|
||||
```js
|
||||
document.addEventListener('DOMContentLoaded', (event) => {
|
||||
document.querySelectorAll('pre code').forEach((el) => {
|
||||
hljs.highlightElement(el);
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
Please refer to the documentation for [`configure`][4] options.
|
||||
|
||||
|
||||
### Using custom HTML
|
||||
|
||||
We strongly recommend `<pre><code>` wrapping for code blocks. It's quite
|
||||
semantic and "just works" out of the box with zero fiddling. It is possible to
|
||||
use other HTML elements (or combos), but you may need to pay special attention to
|
||||
preserving linebreaks.
|
||||
|
||||
Let's say your markup for code blocks uses divs:
|
||||
|
||||
```html
|
||||
<div class='code'>...</div>
|
||||
```
|
||||
|
||||
To highlight such blocks manually:
|
||||
|
||||
```js
|
||||
// first, find all the div.code blocks
|
||||
document.querySelectorAll('div.code').forEach(el => {
|
||||
// then highlight each
|
||||
hljs.highlightElement(el);
|
||||
});
|
||||
```
|
||||
|
||||
Without using a tag that preserves linebreaks (like `pre`) you'll need some
|
||||
additional CSS to help preserve them. You could also [pre and post-process line
|
||||
breaks with a plug-in][brPlugin], but *we recommend using CSS*.
|
||||
|
||||
[brPlugin]: https://github.com/highlightjs/highlight.js/issues/2559
|
||||
|
||||
To preserve linebreaks inside a `div` using CSS:
|
||||
|
||||
```css
|
||||
div.code {
|
||||
white-space: pre;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Using with Vue.js
|
||||
|
||||
See [highlightjs/vue-plugin](https://github.com/highlightjs/vue-plugin) for a simple Vue plugin that works great with Highlight.js.
|
||||
|
||||
An example of `vue-plugin` in action:
|
||||
|
||||
```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>
|
||||
```
|
||||
|
||||
### Using Web Workers
|
||||
|
||||
You can run highlighting inside a web worker to avoid freezing the browser
|
||||
window while dealing with very big chunks of code.
|
||||
|
||||
In your main script:
|
||||
|
||||
```js
|
||||
addEventListener('load', () => {
|
||||
const code = document.querySelector('#code');
|
||||
const worker = new Worker('worker.js');
|
||||
worker.onmessage = (event) => { code.innerHTML = event.data; }
|
||||
worker.postMessage(code.textContent);
|
||||
});
|
||||
```
|
||||
|
||||
In worker.js:
|
||||
|
||||
```js
|
||||
onmessage = (event) => {
|
||||
importScripts('<path>/highlight.min.js');
|
||||
const result = self.hljs.highlightAuto(event.data);
|
||||
postMessage(result.value);
|
||||
};
|
||||
```
|
||||
|
||||
## Importing the Library
|
||||
|
||||
First, you'll likely be installing the library via `npm` or `yarn` -- see [Getting the Library](#getting-the-library).
|
||||
|
||||
|
||||
### Node.js CommonJS Modules / `require`
|
||||
|
||||
Requiring the top-level library will load all languages:
|
||||
|
||||
```js
|
||||
// require the highlight.js library, including all languages
|
||||
const hljs = require('./highlight.js');
|
||||
const highlightedCode = hljs.highlightAuto('<span>Hello World!</span>').value
|
||||
```
|
||||
|
||||
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/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'));
|
||||
|
||||
const highlightedCode = hljs.highlight('<span>Hello World!</span>', {language: 'xml'}).value
|
||||
```
|
||||
|
||||
|
||||
### Node.js ES6 Modules / `import`
|
||||
|
||||
The default import will register all languages:
|
||||
|
||||
```js
|
||||
import hljs from 'highlight.js';
|
||||
```
|
||||
|
||||
It is more efficient to import only the library and register the languages you need:
|
||||
|
||||
```js
|
||||
import hljs from 'highlight.js/lib/core';
|
||||
import javascript from 'highlight.js/lib/languages/javascript';
|
||||
hljs.registerLanguage('javascript', javascript);
|
||||
```
|
||||
|
||||
If your build tool processes CSS imports, you can also import the theme directly as a module:
|
||||
|
||||
```js
|
||||
import hljs from 'highlight.js';
|
||||
import 'highlight.js/styles/github.css';
|
||||
```
|
||||
|
||||
### Browser ES6 Modules
|
||||
|
||||
*Note: For now you'll want to install `@highlightjs/cdn-assets` package instead of `highlight.js`.
|
||||
See [Download prebuilt CDN assets](#download-prebuilt-cdn-assets)*
|
||||
|
||||
To import the library and register only those languages that you need:
|
||||
|
||||
```js
|
||||
import hljs from './assets/js/@highlightjs/cdn-assets/es/core.js';
|
||||
import javascript from './assets/js/@highlightjs/cdn-assets/es/languages/javascript.min.js';
|
||||
|
||||
hljs.registerLanguage('javascript', javascript);
|
||||
```
|
||||
|
||||
To import the library and register all languages:
|
||||
|
||||
```js
|
||||
import hljs from './assets/js/@highlightjs/cdn-assets/es/highlight.js';
|
||||
```
|
||||
|
||||
*Note: The path to these files will vary depending on where you have installed/copied them
|
||||
within your project or site. The above path is only an example.*
|
||||
|
||||
You can also use [`importmap`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap) to import in similar way as Node:
|
||||
|
||||
```html
|
||||
<script type="importmap">
|
||||
{
|
||||
"imports": {
|
||||
"@highlightjs": "./assets/js/@highlightjs/cdn-assets/es/"
|
||||
}
|
||||
}
|
||||
</script>
|
||||
```
|
||||
|
||||
Use the above code in your HTML. After that, your JavaScript can import using the named key from
|
||||
your `importmap`, for example `@highlightjs` in this case:
|
||||
|
||||
```js
|
||||
import hljs from '@highlightjs/core.js';
|
||||
import javascript from '@highlightjs/languages/javascript.min.js';
|
||||
|
||||
hljs.registerLanguage('javascript', javascript);
|
||||
```
|
||||
|
||||
*Note: You can also import directly from fully static URLs, such as our very own pre-built ES6 Module CDN resources. See [Fetch via CDN](#fetch-via-cdn) for specific examples.*
|
||||
|
||||
|
||||
## Getting the Library
|
||||
|
||||
You can get highlight.js as a hosted, or custom-build, browser script or
|
||||
as a server module. Right out of the box the browser script supports
|
||||
both AMD and CommonJS, so if you wish you can use RequireJS or
|
||||
Browserify without having to build from source. The server module also
|
||||
works perfectly fine with Browserify, but there is the option to use a
|
||||
build specific to browsers rather than something meant for a server.
|
||||
|
||||
|
||||
**Do not link to GitHub directly.** The library is not supposed to work straight
|
||||
from the source, it requires building. If none of the pre-packaged options
|
||||
work for you refer to the [building documentation][6].
|
||||
|
||||
**On Almond.** You need to use the optimizer to give the module a name. For
|
||||
example:
|
||||
|
||||
```bash
|
||||
r.js -o name=hljs paths.hljs=/path/to/highlight out=highlight.js
|
||||
```
|
||||
|
||||
### Fetch via CDN
|
||||
|
||||
A prebuilt version of Highlight.js bundled with many common languages is hosted by several popular CDNs.
|
||||
When using Highlight.js via CDN you can use Subresource Integrity for additional security. For details
|
||||
see [DIGESTS.md](https://github.com/highlightjs/cdn-release/blob/main/DIGESTS.md).
|
||||
|
||||
#### cdnjs ([link](https://cdnjs.com/libraries/highlight.js))
|
||||
|
||||
##### Common JS <!-- omit in toc -->
|
||||
|
||||
```html
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/styles/default.min.css">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/highlight.min.js"></script>
|
||||
<!-- and it's easy to individually load additional languages -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/languages/go.min.js"></script>
|
||||
```
|
||||
|
||||
##### ES6 Modules <!-- omit in toc -->
|
||||
|
||||
````html
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/styles/dark.min.css">
|
||||
<script type="module">
|
||||
import hljs from 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/es/highlight.min.js';
|
||||
// and it's easy to individually load additional languages
|
||||
import go from 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/es/languages/go.min.js';
|
||||
hljs.registerLanguage('go', go);
|
||||
</script>
|
||||
|
||||
````
|
||||
|
||||
|
||||
#### jsdelivr ([link](https://www.jsdelivr.com/package/gh/highlightjs/cdn-release))
|
||||
|
||||
##### Common JS <!-- omit in toc -->
|
||||
|
||||
```html
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.11.1/build/styles/default.min.css">
|
||||
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.11.1/build/highlight.min.js"></script>
|
||||
<!-- and it's easy to individually load additional languages -->
|
||||
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.11.1/build/languages/go.min.js"></script>
|
||||
```
|
||||
|
||||
##### ES6 Modules <!-- omit in toc -->
|
||||
|
||||
```html
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.11.1/build/styles/default.min.css">
|
||||
<script type="module">
|
||||
import hljs from 'https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.11.1/build/es/highlight.min.js';
|
||||
// and it's easy to individually load additional languages
|
||||
import go from 'https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.11.1/build/es/languages/go.min.js';
|
||||
hljs.registerLanguage('go', go);
|
||||
</script>
|
||||
```
|
||||
|
||||
#### unpkg ([link](https://unpkg.com/browse/@highlightjs/cdn-assets/))
|
||||
|
||||
##### Common JS <!-- omit in toc -->
|
||||
|
||||
```html
|
||||
<link rel="stylesheet" href="https://unpkg.com/@highlightjs/cdn-assets@11.11.1/styles/default.min.css">
|
||||
<script src="https://unpkg.com/@highlightjs/cdn-assets@11.11.1/highlight.min.js"></script>
|
||||
<!-- and it's easy to individually load additional languages -->
|
||||
<script src="https://unpkg.com/@highlightjs/cdn-assets@11.11.1/languages/go.min.js"></script>
|
||||
```
|
||||
|
||||
##### ES6 Modules <!-- omit in toc -->
|
||||
|
||||
```html
|
||||
<link rel="stylesheet" href="https://unpkg.com/@highlightjs/cdn-assets@11.11.1/styles/default.min.css">
|
||||
<script type="module">
|
||||
import hljs from 'https://unpkg.com/@highlightjs/cdn-assets@11.11.1/es/highlight.min.js';
|
||||
// and it's easy to individually load & register additional languages
|
||||
import go from 'https://unpkg.com/@highlightjs/cdn-assets@11.11.1/es/languages/go.min.js';
|
||||
hljs.registerLanguage('go', go);
|
||||
</script>
|
||||
```
|
||||
|
||||
|
||||
**Note:** *The CDN-hosted `highlight.min.js` package doesn't bundle every language.* It would be
|
||||
very large. You can find our list of "common" languages that we bundle by default on our [download page][5].
|
||||
|
||||
### Download prebuilt CDN assets
|
||||
|
||||
You can also download and self-host the same assets we serve up via our own CDNs. We publish those builds to the [cdn-release](https://github.com/highlightjs/cdn-release) GitHub repository. You can easily pull individual files off the CDN endpoints with `curl`, etc; if say you only needed `highlight.min.js` and a single CSS file.
|
||||
|
||||
There is also an npm package [@highlightjs/cdn-assets](https://www.npmjs.com/package/@highlightjs/cdn-assets) if pulling the assets in via `npm` or `yarn` would be easier for your build process.
|
||||
|
||||
### Download from our website
|
||||
|
||||
The [download page][5] can quickly generate a custom single-file minified bundle including only the languages you desire.
|
||||
|
||||
**Note:** [Building from source](#build-from-source) can produce slightly smaller builds than the website download.
|
||||
|
||||
|
||||
### Install via NPM package
|
||||
|
||||
Our NPM package including all supported languages can be installed with NPM or Yarn:
|
||||
|
||||
```bash
|
||||
npm install highlight.js
|
||||
# or
|
||||
yarn add highlight.js
|
||||
```
|
||||
|
||||
There is also another npm package [@highlightjs/cdn-assets](https://www.npmjs.com/package/@highlightjs/cdn-assets) that contains prebuilt CDN assets including [ES6 Modules that can be imported in browser](#browser-es6-modules):
|
||||
|
||||
```bash
|
||||
npm install @highlightjs/cdn-assets
|
||||
# or
|
||||
yarn add @highlightjs/cdn-assets
|
||||
```
|
||||
|
||||
Alternatively, you can build the NPM package from source.
|
||||
|
||||
|
||||
### Build from Source
|
||||
|
||||
The [current source code][10] is always available on GitHub.
|
||||
|
||||
```bash
|
||||
node tools/build.js -t node
|
||||
node tools/build.js -t browser :common
|
||||
node tools/build.js -t cdn :common
|
||||
```
|
||||
|
||||
See our [building documentation][6] for more information.
|
||||
|
||||
|
||||
## Requirements
|
||||
|
||||
Highlight.js works on all modern browsers and currently supported Node.js versions. You'll need the following software to contribute to the core library:
|
||||
|
||||
- Node.js >= 12.x
|
||||
- npm >= 6.x
|
||||
|
||||
## License
|
||||
|
||||
Highlight.js is released under the BSD License. See our [LICENSE][7] file
|
||||
for details.
|
||||
|
||||
|
||||
## Links
|
||||
|
||||
The official website for the library is <https://highlightjs.org/>.
|
||||
|
||||
Further in-depth documentation for the API and other topics is at
|
||||
<http://highlightjs.readthedocs.io/>.
|
||||
|
||||
A list of the Core Team and contributors can be found in the [CONTRIBUTORS.md][8] file.
|
||||
|
||||
[1]: http://highlightjs.readthedocs.io/en/latest/api.html#highlightall
|
||||
[2]: http://highlightjs.readthedocs.io/en/latest/css-classes-reference.html
|
||||
[3]: http://highlightjs.readthedocs.io/en/latest/api.html#highlightelement
|
||||
[4]: http://highlightjs.readthedocs.io/en/latest/api.html#configure
|
||||
[5]: https://highlightjs.org/download/
|
||||
[6]: http://highlightjs.readthedocs.io/en/latest/building-testing.html
|
||||
[7]: https://github.com/highlightjs/highlight.js/blob/main/LICENSE
|
||||
[8]: https://github.com/highlightjs/highlight.js/blob/main/CONTRIBUTORS.md
|
||||
[9]: https://github.com/highlightjs/highlight.js/blob/main/SUPPORTED_LANGUAGES.md
|
||||
[10]: https://github.com/highlightjs/
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
# Security Policy
|
||||
|
||||
Due to both time and resource constrains the Highlight.js core team fully supports only the current major/minor release of the library. Prior major releases may be supported for a short time after new major releases are issued. Problems with minor releases are often resolved by upgrading to the most recent minor release.
|
||||
|
||||
### Release Status
|
||||
|
||||
| Version | Support | Status |
|
||||
| :-----: | :-: | :------ |
|
||||
| 11.x | :white_check_mark: | The 11.x series recieves regular updates, new features & security fixes. |
|
||||
| 10.7.x | :x: | No longer supported. <br>See [VERSION_11_UPGRADE.md](https://github.com/highlightjs/highlight.js/blob/master/VERSION_11_UPGRADE.md).|
|
||||
| <= 10.4.0 | :x: | Known vulnerabities. |
|
||||
| <= 9.18.5 | :x: | Known vulnerabities. [EOL](https://github.com/highlightjs/highlight.js/issues/2877) |
|
||||
| 7.x, 8.x | :x: | Obsolete. Known vulnerabities. |
|
||||
|
||||
|
||||
### Reporting a Vulnerability
|
||||
|
||||
Many vulnerabilities can simply be reported (and tracked) via our [GitHub issues](https://github.com/highlightjs/highlight.js/issues). If you feel your issue is more sensitive than that you can always reach us via email: [security@highlightjs.org](mailto:security@highlightjs.org)
|
||||
|
||||
+283
@@ -0,0 +1,283 @@
|
||||
# Supported Languages
|
||||
|
||||
The table below shows the full list of languages (and corresponding classes/aliases) supported by Highlight.js. Languages that list a **Package** below are 3rd party languages and are not bundled with the core library. You can find their repositories by following the links.
|
||||
|
||||
**Note:** The languages available will depend on how you've built or are included the library in your app. For example our default minified web build includes only ~40 popular languages. See [Getting the Library][1] and [Importing the Library][2] in the README for examples of how to load additional/specific languages.
|
||||
|
||||
<!-- LANGLIST -->
|
||||
| Language | Aliases | Package |
|
||||
| :-----------------------| :--------------------- | :------ |
|
||||
| 1C | 1c | |
|
||||
| 4D | 4d |[highlightjs-4d](https://github.com/highlightjs/highlightjs-4d) |
|
||||
| ABAP | sap-abap, abap |[highlight-sap-abap](https://github.com/highlightjs/highlightjs-sap-abap) |
|
||||
| ABNF | abnf | |
|
||||
| Access logs | accesslog | |
|
||||
| Ada | ada | |
|
||||
| Apex | apex | [highlightjs-apex](https://github.com/highlightjs/highlightjs-apex/) |
|
||||
| Arduino (C++ w/Arduino libs) | arduino, ino | |
|
||||
| ARM assembler | armasm, arm | |
|
||||
| AVR assembler | avrasm | |
|
||||
| ActionScript | actionscript, as | |
|
||||
| Alan IF | alan, i | [highlightjs-alan](https://github.com/highlightjs/highlightjs-alan) |
|
||||
| Alan | ln | [highlightjs-alan](https://github.com/alantech/highlightjs-alan) |
|
||||
| AngelScript | angelscript, asc | |
|
||||
| Apache | apache, apacheconf | |
|
||||
| AppleScript | applescript, osascript | |
|
||||
| Arcade | arcade | |
|
||||
| AsciiDoc | asciidoc, adoc | |
|
||||
| AspectJ | aspectj | |
|
||||
| AutoHotkey | autohotkey | |
|
||||
| AutoIt | autoit | |
|
||||
| Awk | awk, mawk, nawk, gawk | |
|
||||
| Ballerina | ballerina, bal | [highlightjs-ballerina](https://github.com/highlightjs/highlightjs-ballerina) |
|
||||
| Bash | bash, sh, zsh | |
|
||||
| Basic | basic | |
|
||||
| BBCode | bbcode | [highlightjs-bbcode](https://github.com/RedGuy12/highlightjs-bbcode) |
|
||||
| Blade (Laravel) | blade | [highlightjs-blade](https://github.com/miken32/highlightjs-blade) |
|
||||
| BNF | bnf | |
|
||||
| BQN | bqn | [highlightjs-bqn](https://github.com/razetime/highlightjs-bqn) |
|
||||
| Brainfuck | brainfuck, bf | |
|
||||
| C# | csharp, cs | |
|
||||
| C | c, h | |
|
||||
| C++ | cpp, hpp, cc, hh, c++, h++, cxx, hxx | |
|
||||
| C/AL | cal | |
|
||||
| C3 | c3 | [highlightjs-c3](https://github.com/highlightjs/highlightjs-c3) |
|
||||
| Cache Object Script | cos, cls | |
|
||||
| Candid | candid, did | [highlightjs-motoko](https://github.com/rvanasa/highlightjs-motoko) |
|
||||
| CMake | cmake, cmake.in | |
|
||||
| COBOL | cobol, standard-cobol | [highlightjs-cobol](https://github.com/otterkit/highlightjs-cobol) |
|
||||
| CODEOWNERS | codeowners | [highlightjs-codeowners](https://github.com/highlightjs/highlightjs-codeowners) |
|
||||
| Coq | coq | |
|
||||
| CSP | csp | |
|
||||
| CSS | css | |
|
||||
| Cap’n Proto | capnproto, capnp | |
|
||||
| Chaos | chaos, kaos | [highlightjs-chaos](https://github.com/chaos-lang/highlightjs-chaos) |
|
||||
| Chapel | chapel, chpl | [highlightjs-chapel](https://github.com/chapel-lang/highlightjs-chapel) |
|
||||
| Cisco CLI | cisco | [highlightjs-cisco-cli](https://github.com/BMatheas/highlightjs-cisco-cli) |
|
||||
| Clojure | clojure, clj | |
|
||||
| CoffeeScript | coffeescript, coffee, cson, iced | |
|
||||
| CpcdosC+ | cpc | [highlightjs-cpcdos](https://github.com/SPinti-Software/highlightjs-cpcdos) |
|
||||
| Crmsh | crmsh, crm, pcmk | |
|
||||
| Crystal | crystal, cr | |
|
||||
| cURL | curl | [highlightjs-curl](https://github.com/highlightjs/highlightjs-curl) |
|
||||
| Cypher (Neo4j) | cypher | [highlightjs-cypher](https://github.com/highlightjs/highlightjs-cypher) |
|
||||
| D | d | |
|
||||
| Dafny | dafny | [highlightjs-dafny](https://github.com/ConsenSys/highlightjs-dafny)|
|
||||
| Dart | dart | |
|
||||
| Delphi | dpr, dfm, pas, pascal | |
|
||||
| Diff | diff, patch | |
|
||||
| Django | django, jinja | |
|
||||
| DNS Zone file | dns, zone, bind | |
|
||||
| Dockerfile | dockerfile, docker | |
|
||||
| DOS | dos, bat, cmd | |
|
||||
| dsconfig | dsconfig | |
|
||||
| DTS (Device Tree) | dts | |
|
||||
| Dust | dust, dst | |
|
||||
| Dylan | dylan | [highlightjs-dylan](https://github.com/highlightjs/highlightjs-dylan) |
|
||||
| EBNF | ebnf | |
|
||||
| Elixir | elixir | |
|
||||
| Elm | elm | |
|
||||
| Erlang | erlang, erl | |
|
||||
| Excel | excel, xls, xlsx | |
|
||||
| Extempore | extempore, xtlang, xtm | [highlightjs-xtlang](https://github.com/highlightjs/highlightjs-xtlang) |
|
||||
| F# | fsharp, fs, fsx, fsi, fsscript | |
|
||||
| FIX | fix | |
|
||||
| Flix | flix | [highlightjs-flix](https://github.com/flix/highlightjs-flix) |
|
||||
| Fortran | fortran, f90, f95 | |
|
||||
| FunC | func | [highlightjs-func](https://github.com/highlightjs/highlightjs-func) |
|
||||
| G-Code | gcode, nc | |
|
||||
| Gams | gams, gms | |
|
||||
| GAUSS | gauss, gss | |
|
||||
| GDScript | godot, gdscript | [highlightjs-gdscript](https://github.com/highlightjs/highlightjs-gdscript) |
|
||||
| Gherkin | gherkin | |
|
||||
| Glimmer and EmberJS | hbs, glimmer, html.hbs, html.handlebars, htmlbars | [highlightjs-glimmer](https://github.com/NullVoxPopuli/highlightjs-glimmer) |
|
||||
| GN for Ninja | gn, gni | [highlightjs-GN](https://github.com/highlightjs/highlightjs-GN) |
|
||||
| Go | go, golang | |
|
||||
| Grammatical Framework | gf | [highlightjs-gf](https://github.com/johnjcamilleri/highlightjs-gf) |
|
||||
| Golo | golo, gololang | |
|
||||
| Gradle | gradle | |
|
||||
| GraphQL | graphql, gql | |
|
||||
| Groovy | groovy | |
|
||||
| GSQL | gsql | [highlightjs-gsql](https://github.com/DanBarkus/highlightjs-gsql) |
|
||||
| HTML, XML | xml, html, xhtml, rss, atom, xjb, xsd, xsl, plist, svg | |
|
||||
| HTTP | http, https | |
|
||||
| Haml | haml | |
|
||||
| Handlebars | handlebars, hbs, html.hbs, html.handlebars | |
|
||||
| Haskell | haskell, hs | |
|
||||
| Haxe | haxe, hx | |
|
||||
| High-level shader language| hlsl | [highlightjs-hlsl](https://github.com/highlightjs/highlightjs-hlsl) |
|
||||
| Hy | hy, hylang | |
|
||||
| Ini, TOML | ini, toml | |
|
||||
| Inform7 | inform7, i7 | |
|
||||
| IRPF90 | irpf90 | |
|
||||
| Iptables | iptables | [highlightjs-iptables](https://github.com/highlightjs/highlightjs-iptables) |
|
||||
| JSON | json, jsonc | |
|
||||
| JSONata | jsonata | [highlightjs-jsonata](https://github.com/DevDimov/highlightjs-jsonata) |
|
||||
| Java | java, jsp | |
|
||||
| JavaScript | javascript, js, jsx | |
|
||||
| Jolie | jolie, iol, ol | [highlightjs-jolie](https://github.com/xiroV/highlightjs-jolie) |
|
||||
| Julia | julia, jl | |
|
||||
| Julia REPL | julia-repl | |
|
||||
| Kotlin | kotlin, kt | |
|
||||
| Lang | | [highlightjs-lang](https://github.com/highlightjs/highlightjs-lang)
|
||||
| LaTeX | tex | |
|
||||
| Leaf | leaf | |
|
||||
| Lean | lean | [highlightjs-lean](https://github.com/leanprover-community/highlightjs-lean) |
|
||||
| Lasso | lasso, ls, lassoscript | |
|
||||
| Less | less | |
|
||||
| LDIF | ldif | |
|
||||
| Liquid | liquid | [highlightjs-liquid](https://github.com/highlightjs/highlightjs-liquid) |
|
||||
| Lisp | lisp | |
|
||||
| LiveCode Server | livecodeserver | |
|
||||
| LiveScript | livescript, ls | |
|
||||
| LookML | lookml | [highlightjs-lookml](https://github.com/spectacles-ci/highlightjs-lookml) |
|
||||
| Lua | lua, pluto | |
|
||||
| Luau | luau | [highlightjs-luau](https://github.com/highlightjs/highlightjs-luau) |
|
||||
| Macaulay2 | macaulay2 | [highlightjs-macaulay2](https://github.com/d-torrance/highlightjs-macaulay2) |
|
||||
| Makefile | makefile, mk, mak, make | |
|
||||
| Markdown | markdown, md, mkdown, mkd | |
|
||||
| Mathematica | mathematica, mma, wl | |
|
||||
| Matlab | matlab | |
|
||||
| Maxima | maxima | |
|
||||
| Maya Embedded Language | mel | |
|
||||
| Mercury | mercury | |
|
||||
| MetaPost | metapost | [highlightjs-metapost](https://github.com/chupinmaxime/highlightjs-metapost) | |
|
||||
| MIPS Assembler | mips, mipsasm | |
|
||||
| Mint | mint | [highlightjs-mint](https://github.com/mint-lang/highlightjs-mint) |
|
||||
| Mirth | mirth | [highlightjs-mirth](https://github.com/highlightjs/highlightjs-mirth) |
|
||||
| mIRC Scripting Language | mirc, mrc | [highlightjs-mirc](https://github.com/highlightjs/highlightjs-mirc) |
|
||||
| Mizar | mizar | |
|
||||
| MKB | mkb | [highlightjs-mkb](https://github.com/Dereavy/highlightjs-mkb) |
|
||||
| MLIR | mlir | [highlightjs-mlir](https://github.com/highlightjs/highlightjs-mlir) |
|
||||
| Mojolicious | mojolicious | |
|
||||
| Monkey | monkey | |
|
||||
| Moonscript | moonscript, moon | |
|
||||
| Motoko | motoko, mo | [highlightjs-motoko](https://github.com/rvanasa/highlightjs-motoko) |
|
||||
| N1QL | n1ql | |
|
||||
| NSIS | nsis | |
|
||||
| Never | never | [highlightjs-never](https://github.com/never-lang/highlightjs-never) |
|
||||
| Nginx | nginx, nginxconf | |
|
||||
| Nim | nim, nimrod | |
|
||||
| Nix | nix | |
|
||||
| Oak | oak | [highlightjs-oak](https://github.com/timlabs/highlightjs-oak) |
|
||||
| Object Constraint Language | ocl | [highlightjs-ocl](https://github.com/nhomble/highlightjs-ocl) |
|
||||
| OCaml | ocaml, ml | |
|
||||
| Objective C | objectivec, mm, objc, obj-c, obj-c++, objective-c++ | |
|
||||
| Odin | odin | [highlightjs-odin](https://github.com/NinjasCL/highlightjs-odin) |
|
||||
| OpenGL Shading Language | glsl | |
|
||||
| OpenSCAD | openscad, scad | |
|
||||
| Oracle Rules Language | ruleslanguage | |
|
||||
| Oxygene | oxygene | |
|
||||
| PF | pf, pf.conf | |
|
||||
| PHP | php | |
|
||||
| Papyrus | papyrus, psc |[highlightjs-papyrus](https://github.com/Pickysaurus/highlightjs-papyrus) |
|
||||
| Parser3 | parser3 | |
|
||||
| Perl | perl, pl, pm | |
|
||||
| Phix | phix | [highlightjs-phix](https://github.com/highlightjs/highlightjs-phix) |
|
||||
| Pine Script | pine, pinescript | [highlightjs-pine](https://github.com/jeyllani/highlightjs-pine) |
|
||||
| Plaintext | plaintext, txt, text | |
|
||||
| Pony | pony | |
|
||||
| PostgreSQL & PL/pgSQL | pgsql, postgres, postgresql | |
|
||||
| PowerOn | poweron, po | [highlightjs-poweron](https://github.com/libum-llc/highlightjs-poweron) |
|
||||
| PowerShell | powershell, ps, ps1 | |
|
||||
| Processing | processing | |
|
||||
| Prolog | prolog | |
|
||||
| Properties | properties | |
|
||||
| Protocol Buffers | proto, protobuf | |
|
||||
| Puppet | puppet, pp | |
|
||||
| Python | python, py, gyp | |
|
||||
| Python profiler results | profile | |
|
||||
| Python REPL | python-repl, pycon | |
|
||||
| Q# | qsharp | [highlightjs-qsharp](https://github.com/fedonman/highlightjs-qsharp) |
|
||||
| Q | k, kdb | |
|
||||
| QML | qml | |
|
||||
| R | r | |
|
||||
| Raku | raku, perl6, p6, pm6, rakumod | [highlightjs-raku](https://github.com/highlightjs/highlightjs-raku) |
|
||||
| RakuDoc | pod6, rakudoc | [highlightjs-raku](https://github.com/highlightjs/highlightjs-raku) |
|
||||
| RakuQuoting | rakuquoting | [highlightjs-raku](https://github.com/highlightjs/highlightjs-raku) |
|
||||
| RakuRegexe | rakuregexe | [highlightjs-raku](https://github.com/highlightjs/highlightjs-raku) |
|
||||
| Razor CSHTML | cshtml, razor, razor-cshtml | [highlightjs-cshtml-razor](https://github.com/highlightjs/highlightjs-cshtml-razor) |
|
||||
| ReasonML | reasonml, re | |
|
||||
| Rebol & Red | redbol, rebol, red, red-system | [highlightjs-redbol](https://github.com/oldes/highlightjs-redbol) |
|
||||
| RenderMan RIB | rib | |
|
||||
| RenderMan RSL | rsl | |
|
||||
| ReScript | rescript, res | [highlightjs-rescript](https://github.com/tsnobip/highlightjs-rescript) |
|
||||
| RiScript | risc, riscript | [highlightjs-riscript](https://github.com/highlightjs/highlightjs-riscript) |
|
||||
| RISC-V Assembly | riscv, riscvasm | [highlightjs-riscvasm](https://github.com/highlightjs/highlightjs-riscvasm) |
|
||||
| Roboconf | graph, instances | |
|
||||
| Robot Framework | robot, rf | [highlightjs-robot](https://github.com/highlightjs/highlightjs-robot) |
|
||||
| RPM spec files | rpm-specfile, rpm, spec, rpm-spec, specfile | [highlightjs-rpm-specfile](https://github.com/highlightjs/highlightjs-rpm-specfile) |
|
||||
| Ruby | ruby, rb, gemspec, podspec, thor, irb | |
|
||||
| Rust | rust, rs | |
|
||||
| RVT Script | rvt, rvt-script | [highlightjs-rvt-script](https://github.com/Sopitive/highlightjs-rvt-script) |
|
||||
| SAS | SAS, sas | |
|
||||
| SCSS | scss | |
|
||||
| SQL | sql | |
|
||||
| STEP Part 21 | p21, step, stp | |
|
||||
| Scala | scala | |
|
||||
| Scheme | scheme | |
|
||||
| Scilab | scilab, sci | |
|
||||
| SFZ | sfz | [highlightjs-sfz](https://github.com/sfz/highlight.js) |
|
||||
| Shape Expressions | shexc | [highlightjs-shexc](https://github.com/highlightjs/highlightjs-shexc) |
|
||||
| Shell | shell, console | |
|
||||
| Smali | smali | |
|
||||
| Smalltalk | smalltalk, st | |
|
||||
| SML | sml, ml | |
|
||||
| Solidity | solidity, sol | [highlightjs-solidity](https://github.com/highlightjs/highlightjs-solidity) |
|
||||
| Splunk SPL | spl | [highlightjs-spl](https://github.com/swsoyee/highlightjs-spl) |
|
||||
| Stan | stan, stanfuncs | |
|
||||
| Stata | stata | |
|
||||
| Structured Text | iecst, scl, stl, structured-text | [highlightjs-structured-text](https://github.com/highlightjs/highlightjs-structured-text) |
|
||||
| Stylus | stylus, styl | |
|
||||
| SubUnit | subunit | |
|
||||
| Supercollider | supercollider, sc | [highlightjs-supercollider](https://github.com/highlightjs/highlightjs-supercollider) |
|
||||
| Svelte | svelte | [highlight.svelte](https://github.com/moonlitgrace/highlight.svelte) |
|
||||
| Swift | swift | |
|
||||
| Tcl | tcl, tk | |
|
||||
| Terraform (HCL) | terraform, tf, hcl | [highlightjs-terraform](https://github.com/highlightjs/highlightjs-terraform) |
|
||||
| Test Anything Protocol | tap | |
|
||||
| Thrift | thrift | |
|
||||
| Toit | toit | [toit-highlight](https://github.com/snxx-lppxx/toit-highlight) |
|
||||
| TP | tp | |
|
||||
| Transact-SQL | tsql | [highlightjs-tsql](https://github.com/highlightjs/highlightjs-tsql) |
|
||||
| TTCN-3 | ttcn, ttcnpp, ttcn3 | [highlightjs-ttcn3](https://gitea.osmocom.org/ttcn3/highlightjs-ttcn3) |
|
||||
| Twig | twig, craftcms | |
|
||||
| TypeScript | typescript, ts, tsx, mts, cts | |
|
||||
| Unicorn Rails log | unicorn-rails-log | [highlightjs-unicorn-rails-log](https://github.com/sweetppro/highlightjs-unicorn-rails-log) |
|
||||
| Unison | unison, u | [highlightjs-unison](https://github.com/highlightjs/highlightjs-unison) |
|
||||
| VB.Net | vbnet, vb | |
|
||||
| VBA | vba | [highlightjs-vba](https://github.com/dullin/highlightjs-vba) |
|
||||
| VBScript | vbscript, vbs | |
|
||||
| VHDL | vhdl | |
|
||||
| Vala | vala | |
|
||||
| Verilog | verilog, v | |
|
||||
| Vim Script | vim | |
|
||||
| WGSL | wgsl | [highlightjs-wgsl](https://github.com/highlightjs/highlightjs-wgsl) |
|
||||
| X# | xsharp, xs, prg | [highlightjs-xsharp](https://github.com/InfomindsAg/highlightjs-xsharp) |
|
||||
| X++ | axapta, x++ | |
|
||||
| x86 Assembly | x86asm | |
|
||||
| x86 Assembly (AT&T) | x86asmatt | [highlightjs-x86asmatt](https://github.com/gondow/highlightjs-x86asmatt) |
|
||||
| XL | xl, tao | |
|
||||
| XQuery | xquery, xpath, xq, xqm | |
|
||||
| YAML | yml, yaml | |
|
||||
| ZenScript | zenscript, zs |[highlightjs-zenscript](https://github.com/highlightjs/highlightjs-zenscript) |
|
||||
| Zephir | zephir, zep | |
|
||||
| Zig | zig |[highlightjs-zig](https://github.com/fwx5618177/highlightjs-zig) |
|
||||
<!-- LANGLIST_END -->
|
||||
|
||||
<!-- document it until we can fix it -->
|
||||
## Alias Overlap
|
||||
|
||||
If you are using either of these languages at the same time please be sure to
|
||||
use the full name and not the alias to avoid any ambiguity.
|
||||
|
||||
| Language | Overlap |
|
||||
| :-----------------------| :--------------------- |
|
||||
| SML | ml |
|
||||
| OCaml | ml |
|
||||
| Lasso | ls |
|
||||
| LiveScript | ls |
|
||||
|
||||
|
||||
[1]: https://github.com/highlightjs/highlight.js#getting-the-library
|
||||
[2]: https://github.com/highlightjs/highlight.js#importing-the-library
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
# Upgrading to Version 10.0
|
||||
|
||||
Welcome to version 10.0. This a major release and therefore will contain breaking changes.
|
||||
|
||||
## Breaking Changes
|
||||
|
||||
Our normal minor releases try to never break anything, holding all breaking changes for major releases.
|
||||
We tried to squeeze in as many as we could this time so that after 10.0 ships we'll be back to quiet sailing for a while before we need to push version 11. That said, we're very conservative about what we consider a breaking change.
|
||||
|
||||
*IE, if there it could possibly break things for anyone, it's typically a breaking change.* The fact is a vast majority of users should upgrade and probably not notice any changes at all.
|
||||
|
||||
See [VERSION_10_BREAKING_CHANGES.md](https://github.com/highlightjs/highlight.js/blob/main/VERSION_10_BREAKING_CHANGES.md) for a comprehensive list of breaking changes, but here is a summary... if you use:
|
||||
|
||||
### Core highlight.js lib on the client (with no extra CDN languages)
|
||||
|
||||
Just keep doing that.
|
||||
|
||||
- If you're using `darkula.css`, you'll need to change that to `darcula.css`
|
||||
- The minified distributable has changed from `.pack.js` to `.min.js`, update your name when you update your URL.
|
||||
- If your users have very old browsers, they may no longer be supported (no more IE11, etc.). (We're using ES2015 code now.)
|
||||
- `nohighlight` or `no-highlight` are the only two CSS classes that will SKIP highlighting completely. `*text*` and `*plain*` no longer will do this.
|
||||
|
||||
### Core highlight.js lib on the client (plus additional CDN languages)
|
||||
|
||||
Quite a few grammars have been renamed. Ex: `nimrod.js` is now `nim.js`.
|
||||
|
||||
- Check the renamed grammars to see if you might need to update your links.
|
||||
- Be aware that you can't use version 9 CDN JS files anymore, they aren't compatible.
|
||||
- Plus read the above list of items.
|
||||
|
||||
### highlight.js on the server (via NPM) and only use the public API
|
||||
|
||||
If you're just pulling in the FULL library (`require('./highlight.js')`) just keep doing that. You might not need to change anything.
|
||||
|
||||
- If you're manually loading a smaller set of languages and using `registerLanguage` make sure you check out all the renamed grammars and dependency changes.
|
||||
- Read the client-side lists above also.
|
||||
|
||||
### highlight.js on the server (via NPM) with a custom integration
|
||||
|
||||
Read the complete breaking changes list carefully.
|
||||
|
||||
- Read the client-side lists above also.
|
||||
|
||||
### highlight.js lib on the client, with source directly from our GitHub repo
|
||||
|
||||
That will no longer work. The source needs to be built to work properly and cannot be used "raw" unless you've also setup your own build pipeline (rollup, etc.). Fetch a static build from the CDN, the [cdn-release repo](https://github.com/highlightjs/cdn-release) or use the new [`highlightjs-dist`]() NPM package.
|
||||
|
||||
### highlight.js source code directly from our GitHub repo with a custom integration
|
||||
|
||||
All bets are off, since we only try to guarantee stability of our NPM and CDN builds and the public API. Read all the breaking changes and perhaps skim the commit history.
|
||||
|
||||
- We're using ES6 modules now.
|
||||
- We're using an entirely new build system.
|
||||
- The source will likely become more and more modular during the 10.0 timeline.
|
||||
|
||||
## Enjoy and good luck.
|
||||
|
||||
As always if you have any questions or issues, jump on the [Github Issues](https://github.com/highlightjs/highlight.js/issues).
|
||||
+203
@@ -0,0 +1,203 @@
|
||||
# Upgrading to Highlight.js v11.0
|
||||
|
||||
- [Overview of Breaking Changes](#overview-of-breaking-changes)
|
||||
- [Built-in set of "Common" Languages](#built-in-set-of-common-languages)
|
||||
- [Language Files](#language-files)
|
||||
- [Language Aliases](#language-aliases)
|
||||
- [Styles and CSS](#styles-and-css)
|
||||
- [Grammar Scopes](#grammar-scopes)
|
||||
- [Behavioral changes](#behavioral-changes)
|
||||
- [API changes](#api-changes)
|
||||
- [Changes to Result Data](#changes-to-result-data)
|
||||
- [Feature Removal](#feature-removal)
|
||||
- [Small Things](#small-things)
|
||||
- [Upgrading from Version 9.x](#upgrading-from-version-9x)
|
||||
|
||||
|
||||
## Overview of Breaking Changes
|
||||
|
||||
Welcome to version 11.0. This a major release and therefore contains breaking changes. Below is a complete list of those such changes.
|
||||
|
||||
|
||||
### Built-in set of "Common" Languages
|
||||
|
||||
The default `highlight.min.js` build **removes** a few less popular grammars:
|
||||
|
||||
- apache
|
||||
- http
|
||||
- nginx
|
||||
- properties
|
||||
- coffeescript
|
||||
|
||||
If you need any of these, you can always create a custom build.
|
||||
|
||||
Ref: https://github.com/highlightjs/highlight.js/issues/2848
|
||||
|
||||
|
||||
### Language Files
|
||||
|
||||
This would matter if you are requiring any of these files directly (via Node.js or CDN).
|
||||
|
||||
- `htmlbars` has been removed. Use `handlebars` instead.
|
||||
- `c-like` has been removed. Use `c`, `cpp`, or `arduino`.
|
||||
- `sql_more` has been removed. Use `sql` instead or a more specific 3rd party grammar.
|
||||
|
||||
|
||||
### Language Aliases
|
||||
|
||||
This would matter if you are using these aliases.
|
||||
|
||||
- `php3`,`php4`,`php5`, `php6`, `php7`, and `php8` have been removed. Use `php` instead.
|
||||
- `zsh` has been removed. Use `sh` or `bash` instead.
|
||||
- `freepascal`, `lazarus`, `lpr`, and `lpm` removed. Use `delphi` instead.
|
||||
|
||||
You can of course re-register any of these aliases easily if necessary. For example to restore the PHP aliases:
|
||||
|
||||
```js
|
||||
hljs.registerAliases(["php3","php4","php5","php6","php7","php8"],{ languageName: "php" })
|
||||
```
|
||||
|
||||
### Styles and CSS
|
||||
|
||||
- The default padding on `.hljs` element has been increased and is now `1em` (it was `0.5em` previously). If your design depends on the smaller spacing you may need to update your CSS to override.
|
||||
- `schoolbook` no longer has a custom lined background, it is solid color now. The old image and CSS can be found in the [10-stable branch](https://github.com/highlightjs/highlight.js/tree/10-stable/src/styles) if you wish to manually copy it into your project.
|
||||
- `github` includes significant changes to more properly match modern GitHub syntax highlighting. If you desire the old theme you can manually copy it into your project from the [10-stable branch](https://github.com/highlightjs/highlight.js/tree/10-stable/src/styles).
|
||||
- `github-gist` has been removed in favor of `github` as GitHub and GitHub Gist have converged. If you desire the theme you can manually copy it into your project from the [10-stable branch](https://github.com/highlightjs/highlight.js/tree/10-stable/src/styles).
|
||||
- The `.hljs` CSS selector is now further scoped. It now targets `code.hljs` (inline code) and `pre code.hljs` (code blocks). If you are using a different element you may need to update your CSS to reapply some styling.
|
||||
- All [Base16 themes](https://github.com/highlightjs/base16-highlightjs) now live in the `styles/base16` directory - this means some CSS files have moved. Please confirm themes you use reference the new locations.
|
||||
|
||||
|
||||
#### Grammar Scopes
|
||||
|
||||
- `.meta-string` removed/deprecated. Use `.meta .string` (a nested scope) instead. See [meta-keyword][].
|
||||
- `.meta-keyword` removed/deprecated. Use `.meta .keyword` (a nested scope) instead. See [meta-keyword][].
|
||||
|
||||
### Behavioral changes
|
||||
|
||||
- `after:highlightElement` plugin callback is now fired *after* the DOM has been updated, not before.
|
||||
|
||||
#### API changes
|
||||
|
||||
- The option `ignoreIllegals` is now `true` by default (for `highlight()`). Previously it was `false`.
|
||||
- The `highlight(language,code, ...args)` API no longer accepts `continuation` as a 4th argument.
|
||||
- The `highlight(language,code, ...args)` API is deprecated (to be removed in 12.0).
|
||||
|
||||
The new call signature is `highlight(code, {options})`. ([see docs](https://highlightjs.readthedocs.io/en/latest/api.html#highlight))
|
||||
|
||||
Code using the old API:
|
||||
|
||||
```js
|
||||
// highlight(language, code, ignoreIllegals, continuation)
|
||||
highlight("javascript", "var a = 5;", true)
|
||||
```
|
||||
...would be upgraded to the newer API as follows:
|
||||
|
||||
```js
|
||||
// highlight(code, {language, ignoreIllegals})
|
||||
highlight("var a = 5;", {language: "javascript", ignoreIllegals: true})
|
||||
```
|
||||
|
||||
The new API purposely does not support `continuation` as this is only intended for internal library usage.
|
||||
|
||||
- `initHighlighting()` is deprecated (to be removed in 12.0).
|
||||
- `initHighlightingOnLoad()` is deprecated (to be removed in 12.0).
|
||||
|
||||
**Use `highlightAll()` instead.** ([see docs](https://highlightjs.readthedocs.io/en/latest/api.html#highlight-all)) The old functions are now simply aliases of `highlightAll()`. The new function may be called before or after the DOM is loaded and should do the correct thing in all cases, replacing the need for the previous individual functions.
|
||||
|
||||
Note: `highlightAll()` does not guard against calling itself repeatedly as the previous functions did. Your code should be careful to avoid doing this.
|
||||
|
||||
- `highlightBlock()` is deprecated (to be removed in 12.0).
|
||||
|
||||
**Use `highlightElement()` instead.** ([see docs](https://highlightjs.readthedocs.io/en/latest/api.html#highlight-element)) This is merely a naming change.
|
||||
|
||||
Note: The object literal passed to the `before:highlightElement` callback now passes the element in the `el` key vs the `block` key.
|
||||
|
||||
##### Changes to Result Data
|
||||
|
||||
- `highlightAuto()`'s `second_best` key has been renamed to `secondBest`
|
||||
- `highlightElement()`'s result now no longer includes a `re` key. Use the `relevance` key now.
|
||||
- `highlight()` renames some result keys to more clearly mark them as private: `_top`, `_emitter`, and `_illegalBy`. You should not depend on these keys as they are subject to change at any time.
|
||||
- The `relevance` key returned by `highlight()` is no longer guaranteed to be an even integer.
|
||||
- `highlightElement` now always tags blocks with a consistent `language-[name]` class
|
||||
|
||||
This behavior was inconsistent before. Sometimes `[name]` class would be added, sometimes the alias name would be added, something no class would be added. now `language-[name]` is always added. This also affects sublanguage `span` tags which now also include the `language-` prefix.
|
||||
|
||||
#### Feature Removal
|
||||
|
||||
- HTML auto-passthru is now no longer included in core. Use a plugin instead. For a possible plugin please see [#2889](https://github.com/highlightjs/highlight.js/issues/2889).
|
||||
|
||||
An example:
|
||||
|
||||
```html
|
||||
<pre><code class="lang-js">
|
||||
var a = 4;
|
||||
<span class="yellow">var a = 4;</span>
|
||||
</code></pre>
|
||||
```
|
||||
|
||||
Unescaped HTML like this will now be ignored (stripped before highlighting) and a warning will be logged to the console. All HTML to be highlighted should be properly escaped to avoid potential HTML/JS injection attacks.
|
||||
|
||||
- `fixMarkup` has been removed.
|
||||
|
||||
This function was deprecated in v10.2. It is not our goal to provide random string utilities. You may need to provide your own replacement [Ref: #2534](https://github.com/highlightjs/highlight.js/issues/2634)
|
||||
|
||||
- `CSS_NUMBER_MODE` has been removed.
|
||||
|
||||
This rule was too broad for bring inclusion in core and has been removed.
|
||||
|
||||
- `lexemes` mode attribute has been removed.
|
||||
|
||||
Use the new `keywords.$pattern` instead.
|
||||
|
||||
Before:
|
||||
|
||||
```js
|
||||
{
|
||||
keywords: "do.it start.now begin.later end.immediately"
|
||||
lexemes: /[a-z.]+/
|
||||
}
|
||||
```
|
||||
|
||||
After:
|
||||
|
||||
```js
|
||||
{
|
||||
keywords: {
|
||||
$pattern: /[a-z.]+/
|
||||
keyword: "do.it start.now begin.later end.immediately",
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This may required converting your `keywords` key into an object if it's not already (as shown above).
|
||||
|
||||
- `endSameAsBegin` mode attribute has been removed.
|
||||
|
||||
Use the new `END_SAME_AS_BEGIN` mode rule/function instead.
|
||||
|
||||
- `useBR` configuration has been removed.
|
||||
|
||||
This configuration option was deprecated in v10.1. Use a plugin or preferably simply CSS `white-space: pre`. [Ref: #2559](https://github.com/highlightjs/highlight.js/issues/2559)
|
||||
|
||||
|
||||
- `tabReplace` configuration has been removed.
|
||||
|
||||
This configuration option was deprecated in v10.5. Use a plugin or pre-render content instead with desired spacing. [Ref: #2874](https://github.com/highlightjs/highlight.js/issues/2874)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Small Things
|
||||
|
||||
- The `regex` utility `join` has been renamed to `_eitherRewriteBackreferences` (this has always been intended for internal use only)
|
||||
|
||||
### Upgrading from Version 9.x
|
||||
|
||||
If you're upgrading all the way from version 9 it may still be helpful to review all the breaking changes in version 10 as well:
|
||||
|
||||
- [VERSION_10_UPGRADE.md](https://github.com/highlightjs/highlight.js/blob/main/VERSION_10_UPGRADE.md)
|
||||
- [VERSION_10_BREAKING_CHANGES.md](https://github.com/highlightjs/highlight.js/blob/main/VERSION_10_BREAKING_CHANGES.md)
|
||||
|
||||
|
||||
[meta-keyword]: https://github.com/highlightjs/highlight.js/pull/3167
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import hljs from "highlight.js";
|
||||
export default hljs;
|
||||
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// https://nodejs.org/api/packages.html#packages_writing_dual_packages_while_avoiding_or_minimizing_hazards
|
||||
import HighlightJS from '../lib/common.js';
|
||||
export { HighlightJS };
|
||||
export default HighlightJS;
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import hljs from "highlight.js";
|
||||
export default hljs;
|
||||
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// https://nodejs.org/api/packages.html#packages_writing_dual_packages_while_avoiding_or_minimizing_hazards
|
||||
import HighlightJS from '../lib/core.js';
|
||||
export { HighlightJS };
|
||||
export default HighlightJS;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// https://nodejs.org/api/packages.html#packages_writing_dual_packages_while_avoiding_or_minimizing_hazards
|
||||
import HighlightJS from '../lib/index.js';
|
||||
export { HighlightJS };
|
||||
export default HighlightJS;
|
||||
+544
@@ -0,0 +1,544 @@
|
||||
/*
|
||||
Language: 1C:Enterprise
|
||||
Author: Stanislav Belov <stbelov@gmail.com>
|
||||
Description: built-in language 1C:Enterprise (v7, v8)
|
||||
Category: enterprise
|
||||
*/
|
||||
|
||||
function _1c(hljs) {
|
||||
// общий паттерн для определения идентификаторов
|
||||
const UNDERSCORE_IDENT_RE = '[A-Za-zА-Яа-яёЁ_][A-Za-zА-Яа-яёЁ_0-9]+';
|
||||
|
||||
// v7 уникальные ключевые слова, отсутствующие в v8 ==> keyword
|
||||
const v7_keywords =
|
||||
'далее ';
|
||||
|
||||
// v8 ключевые слова ==> keyword
|
||||
const v8_keywords =
|
||||
'возврат вызватьисключение выполнить для если и из или иначе иначеесли исключение каждого конецесли '
|
||||
+ 'конецпопытки конеццикла не новый перейти перем по пока попытка прервать продолжить тогда цикл экспорт ';
|
||||
|
||||
// keyword : ключевые слова
|
||||
const KEYWORD = v7_keywords + v8_keywords;
|
||||
|
||||
// v7 уникальные директивы, отсутствующие в v8 ==> meta-keyword
|
||||
const v7_meta_keywords =
|
||||
'загрузитьизфайла ';
|
||||
|
||||
// v8 ключевые слова в инструкциях препроцессора, директивах компиляции, аннотациях ==> meta-keyword
|
||||
const v8_meta_keywords =
|
||||
'вебклиент вместо внешнеесоединение клиент конецобласти мобильноеприложениеклиент мобильноеприложениесервер '
|
||||
+ 'наклиенте наклиентенасервере наклиентенасерверебезконтекста насервере насерверебезконтекста область перед '
|
||||
+ 'после сервер толстыйклиентобычноеприложение толстыйклиентуправляемоеприложение тонкийклиент ';
|
||||
|
||||
// meta-keyword : ключевые слова в инструкциях препроцессора, директивах компиляции, аннотациях
|
||||
const METAKEYWORD = v7_meta_keywords + v8_meta_keywords;
|
||||
|
||||
// v7 системные константы ==> built_in
|
||||
const v7_system_constants =
|
||||
'разделительстраниц разделительстрок символтабуляции ';
|
||||
|
||||
// v7 уникальные методы глобального контекста, отсутствующие в v8 ==> built_in
|
||||
const v7_global_context_methods =
|
||||
'ansitooem oemtoansi ввестивидсубконто ввестиперечисление ввестипериод ввестиплансчетов выбранныйплансчетов '
|
||||
+ 'датагод датамесяц датачисло заголовоксистемы значениевстроку значениеизстроки каталогиб каталогпользователя '
|
||||
+ 'кодсимв конгода конецпериодаби конецрассчитанногопериодаби конецстандартногоинтервала конквартала конмесяца '
|
||||
+ 'коннедели лог лог10 максимальноеколичествосубконто названиеинтерфейса названиенабораправ назначитьвид '
|
||||
+ 'назначитьсчет найтиссылки началопериодаби началостандартногоинтервала начгода начквартала начмесяца '
|
||||
+ 'начнедели номерднягода номерднянедели номернеделигода обработкаожидания основнойжурналрасчетов '
|
||||
+ 'основнойплансчетов основнойязык очиститьокносообщений периодстр получитьвремята получитьдатута '
|
||||
+ 'получитьдокументта получитьзначенияотбора получитьпозициюта получитьпустоезначение получитьта '
|
||||
+ 'префиксавтонумерации пропись пустоезначение разм разобратьпозициюдокумента рассчитатьрегистрына '
|
||||
+ 'рассчитатьрегистрыпо симв создатьобъект статусвозврата стрколичествострок сформироватьпозициюдокумента '
|
||||
+ 'счетпокоду текущеевремя типзначения типзначениястр установитьтана установитьтапо фиксшаблон шаблон ';
|
||||
|
||||
// v8 методы глобального контекста ==> built_in
|
||||
const v8_global_context_methods =
|
||||
'acos asin atan base64значение base64строка cos exp log log10 pow sin sqrt tan xmlзначение xmlстрока '
|
||||
+ 'xmlтип xmlтипзнч активноеокно безопасныйрежим безопасныйрежимразделенияданных булево ввестидату ввестизначение '
|
||||
+ 'ввестистроку ввестичисло возможностьчтенияxml вопрос восстановитьзначение врег выгрузитьжурналрегистрации '
|
||||
+ 'выполнитьобработкуоповещения выполнитьпроверкуправдоступа вычислить год данныеформывзначение дата день деньгода '
|
||||
+ 'деньнедели добавитьмесяц заблокироватьданныедляредактирования заблокироватьработупользователя завершитьработусистемы '
|
||||
+ 'загрузитьвнешнююкомпоненту закрытьсправку записатьjson записатьxml записатьдатуjson записьжурналарегистрации '
|
||||
+ 'заполнитьзначениясвойств запроситьразрешениепользователя запуститьприложение запуститьсистему зафиксироватьтранзакцию '
|
||||
+ 'значениевданныеформы значениевстрокувнутр значениевфайл значениезаполнено значениеизстрокивнутр значениеизфайла '
|
||||
+ 'изxmlтипа импортмоделиxdto имякомпьютера имяпользователя инициализироватьпредопределенныеданные информацияобошибке '
|
||||
+ 'каталогбиблиотекимобильногоустройства каталогвременныхфайлов каталогдокументов каталогпрограммы кодироватьстроку '
|
||||
+ 'кодлокализацииинформационнойбазы кодсимвола командасистемы конецгода конецдня конецквартала конецмесяца конецминуты '
|
||||
+ 'конецнедели конецчаса конфигурациябазыданныхизмененадинамически конфигурацияизменена копироватьданныеформы '
|
||||
+ 'копироватьфайл краткоепредставлениеошибки лев макс местноевремя месяц мин минута монопольныйрежим найти '
|
||||
+ 'найтинедопустимыесимволыxml найтиокнопонавигационнойссылке найтипомеченныенаудаление найтипоссылкам найтифайлы '
|
||||
+ 'началогода началодня началоквартала началомесяца началоминуты началонедели началочаса начатьзапросразрешенияпользователя '
|
||||
+ 'начатьзапускприложения начатькопированиефайла начатьперемещениефайла начатьподключениевнешнейкомпоненты '
|
||||
+ 'начатьподключениерасширенияработыскриптографией начатьподключениерасширенияработысфайлами начатьпоискфайлов '
|
||||
+ 'начатьполучениекаталогавременныхфайлов начатьполучениекаталогадокументов начатьполучениерабочегокаталогаданныхпользователя '
|
||||
+ 'начатьполучениефайлов начатьпомещениефайла начатьпомещениефайлов начатьсозданиедвоичныхданныхизфайла начатьсозданиекаталога '
|
||||
+ 'начатьтранзакцию начатьудалениефайлов начатьустановкувнешнейкомпоненты начатьустановкурасширенияработыскриптографией '
|
||||
+ 'начатьустановкурасширенияработысфайлами неделягода необходимостьзавершениясоединения номерсеансаинформационнойбазы '
|
||||
+ 'номерсоединенияинформационнойбазы нрег нстр обновитьинтерфейс обновитьнумерациюобъектов обновитьповторноиспользуемыезначения '
|
||||
+ 'обработкапрерыванияпользователя объединитьфайлы окр описаниеошибки оповестить оповеститьобизменении '
|
||||
+ 'отключитьобработчикзапросанастроекклиенталицензирования отключитьобработчикожидания отключитьобработчикоповещения '
|
||||
+ 'открытьзначение открытьиндекссправки открытьсодержаниесправки открытьсправку открытьформу открытьформумодально '
|
||||
+ 'отменитьтранзакцию очиститьжурналрегистрации очиститьнастройкипользователя очиститьсообщения параметрыдоступа '
|
||||
+ 'перейтипонавигационнойссылке переместитьфайл подключитьвнешнююкомпоненту '
|
||||
+ 'подключитьобработчикзапросанастроекклиенталицензирования подключитьобработчикожидания подключитьобработчикоповещения '
|
||||
+ 'подключитьрасширениеработыскриптографией подключитьрасширениеработысфайлами подробноепредставлениеошибки '
|
||||
+ 'показатьвводдаты показатьвводзначения показатьвводстроки показатьвводчисла показатьвопрос показатьзначение '
|
||||
+ 'показатьинформациюобошибке показатьнакарте показатьоповещениепользователя показатьпредупреждение полноеимяпользователя '
|
||||
+ 'получитьcomобъект получитьxmlтип получитьадреспоместоположению получитьблокировкусеансов получитьвремязавершенияспящегосеанса '
|
||||
+ 'получитьвремязасыпанияпассивногосеанса получитьвремяожиданияблокировкиданных получитьданныевыбора '
|
||||
+ 'получитьдополнительныйпараметрклиенталицензирования получитьдопустимыекодылокализации получитьдопустимыечасовыепояса '
|
||||
+ 'получитьзаголовокклиентскогоприложения получитьзаголовоксистемы получитьзначенияотборажурналарегистрации '
|
||||
+ 'получитьидентификаторконфигурации получитьизвременногохранилища получитьимявременногофайла '
|
||||
+ 'получитьимяклиенталицензирования получитьинформациюэкрановклиента получитьиспользованиежурналарегистрации '
|
||||
+ 'получитьиспользованиесобытияжурналарегистрации получитькраткийзаголовокприложения получитьмакетоформления '
|
||||
+ 'получитьмаскувсефайлы получитьмаскувсефайлыклиента получитьмаскувсефайлысервера получитьместоположениепоадресу '
|
||||
+ 'получитьминимальнуюдлинупаролейпользователей получитьнавигационнуюссылку получитьнавигационнуюссылкуинформационнойбазы '
|
||||
+ 'получитьобновлениеконфигурациибазыданных получитьобновлениепредопределенныхданныхинформационнойбазы получитьобщиймакет '
|
||||
+ 'получитьобщуюформу получитьокна получитьоперативнуюотметкувремени получитьотключениебезопасногорежима '
|
||||
+ 'получитьпараметрыфункциональныхопцийинтерфейса получитьполноеимяпредопределенногозначения '
|
||||
+ 'получитьпредставлениянавигационныхссылок получитьпроверкусложностипаролейпользователей получитьразделительпути '
|
||||
+ 'получитьразделительпутиклиента получитьразделительпутисервера получитьсеансыинформационнойбазы '
|
||||
+ 'получитьскоростьклиентскогосоединения получитьсоединенияинформационнойбазы получитьсообщенияпользователю '
|
||||
+ 'получитьсоответствиеобъектаиформы получитьсоставстандартногоинтерфейсаodata получитьструктурухранениябазыданных '
|
||||
+ 'получитьтекущийсеансинформационнойбазы получитьфайл получитьфайлы получитьформу получитьфункциональнуюопцию '
|
||||
+ 'получитьфункциональнуюопциюинтерфейса получитьчасовойпоясинформационнойбазы пользователиос поместитьвовременноехранилище '
|
||||
+ 'поместитьфайл поместитьфайлы прав праводоступа предопределенноезначение представлениекодалокализации представлениепериода '
|
||||
+ 'представлениеправа представлениеприложения представлениесобытияжурналарегистрации представлениечасовогопояса предупреждение '
|
||||
+ 'прекратитьработусистемы привилегированныйрежим продолжитьвызов прочитатьjson прочитатьxml прочитатьдатуjson пустаястрока '
|
||||
+ 'рабочийкаталогданныхпользователя разблокироватьданныедляредактирования разделитьфайл разорватьсоединениесвнешнимисточникомданных '
|
||||
+ 'раскодироватьстроку рольдоступна секунда сигнал символ скопироватьжурналрегистрации смещениелетнеговремени '
|
||||
+ 'смещениестандартноговремени соединитьбуферыдвоичныхданных создатькаталог создатьфабрикуxdto сокрл сокрлп сокрп сообщить '
|
||||
+ 'состояние сохранитьзначение сохранитьнастройкипользователя сред стрдлина стрзаканчиваетсяна стрзаменить стрнайти стрначинаетсяс '
|
||||
+ 'строка строкасоединенияинформационнойбазы стрполучитьстроку стрразделить стрсоединить стрсравнить стрчисловхождений '
|
||||
+ 'стрчислострок стршаблон текущаядата текущаядатасеанса текущаяуниверсальнаядата текущаяуниверсальнаядатавмиллисекундах '
|
||||
+ 'текущийвариантинтерфейсаклиентскогоприложения текущийвариантосновногошрифтаклиентскогоприложения текущийкодлокализации '
|
||||
+ 'текущийрежимзапуска текущийязык текущийязыксистемы тип типзнч транзакцияактивна трег удалитьданныеинформационнойбазы '
|
||||
+ 'удалитьизвременногохранилища удалитьобъекты удалитьфайлы универсальноевремя установитьбезопасныйрежим '
|
||||
+ 'установитьбезопасныйрежимразделенияданных установитьблокировкусеансов установитьвнешнююкомпоненту '
|
||||
+ 'установитьвремязавершенияспящегосеанса установитьвремязасыпанияпассивногосеанса установитьвремяожиданияблокировкиданных '
|
||||
+ 'установитьзаголовокклиентскогоприложения установитьзаголовоксистемы установитьиспользованиежурналарегистрации '
|
||||
+ 'установитьиспользованиесобытияжурналарегистрации установитькраткийзаголовокприложения '
|
||||
+ 'установитьминимальнуюдлинупаролейпользователей установитьмонопольныйрежим установитьнастройкиклиенталицензирования '
|
||||
+ 'установитьобновлениепредопределенныхданныхинформационнойбазы установитьотключениебезопасногорежима '
|
||||
+ 'установитьпараметрыфункциональныхопцийинтерфейса установитьпривилегированныйрежим '
|
||||
+ 'установитьпроверкусложностипаролейпользователей установитьрасширениеработыскриптографией '
|
||||
+ 'установитьрасширениеработысфайлами установитьсоединениесвнешнимисточникомданных установитьсоответствиеобъектаиформы '
|
||||
+ 'установитьсоставстандартногоинтерфейсаodata установитьчасовойпоясинформационнойбазы установитьчасовойпояссеанса '
|
||||
+ 'формат цел час часовойпояс часовойпояссеанса число числопрописью этоадресвременногохранилища ';
|
||||
|
||||
// v8 свойства глобального контекста ==> built_in
|
||||
const v8_global_context_property =
|
||||
'wsссылки библиотекакартинок библиотекамакетовоформлениякомпоновкиданных библиотекастилей бизнеспроцессы '
|
||||
+ 'внешниеисточникиданных внешниеобработки внешниеотчеты встроенныепокупки главныйинтерфейс главныйстиль '
|
||||
+ 'документы доставляемыеуведомления журналыдокументов задачи информацияобинтернетсоединении использованиерабочейдаты '
|
||||
+ 'историяработыпользователя константы критерииотбора метаданные обработки отображениерекламы отправкадоставляемыхуведомлений '
|
||||
+ 'отчеты панельзадачос параметрзапуска параметрысеанса перечисления планывидоврасчета планывидовхарактеристик '
|
||||
+ 'планыобмена планысчетов полнотекстовыйпоиск пользователиинформационнойбазы последовательности проверкавстроенныхпокупок '
|
||||
+ 'рабочаядата расширенияконфигурации регистрыбухгалтерии регистрынакопления регистрырасчета регистрысведений '
|
||||
+ 'регламентныезадания сериализаторxdto справочники средствагеопозиционирования средствакриптографии средствамультимедиа '
|
||||
+ 'средстваотображениярекламы средствапочты средствателефонии фабрикаxdto файловыепотоки фоновыезадания хранилищанастроек '
|
||||
+ 'хранилищевариантовотчетов хранилищенастроекданныхформ хранилищеобщихнастроек хранилищепользовательскихнастроекдинамическихсписков '
|
||||
+ 'хранилищепользовательскихнастроекотчетов хранилищесистемныхнастроек ';
|
||||
|
||||
// built_in : встроенные или библиотечные объекты (константы, классы, функции)
|
||||
const BUILTIN =
|
||||
v7_system_constants
|
||||
+ v7_global_context_methods + v8_global_context_methods
|
||||
+ v8_global_context_property;
|
||||
|
||||
// v8 системные наборы значений ==> class
|
||||
const v8_system_sets_of_values =
|
||||
'webцвета windowsцвета windowsшрифты библиотекакартинок рамкистиля символы цветастиля шрифтыстиля ';
|
||||
|
||||
// v8 системные перечисления - интерфейсные ==> class
|
||||
const v8_system_enums_interface =
|
||||
'автоматическоесохранениеданныхформывнастройках автонумерациявформе автораздвижениесерий '
|
||||
+ 'анимациядиаграммы вариантвыравниванияэлементовизаголовков вариантуправлениявысотойтаблицы '
|
||||
+ 'вертикальнаяпрокруткаформы вертикальноеположение вертикальноеположениеэлемента видгруппыформы '
|
||||
+ 'виддекорацииформы виддополненияэлементаформы видизмененияданных видкнопкиформы видпереключателя '
|
||||
+ 'видподписейкдиаграмме видполяформы видфлажка влияниеразмеранапузырекдиаграммы горизонтальноеположение '
|
||||
+ 'горизонтальноеположениеэлемента группировкаколонок группировкаподчиненныхэлементовформы '
|
||||
+ 'группыиэлементы действиеперетаскивания дополнительныйрежимотображения допустимыедействияперетаскивания '
|
||||
+ 'интервалмеждуэлементамиформы использованиевывода использованиеполосыпрокрутки '
|
||||
+ 'используемоезначениеточкибиржевойдиаграммы историявыборапривводе источникзначенийоситочекдиаграммы '
|
||||
+ 'источникзначенияразмерапузырькадиаграммы категориягруппыкоманд максимумсерий начальноеотображениедерева '
|
||||
+ 'начальноеотображениесписка обновлениетекстаредактирования ориентациядендрограммы ориентациядиаграммы '
|
||||
+ 'ориентацияметокдиаграммы ориентацияметоксводнойдиаграммы ориентацияэлементаформы отображениевдиаграмме '
|
||||
+ 'отображениевлегендедиаграммы отображениегруппыкнопок отображениезаголовкашкалыдиаграммы '
|
||||
+ 'отображениезначенийсводнойдиаграммы отображениезначенияизмерительнойдиаграммы '
|
||||
+ 'отображениеинтерваладиаграммыганта отображениекнопки отображениекнопкивыбора отображениеобсужденийформы '
|
||||
+ 'отображениеобычнойгруппы отображениеотрицательныхзначенийпузырьковойдиаграммы отображениепанелипоиска '
|
||||
+ 'отображениеподсказки отображениепредупрежденияприредактировании отображениеразметкиполосырегулирования '
|
||||
+ 'отображениестраницформы отображениетаблицы отображениетекстазначениядиаграммыганта '
|
||||
+ 'отображениеуправленияобычнойгруппы отображениефигурыкнопки палитрацветовдиаграммы поведениеобычнойгруппы '
|
||||
+ 'поддержкамасштабадендрограммы поддержкамасштабадиаграммыганта поддержкамасштабасводнойдиаграммы '
|
||||
+ 'поисквтаблицепривводе положениезаголовкаэлементаформы положениекартинкикнопкиформы '
|
||||
+ 'положениекартинкиэлементаграфическойсхемы положениекоманднойпанелиформы положениекоманднойпанелиэлементаформы '
|
||||
+ 'положениеопорнойточкиотрисовки положениеподписейкдиаграмме положениеподписейшкалызначенийизмерительнойдиаграммы '
|
||||
+ 'положениесостоянияпросмотра положениестрокипоиска положениетекстасоединительнойлинии положениеуправленияпоиском '
|
||||
+ 'положениешкалывремени порядокотображенияточекгоризонтальнойгистограммы порядоксерийвлегендедиаграммы '
|
||||
+ 'размеркартинки расположениезаголовкашкалыдиаграммы растягиваниеповертикалидиаграммыганта '
|
||||
+ 'режимавтоотображениясостояния режимвводастроктаблицы режимвыборанезаполненного режимвыделениядаты '
|
||||
+ 'режимвыделениястрокитаблицы режимвыделениятаблицы режимизмененияразмера режимизменениясвязанногозначения '
|
||||
+ 'режимиспользованиядиалогапечати режимиспользованияпараметракоманды режиммасштабированияпросмотра '
|
||||
+ 'режимосновногоокнаклиентскогоприложения режимоткрытияокнаформы режимотображениявыделения '
|
||||
+ 'режимотображениягеографическойсхемы режимотображениязначенийсерии режимотрисовкисеткиграфическойсхемы '
|
||||
+ 'режимполупрозрачностидиаграммы режимпробеловдиаграммы режимразмещениянастранице режимредактированияколонки '
|
||||
+ 'режимсглаживаниядиаграммы режимсглаживанияиндикатора режимсписказадач сквозноевыравнивание '
|
||||
+ 'сохранениеданныхформывнастройках способзаполнениятекстазаголовкашкалыдиаграммы '
|
||||
+ 'способопределенияограничивающегозначениядиаграммы стандартнаягруппакоманд стандартноеоформление '
|
||||
+ 'статусоповещенияпользователя стильстрелки типаппроксимациилиниитрендадиаграммы типдиаграммы '
|
||||
+ 'типединицышкалывремени типимпортасерийслоягеографическойсхемы типлиниигеографическойсхемы типлиниидиаграммы '
|
||||
+ 'типмаркерагеографическойсхемы типмаркерадиаграммы типобластиоформления '
|
||||
+ 'типорганизацииисточникаданныхгеографическойсхемы типотображениясериислоягеографическойсхемы '
|
||||
+ 'типотображенияточечногообъектагеографическойсхемы типотображенияшкалыэлементалегендыгеографическойсхемы '
|
||||
+ 'типпоискаобъектовгеографическойсхемы типпроекциигеографическойсхемы типразмещенияизмерений '
|
||||
+ 'типразмещенияреквизитовизмерений типрамкиэлементауправления типсводнойдиаграммы '
|
||||
+ 'типсвязидиаграммыганта типсоединениязначенийпосериямдиаграммы типсоединенияточекдиаграммы '
|
||||
+ 'типсоединительнойлинии типстороныэлементаграфическойсхемы типформыотчета типшкалырадарнойдиаграммы '
|
||||
+ 'факторлиниитрендадиаграммы фигуракнопки фигурыграфическойсхемы фиксациявтаблице форматдняшкалывремени '
|
||||
+ 'форматкартинки ширинаподчиненныхэлементовформы ';
|
||||
|
||||
// v8 системные перечисления - свойства прикладных объектов ==> class
|
||||
const v8_system_enums_objects_properties =
|
||||
'виддвижениябухгалтерии виддвижениянакопления видпериодарегистрарасчета видсчета видточкимаршрутабизнеспроцесса '
|
||||
+ 'использованиеагрегатарегистранакопления использованиегруппиэлементов использованиережимапроведения '
|
||||
+ 'использованиесреза периодичностьагрегатарегистранакопления режимавтовремя режимзаписидокумента режимпроведениядокумента ';
|
||||
|
||||
// v8 системные перечисления - планы обмена ==> class
|
||||
const v8_system_enums_exchange_plans =
|
||||
'авторегистрацияизменений допустимыйномерсообщения отправкаэлементаданных получениеэлементаданных ';
|
||||
|
||||
// v8 системные перечисления - табличный документ ==> class
|
||||
const v8_system_enums_tabular_document =
|
||||
'использованиерасшифровкитабличногодокумента ориентациястраницы положениеитоговколоноксводнойтаблицы '
|
||||
+ 'положениеитоговстроксводнойтаблицы положениетекстаотносительнокартинки расположениезаголовкагруппировкитабличногодокумента '
|
||||
+ 'способчтениязначенийтабличногодокумента типдвустороннейпечати типзаполненияобластитабличногодокумента '
|
||||
+ 'типкурсоровтабличногодокумента типлиниирисункатабличногодокумента типлинииячейкитабличногодокумента '
|
||||
+ 'типнаправленияпереходатабличногодокумента типотображениявыделениятабличногодокумента типотображениялинийсводнойтаблицы '
|
||||
+ 'типразмещениятекстатабличногодокумента типрисункатабличногодокумента типсмещениятабличногодокумента '
|
||||
+ 'типузоратабличногодокумента типфайлатабличногодокумента точностьпечати чередованиерасположениястраниц ';
|
||||
|
||||
// v8 системные перечисления - планировщик ==> class
|
||||
const v8_system_enums_sheduler =
|
||||
'отображениевремениэлементовпланировщика ';
|
||||
|
||||
// v8 системные перечисления - форматированный документ ==> class
|
||||
const v8_system_enums_formatted_document =
|
||||
'типфайлаформатированногодокумента ';
|
||||
|
||||
// v8 системные перечисления - запрос ==> class
|
||||
const v8_system_enums_query =
|
||||
'обходрезультатазапроса типзаписизапроса ';
|
||||
|
||||
// v8 системные перечисления - построитель отчета ==> class
|
||||
const v8_system_enums_report_builder =
|
||||
'видзаполнениярасшифровкипостроителяотчета типдобавленияпредставлений типизмеренияпостроителяотчета типразмещенияитогов ';
|
||||
|
||||
// v8 системные перечисления - работа с файлами ==> class
|
||||
const v8_system_enums_files =
|
||||
'доступкфайлу режимдиалогавыборафайла режимоткрытияфайла ';
|
||||
|
||||
// v8 системные перечисления - построитель запроса ==> class
|
||||
const v8_system_enums_query_builder =
|
||||
'типизмеренияпостроителязапроса ';
|
||||
|
||||
// v8 системные перечисления - анализ данных ==> class
|
||||
const v8_system_enums_data_analysis =
|
||||
'видданныханализа методкластеризации типединицыинтервалавременианализаданных типзаполнениятаблицырезультатаанализаданных '
|
||||
+ 'типиспользованиячисловыхзначенийанализаданных типисточникаданныхпоискаассоциаций типколонкианализаданныхдереворешений '
|
||||
+ 'типколонкианализаданныхкластеризация типколонкианализаданныхобщаястатистика типколонкианализаданныхпоискассоциаций '
|
||||
+ 'типколонкианализаданныхпоискпоследовательностей типколонкимоделипрогноза типмерырасстоянияанализаданных '
|
||||
+ 'типотсеченияправилассоциации типполяанализаданных типстандартизациианализаданных типупорядочиванияправилассоциациианализаданных '
|
||||
+ 'типупорядочиванияшаблоновпоследовательностейанализаданных типупрощениядереварешений ';
|
||||
|
||||
// v8 системные перечисления - xml, json, xs, dom, xdto, web-сервисы ==> class
|
||||
const v8_system_enums_xml_json_xs_dom_xdto_ws =
|
||||
'wsнаправлениепараметра вариантxpathxs вариантзаписидатыjson вариантпростоготипаxs видгруппымоделиxs видфасетаxdto '
|
||||
+ 'действиепостроителяdom завершенностьпростоготипаxs завершенностьсоставноготипаxs завершенностьсхемыxs запрещенныеподстановкиxs '
|
||||
+ 'исключениягруппподстановкиxs категорияиспользованияатрибутаxs категорияограниченияидентичностиxs категорияограниченияпространствименxs '
|
||||
+ 'методнаследованияxs модельсодержимогоxs назначениетипаxml недопустимыеподстановкиxs обработкапробельныхсимволовxs обработкасодержимогоxs '
|
||||
+ 'ограничениезначенияxs параметрыотбораузловdom переносстрокjson позициявдокументеdom пробельныесимволыxml типатрибутаxml типзначенияjson '
|
||||
+ 'типканоническогоxml типкомпонентыxs типпроверкиxml типрезультатаdomxpath типузлаdom типузлаxml формаxml формапредставленияxs '
|
||||
+ 'форматдатыjson экранированиесимволовjson ';
|
||||
|
||||
// v8 системные перечисления - система компоновки данных ==> class
|
||||
const v8_system_enums_data_composition_system =
|
||||
'видсравнениякомпоновкиданных действиеобработкирасшифровкикомпоновкиданных направлениесортировкикомпоновкиданных '
|
||||
+ 'расположениевложенныхэлементоврезультатакомпоновкиданных расположениеитоговкомпоновкиданных расположениегруппировкикомпоновкиданных '
|
||||
+ 'расположениеполейгруппировкикомпоновкиданных расположениеполякомпоновкиданных расположениереквизитовкомпоновкиданных '
|
||||
+ 'расположениересурсовкомпоновкиданных типбухгалтерскогоостаткакомпоновкиданных типвыводатекстакомпоновкиданных '
|
||||
+ 'типгруппировкикомпоновкиданных типгруппыэлементовотборакомпоновкиданных типдополненияпериодакомпоновкиданных '
|
||||
+ 'типзаголовкаполейкомпоновкиданных типмакетагруппировкикомпоновкиданных типмакетаобластикомпоновкиданных типостаткакомпоновкиданных '
|
||||
+ 'типпериодакомпоновкиданных типразмещениятекстакомпоновкиданных типсвязинаборовданныхкомпоновкиданных типэлементарезультатакомпоновкиданных '
|
||||
+ 'расположениелегендыдиаграммыкомпоновкиданных типпримененияотборакомпоновкиданных режимотображенияэлементанастройкикомпоновкиданных '
|
||||
+ 'режимотображениянастроеккомпоновкиданных состояниеэлементанастройкикомпоновкиданных способвосстановлениянастроеккомпоновкиданных '
|
||||
+ 'режимкомпоновкирезультата использованиепараметракомпоновкиданных автопозицияресурсовкомпоновкиданных '
|
||||
+ 'вариантиспользованиягруппировкикомпоновкиданных расположениересурсоввдиаграммекомпоновкиданных фиксациякомпоновкиданных '
|
||||
+ 'использованиеусловногооформлениякомпоновкиданных ';
|
||||
|
||||
// v8 системные перечисления - почта ==> class
|
||||
const v8_system_enums_email =
|
||||
'важностьинтернетпочтовогосообщения обработкатекстаинтернетпочтовогосообщения способкодированияинтернетпочтовоговложения '
|
||||
+ 'способкодированиянеasciiсимволовинтернетпочтовогосообщения типтекстапочтовогосообщения протоколинтернетпочты '
|
||||
+ 'статусразборапочтовогосообщения ';
|
||||
|
||||
// v8 системные перечисления - журнал регистрации ==> class
|
||||
const v8_system_enums_logbook =
|
||||
'режимтранзакциизаписижурналарегистрации статустранзакциизаписижурналарегистрации уровеньжурналарегистрации ';
|
||||
|
||||
// v8 системные перечисления - криптография ==> class
|
||||
const v8_system_enums_cryptography =
|
||||
'расположениехранилищасертификатовкриптографии режимвключениясертификатовкриптографии режимпроверкисертификатакриптографии '
|
||||
+ 'типхранилищасертификатовкриптографии ';
|
||||
|
||||
// v8 системные перечисления - ZIP ==> class
|
||||
const v8_system_enums_zip =
|
||||
'кодировкаименфайловвzipфайле методсжатияzip методшифрованияzip режимвосстановленияпутейфайловzip режимобработкиподкаталоговzip '
|
||||
+ 'режимсохраненияпутейzip уровеньсжатияzip ';
|
||||
|
||||
// v8 системные перечисления -
|
||||
// Блокировка данных, Фоновые задания, Автоматизированное тестирование,
|
||||
// Доставляемые уведомления, Встроенные покупки, Интернет, Работа с двоичными данными ==> class
|
||||
const v8_system_enums_other =
|
||||
'звуковоеоповещение направлениепереходакстроке позициявпотоке порядокбайтов режимблокировкиданных режимуправленияблокировкойданных '
|
||||
+ 'сервисвстроенныхпокупок состояниефоновогозадания типподписчикадоставляемыхуведомлений уровеньиспользованиязащищенногосоединенияftp ';
|
||||
|
||||
// v8 системные перечисления - схема запроса ==> class
|
||||
const v8_system_enums_request_schema =
|
||||
'направлениепорядкасхемызапроса типдополненияпериодамисхемызапроса типконтрольнойточкисхемызапроса типобъединениясхемызапроса '
|
||||
+ 'типпараметрадоступнойтаблицысхемызапроса типсоединениясхемызапроса ';
|
||||
|
||||
// v8 системные перечисления - свойства объектов метаданных ==> class
|
||||
const v8_system_enums_properties_of_metadata_objects =
|
||||
'httpметод автоиспользованиеобщегореквизита автопрефиксномеразадачи вариантвстроенногоязыка видиерархии видрегистранакопления '
|
||||
+ 'видтаблицывнешнегоисточникаданных записьдвиженийприпроведении заполнениепоследовательностей индексирование '
|
||||
+ 'использованиебазыпланавидоврасчета использованиебыстроговыбора использованиеобщегореквизита использованиеподчинения '
|
||||
+ 'использованиеполнотекстовогопоиска использованиеразделяемыхданныхобщегореквизита использованиереквизита '
|
||||
+ 'назначениеиспользованияприложения назначениерасширенияконфигурации направлениепередачи обновлениепредопределенныхданных '
|
||||
+ 'оперативноепроведение основноепредставлениевидарасчета основноепредставлениевидахарактеристики основноепредставлениезадачи '
|
||||
+ 'основноепредставлениепланаобмена основноепредставлениесправочника основноепредставлениесчета перемещениеграницыприпроведении '
|
||||
+ 'периодичностьномерабизнеспроцесса периодичностьномерадокумента периодичностьрегистрарасчета периодичностьрегистрасведений '
|
||||
+ 'повторноеиспользованиевозвращаемыхзначений полнотекстовыйпоискпривводепостроке принадлежностьобъекта проведение '
|
||||
+ 'разделениеаутентификацииобщегореквизита разделениеданныхобщегореквизита разделениерасширенийконфигурацииобщегореквизита '
|
||||
+ 'режимавтонумерацииобъектов режимзаписирегистра режимиспользованиямодальности '
|
||||
+ 'режимиспользованиясинхронныхвызововрасширенийплатформыивнешнихкомпонент режимповторногоиспользованиясеансов '
|
||||
+ 'режимполученияданныхвыборапривводепостроке режимсовместимости режимсовместимостиинтерфейса '
|
||||
+ 'режимуправленияблокировкойданныхпоумолчанию сериикодовпланавидовхарактеристик сериикодовпланасчетов '
|
||||
+ 'сериикодовсправочника созданиепривводе способвыбора способпоискастрокипривводепостроке способредактирования '
|
||||
+ 'типданныхтаблицывнешнегоисточникаданных типкодапланавидоврасчета типкодасправочника типмакета типномерабизнеспроцесса '
|
||||
+ 'типномерадокумента типномеразадачи типформы удалениедвижений ';
|
||||
|
||||
// v8 системные перечисления - разные ==> class
|
||||
const v8_system_enums_differents =
|
||||
'важностьпроблемыприменениярасширенияконфигурации вариантинтерфейсаклиентскогоприложения вариантмасштабаформклиентскогоприложения '
|
||||
+ 'вариантосновногошрифтаклиентскогоприложения вариантстандартногопериода вариантстандартнойдатыначала видграницы видкартинки '
|
||||
+ 'видотображенияполнотекстовогопоиска видрамки видсравнения видцвета видчисловогозначения видшрифта допустимаядлина допустимыйзнак '
|
||||
+ 'использованиеbyteordermark использованиеметаданныхполнотекстовогопоиска источникрасширенийконфигурации клавиша кодвозвратадиалога '
|
||||
+ 'кодировкаxbase кодировкатекста направлениепоиска направлениесортировки обновлениепредопределенныхданных обновлениеприизмененииданных '
|
||||
+ 'отображениепанелиразделов проверказаполнения режимдиалогавопрос режимзапускаклиентскогоприложения режимокругления режимоткрытияформприложения '
|
||||
+ 'режимполнотекстовогопоиска скоростьклиентскогосоединения состояниевнешнегоисточникаданных состояниеобновленияконфигурациибазыданных '
|
||||
+ 'способвыборасертификатаwindows способкодированиястроки статуссообщения типвнешнейкомпоненты типплатформы типповеденияклавишиenter '
|
||||
+ 'типэлементаинформацииовыполненииобновленияконфигурациибазыданных уровеньизоляциитранзакций хешфункция частидаты';
|
||||
|
||||
// class: встроенные наборы значений, системные перечисления (содержат дочерние значения, обращения к которым через разыменование)
|
||||
const CLASS =
|
||||
v8_system_sets_of_values
|
||||
+ v8_system_enums_interface
|
||||
+ v8_system_enums_objects_properties
|
||||
+ v8_system_enums_exchange_plans
|
||||
+ v8_system_enums_tabular_document
|
||||
+ v8_system_enums_sheduler
|
||||
+ v8_system_enums_formatted_document
|
||||
+ v8_system_enums_query
|
||||
+ v8_system_enums_report_builder
|
||||
+ v8_system_enums_files
|
||||
+ v8_system_enums_query_builder
|
||||
+ v8_system_enums_data_analysis
|
||||
+ v8_system_enums_xml_json_xs_dom_xdto_ws
|
||||
+ v8_system_enums_data_composition_system
|
||||
+ v8_system_enums_email
|
||||
+ v8_system_enums_logbook
|
||||
+ v8_system_enums_cryptography
|
||||
+ v8_system_enums_zip
|
||||
+ v8_system_enums_other
|
||||
+ v8_system_enums_request_schema
|
||||
+ v8_system_enums_properties_of_metadata_objects
|
||||
+ v8_system_enums_differents;
|
||||
|
||||
// v8 общие объекты (у объектов есть конструктор, экземпляры создаются методом НОВЫЙ) ==> type
|
||||
const v8_shared_object =
|
||||
'comобъект ftpсоединение httpзапрос httpсервисответ httpсоединение wsопределения wsпрокси xbase анализданных аннотацияxs '
|
||||
+ 'блокировкаданных буфердвоичныхданных включениеxs выражениекомпоновкиданных генераторслучайныхчисел географическаясхема '
|
||||
+ 'географическиекоординаты графическаясхема группамоделиxs данныерасшифровкикомпоновкиданных двоичныеданные дендрограмма '
|
||||
+ 'диаграмма диаграммаганта диалогвыборафайла диалогвыборацвета диалогвыборашрифта диалограсписаниярегламентногозадания '
|
||||
+ 'диалогредактированиястандартногопериода диапазон документdom документhtml документацияxs доставляемоеуведомление '
|
||||
+ 'записьdom записьfastinfoset записьhtml записьjson записьxml записьzipфайла записьданных записьтекста записьузловdom '
|
||||
+ 'запрос защищенноесоединениеopenssl значенияполейрасшифровкикомпоновкиданных извлечениетекста импортxs интернетпочта '
|
||||
+ 'интернетпочтовоесообщение интернетпочтовыйпрофиль интернетпрокси интернетсоединение информациядляприложенияxs '
|
||||
+ 'использованиеатрибутаxs использованиесобытияжурналарегистрации источникдоступныхнастроеккомпоновкиданных '
|
||||
+ 'итераторузловdom картинка квалификаторыдаты квалификаторыдвоичныхданных квалификаторыстроки квалификаторычисла '
|
||||
+ 'компоновщикмакетакомпоновкиданных компоновщикнастроеккомпоновкиданных конструктормакетаоформлениякомпоновкиданных '
|
||||
+ 'конструкторнастроеккомпоновкиданных конструкторформатнойстроки линия макеткомпоновкиданных макетобластикомпоновкиданных '
|
||||
+ 'макетоформлениякомпоновкиданных маскаxs менеджеркриптографии наборсхемxml настройкикомпоновкиданных настройкисериализацииjson '
|
||||
+ 'обработкакартинок обработкарасшифровкикомпоновкиданных обходдереваdom объявлениеатрибутаxs объявлениенотацииxs '
|
||||
+ 'объявлениеэлементаxs описаниеиспользованиясобытиядоступжурналарегистрации '
|
||||
+ 'описаниеиспользованиясобытияотказвдоступежурналарегистрации описаниеобработкирасшифровкикомпоновкиданных '
|
||||
+ 'описаниепередаваемогофайла описаниетипов определениегруппыатрибутовxs определениегруппымоделиxs '
|
||||
+ 'определениеограниченияидентичностиxs определениепростоготипаxs определениесоставноготипаxs определениетипадокументаdom '
|
||||
+ 'определенияxpathxs отборкомпоновкиданных пакетотображаемыхдокументов параметрвыбора параметркомпоновкиданных '
|
||||
+ 'параметрызаписиjson параметрызаписиxml параметрычтенияxml переопределениеxs планировщик полеанализаданных '
|
||||
+ 'полекомпоновкиданных построительdom построительзапроса построительотчета построительотчетаанализаданных '
|
||||
+ 'построительсхемxml поток потоквпамяти почта почтовоесообщение преобразованиеxsl преобразованиекканоническомуxml '
|
||||
+ 'процессорвыводарезультатакомпоновкиданныхвколлекциюзначений процессорвыводарезультатакомпоновкиданныхвтабличныйдокумент '
|
||||
+ 'процессоркомпоновкиданных разыменовательпространствименdom рамка расписаниерегламентногозадания расширенноеимяxml '
|
||||
+ 'результатчтенияданных своднаядиаграмма связьпараметравыбора связьпотипу связьпотипукомпоновкиданных сериализаторxdto '
|
||||
+ 'сертификатклиентаwindows сертификатклиентафайл сертификаткриптографии сертификатыудостоверяющихцентровwindows '
|
||||
+ 'сертификатыудостоверяющихцентровфайл сжатиеданных системнаяинформация сообщениепользователю сочетаниеклавиш '
|
||||
+ 'сравнениезначений стандартнаядатаначала стандартныйпериод схемаxml схемакомпоновкиданных табличныйдокумент '
|
||||
+ 'текстовыйдокумент тестируемоеприложение типданныхxml уникальныйидентификатор фабрикаxdto файл файловыйпоток '
|
||||
+ 'фасетдлиныxs фасетколичестваразрядовдробнойчастиxs фасетмаксимальноговключающегозначенияxs '
|
||||
+ 'фасетмаксимальногоисключающегозначенияxs фасетмаксимальнойдлиныxs фасетминимальноговключающегозначенияxs '
|
||||
+ 'фасетминимальногоисключающегозначенияxs фасетминимальнойдлиныxs фасетобразцаxs фасетобщегоколичестваразрядовxs '
|
||||
+ 'фасетперечисленияxs фасетпробельныхсимволовxs фильтрузловdom форматированнаястрока форматированныйдокумент '
|
||||
+ 'фрагментxs хешированиеданных хранилищезначения цвет чтениеfastinfoset чтениеhtml чтениеjson чтениеxml чтениеzipфайла '
|
||||
+ 'чтениеданных чтениетекста чтениеузловdom шрифт элементрезультатакомпоновкиданных ';
|
||||
|
||||
// v8 универсальные коллекции значений ==> type
|
||||
const v8_universal_collection =
|
||||
'comsafearray деревозначений массив соответствие списокзначений структура таблицазначений фиксированнаяструктура '
|
||||
+ 'фиксированноесоответствие фиксированныймассив ';
|
||||
|
||||
// type : встроенные типы
|
||||
const TYPE =
|
||||
v8_shared_object
|
||||
+ v8_universal_collection;
|
||||
|
||||
// literal : примитивные типы
|
||||
const LITERAL = 'null истина ложь неопределено';
|
||||
|
||||
// number : числа
|
||||
const NUMBERS = hljs.inherit(hljs.NUMBER_MODE);
|
||||
|
||||
// string : строки
|
||||
const STRINGS = {
|
||||
className: 'string',
|
||||
begin: '"|\\|',
|
||||
end: '"|$',
|
||||
contains: [ { begin: '""' } ]
|
||||
};
|
||||
|
||||
// number : даты
|
||||
const DATE = {
|
||||
begin: "'",
|
||||
end: "'",
|
||||
excludeBegin: true,
|
||||
excludeEnd: true,
|
||||
contains: [
|
||||
{
|
||||
className: 'number',
|
||||
begin: '\\d{4}([\\.\\\\/:-]?\\d{2}){0,5}'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
const PUNCTUATION = {
|
||||
match: /[;()+\-:=,]/,
|
||||
className: "punctuation",
|
||||
relevance: 0
|
||||
};
|
||||
|
||||
// comment : комментарии
|
||||
const COMMENTS = hljs.inherit(hljs.C_LINE_COMMENT_MODE);
|
||||
|
||||
// meta : инструкции препроцессора, директивы компиляции
|
||||
const META = {
|
||||
className: 'meta',
|
||||
|
||||
begin: '#|&',
|
||||
end: '$',
|
||||
keywords: {
|
||||
$pattern: UNDERSCORE_IDENT_RE,
|
||||
keyword: KEYWORD + METAKEYWORD
|
||||
},
|
||||
contains: [ COMMENTS ]
|
||||
};
|
||||
|
||||
// symbol : метка goto
|
||||
const SYMBOL = {
|
||||
className: 'symbol',
|
||||
begin: '~',
|
||||
end: ';|:',
|
||||
excludeEnd: true
|
||||
};
|
||||
|
||||
// function : объявление процедур и функций
|
||||
const FUNCTION = {
|
||||
className: 'function',
|
||||
variants: [
|
||||
{
|
||||
begin: 'процедура|функция',
|
||||
end: '\\)',
|
||||
keywords: 'процедура функция'
|
||||
},
|
||||
{
|
||||
begin: 'конецпроцедуры|конецфункции',
|
||||
keywords: 'конецпроцедуры конецфункции'
|
||||
}
|
||||
],
|
||||
contains: [
|
||||
{
|
||||
begin: '\\(',
|
||||
end: '\\)',
|
||||
endsParent: true,
|
||||
contains: [
|
||||
{
|
||||
className: 'params',
|
||||
begin: UNDERSCORE_IDENT_RE,
|
||||
end: ',',
|
||||
excludeEnd: true,
|
||||
endsWithParent: true,
|
||||
keywords: {
|
||||
$pattern: UNDERSCORE_IDENT_RE,
|
||||
keyword: 'знач',
|
||||
literal: LITERAL
|
||||
},
|
||||
contains: [
|
||||
NUMBERS,
|
||||
STRINGS,
|
||||
DATE
|
||||
]
|
||||
},
|
||||
COMMENTS
|
||||
]
|
||||
},
|
||||
hljs.inherit(hljs.TITLE_MODE, { begin: UNDERSCORE_IDENT_RE })
|
||||
]
|
||||
};
|
||||
|
||||
return {
|
||||
name: '1C:Enterprise',
|
||||
case_insensitive: true,
|
||||
keywords: {
|
||||
$pattern: UNDERSCORE_IDENT_RE,
|
||||
keyword: KEYWORD,
|
||||
built_in: BUILTIN,
|
||||
class: CLASS,
|
||||
type: TYPE,
|
||||
literal: LITERAL
|
||||
},
|
||||
contains: [
|
||||
META,
|
||||
FUNCTION,
|
||||
COMMENTS,
|
||||
SYMBOL,
|
||||
NUMBERS,
|
||||
STRINGS,
|
||||
DATE,
|
||||
PUNCTUATION
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
export { _1c as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/1c" instead of "highlight.js/lib/languages/1c.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './1c.js';
|
||||
export default lang;
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
Language: Augmented Backus-Naur Form
|
||||
Author: Alex McKibben <alex@nullscope.net>
|
||||
Website: https://tools.ietf.org/html/rfc5234
|
||||
Category: syntax
|
||||
Audit: 2020
|
||||
*/
|
||||
|
||||
/** @type LanguageFn */
|
||||
function abnf(hljs) {
|
||||
const regex = hljs.regex;
|
||||
const IDENT = /^[a-zA-Z][a-zA-Z0-9-]*/;
|
||||
|
||||
const KEYWORDS = [
|
||||
"ALPHA",
|
||||
"BIT",
|
||||
"CHAR",
|
||||
"CR",
|
||||
"CRLF",
|
||||
"CTL",
|
||||
"DIGIT",
|
||||
"DQUOTE",
|
||||
"HEXDIG",
|
||||
"HTAB",
|
||||
"LF",
|
||||
"LWSP",
|
||||
"OCTET",
|
||||
"SP",
|
||||
"VCHAR",
|
||||
"WSP"
|
||||
];
|
||||
|
||||
const COMMENT = hljs.COMMENT(/;/, /$/);
|
||||
|
||||
const TERMINAL_BINARY = {
|
||||
scope: "symbol",
|
||||
match: /%b[0-1]+(-[0-1]+|(\.[0-1]+)+)?/
|
||||
};
|
||||
|
||||
const TERMINAL_DECIMAL = {
|
||||
scope: "symbol",
|
||||
match: /%d[0-9]+(-[0-9]+|(\.[0-9]+)+)?/
|
||||
};
|
||||
|
||||
const TERMINAL_HEXADECIMAL = {
|
||||
scope: "symbol",
|
||||
match: /%x[0-9A-F]+(-[0-9A-F]+|(\.[0-9A-F]+)+)?/
|
||||
};
|
||||
|
||||
const CASE_SENSITIVITY = {
|
||||
scope: "symbol",
|
||||
match: /%[si](?=".*")/
|
||||
};
|
||||
|
||||
const RULE_DECLARATION = {
|
||||
scope: "attribute",
|
||||
match: regex.concat(IDENT, /(?=\s*=)/)
|
||||
};
|
||||
|
||||
const ASSIGNMENT = {
|
||||
scope: "operator",
|
||||
match: /=\/?/
|
||||
};
|
||||
|
||||
return {
|
||||
name: 'Augmented Backus-Naur Form',
|
||||
illegal: /[!@#$^&',?+~`|:]/,
|
||||
keywords: KEYWORDS,
|
||||
contains: [
|
||||
ASSIGNMENT,
|
||||
RULE_DECLARATION,
|
||||
COMMENT,
|
||||
TERMINAL_BINARY,
|
||||
TERMINAL_DECIMAL,
|
||||
TERMINAL_HEXADECIMAL,
|
||||
CASE_SENSITIVITY,
|
||||
hljs.QUOTE_STRING_MODE,
|
||||
hljs.NUMBER_MODE
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
export { abnf as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/abnf" instead of "highlight.js/lib/languages/abnf.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './abnf.js';
|
||||
export default lang;
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
Language: Apache Access Log
|
||||
Author: Oleg Efimov <efimovov@gmail.com>
|
||||
Description: Apache/Nginx Access Logs
|
||||
Website: https://httpd.apache.org/docs/2.4/logs.html#accesslog
|
||||
Category: web, logs
|
||||
Audit: 2020
|
||||
*/
|
||||
|
||||
/** @type LanguageFn */
|
||||
function accesslog(hljs) {
|
||||
const regex = hljs.regex;
|
||||
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods
|
||||
const HTTP_VERBS = [
|
||||
"GET",
|
||||
"POST",
|
||||
"HEAD",
|
||||
"PUT",
|
||||
"DELETE",
|
||||
"CONNECT",
|
||||
"OPTIONS",
|
||||
"PATCH",
|
||||
"TRACE"
|
||||
];
|
||||
return {
|
||||
name: 'Apache Access Log',
|
||||
contains: [
|
||||
// IP
|
||||
{
|
||||
className: 'number',
|
||||
begin: /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(:\d{1,5})?\b/,
|
||||
relevance: 5
|
||||
},
|
||||
// Other numbers
|
||||
{
|
||||
className: 'number',
|
||||
begin: /\b\d+\b/,
|
||||
relevance: 0
|
||||
},
|
||||
// Requests
|
||||
{
|
||||
className: 'string',
|
||||
begin: regex.concat(/"/, regex.either(...HTTP_VERBS)),
|
||||
end: /"/,
|
||||
keywords: HTTP_VERBS,
|
||||
illegal: /\n/,
|
||||
relevance: 5,
|
||||
contains: [
|
||||
{
|
||||
begin: /HTTP\/[12]\.\d'/,
|
||||
relevance: 5
|
||||
}
|
||||
]
|
||||
},
|
||||
// Dates
|
||||
{
|
||||
className: 'string',
|
||||
// dates must have a certain length, this prevents matching
|
||||
// simple array accesses a[123] and [] and other common patterns
|
||||
// found in other languages
|
||||
begin: /\[\d[^\]\n]{8,}\]/,
|
||||
illegal: /\n/,
|
||||
relevance: 1
|
||||
},
|
||||
{
|
||||
className: 'string',
|
||||
begin: /\[/,
|
||||
end: /\]/,
|
||||
illegal: /\n/,
|
||||
relevance: 0
|
||||
},
|
||||
// User agent / relevance boost
|
||||
{
|
||||
className: 'string',
|
||||
begin: /"Mozilla\/\d\.\d \(/,
|
||||
end: /"/,
|
||||
illegal: /\n/,
|
||||
relevance: 3
|
||||
},
|
||||
// Strings
|
||||
{
|
||||
className: 'string',
|
||||
begin: /"/,
|
||||
end: /"/,
|
||||
illegal: /\n/,
|
||||
relevance: 0
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
export { accesslog as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/accesslog" instead of "highlight.js/lib/languages/accesslog.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './accesslog.js';
|
||||
export default lang;
|
||||
+153
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
Language: ActionScript
|
||||
Author: Alexander Myadzel <myadzel@gmail.com>
|
||||
Category: scripting
|
||||
Audit: 2020
|
||||
*/
|
||||
|
||||
/** @type LanguageFn */
|
||||
function actionscript(hljs) {
|
||||
const regex = hljs.regex;
|
||||
const IDENT_RE = /[a-zA-Z_$][a-zA-Z0-9_$]*/;
|
||||
const PKG_NAME_RE = regex.concat(
|
||||
IDENT_RE,
|
||||
regex.concat("(\\.", IDENT_RE, ")*")
|
||||
);
|
||||
const IDENT_FUNC_RETURN_TYPE_RE = /([*]|[a-zA-Z_$][a-zA-Z0-9_$]*)/;
|
||||
|
||||
const AS3_REST_ARG_MODE = {
|
||||
className: 'rest_arg',
|
||||
begin: /[.]{3}/,
|
||||
end: IDENT_RE,
|
||||
relevance: 10
|
||||
};
|
||||
|
||||
const KEYWORDS = [
|
||||
"as",
|
||||
"break",
|
||||
"case",
|
||||
"catch",
|
||||
"class",
|
||||
"const",
|
||||
"continue",
|
||||
"default",
|
||||
"delete",
|
||||
"do",
|
||||
"dynamic",
|
||||
"each",
|
||||
"else",
|
||||
"extends",
|
||||
"final",
|
||||
"finally",
|
||||
"for",
|
||||
"function",
|
||||
"get",
|
||||
"if",
|
||||
"implements",
|
||||
"import",
|
||||
"in",
|
||||
"include",
|
||||
"instanceof",
|
||||
"interface",
|
||||
"internal",
|
||||
"is",
|
||||
"namespace",
|
||||
"native",
|
||||
"new",
|
||||
"override",
|
||||
"package",
|
||||
"private",
|
||||
"protected",
|
||||
"public",
|
||||
"return",
|
||||
"set",
|
||||
"static",
|
||||
"super",
|
||||
"switch",
|
||||
"this",
|
||||
"throw",
|
||||
"try",
|
||||
"typeof",
|
||||
"use",
|
||||
"var",
|
||||
"void",
|
||||
"while",
|
||||
"with"
|
||||
];
|
||||
const LITERALS = [
|
||||
"true",
|
||||
"false",
|
||||
"null",
|
||||
"undefined"
|
||||
];
|
||||
|
||||
return {
|
||||
name: 'ActionScript',
|
||||
aliases: [ 'as' ],
|
||||
keywords: {
|
||||
keyword: KEYWORDS,
|
||||
literal: LITERALS
|
||||
},
|
||||
contains: [
|
||||
hljs.APOS_STRING_MODE,
|
||||
hljs.QUOTE_STRING_MODE,
|
||||
hljs.C_LINE_COMMENT_MODE,
|
||||
hljs.C_BLOCK_COMMENT_MODE,
|
||||
hljs.C_NUMBER_MODE,
|
||||
{
|
||||
match: [
|
||||
/\bpackage/,
|
||||
/\s+/,
|
||||
PKG_NAME_RE
|
||||
],
|
||||
className: {
|
||||
1: "keyword",
|
||||
3: "title.class"
|
||||
}
|
||||
},
|
||||
{
|
||||
match: [
|
||||
/\b(?:class|interface|extends|implements)/,
|
||||
/\s+/,
|
||||
IDENT_RE
|
||||
],
|
||||
className: {
|
||||
1: "keyword",
|
||||
3: "title.class"
|
||||
}
|
||||
},
|
||||
{
|
||||
className: 'meta',
|
||||
beginKeywords: 'import include',
|
||||
end: /;/,
|
||||
keywords: { keyword: 'import include' }
|
||||
},
|
||||
{
|
||||
beginKeywords: 'function',
|
||||
end: /[{;]/,
|
||||
excludeEnd: true,
|
||||
illegal: /\S/,
|
||||
contains: [
|
||||
hljs.inherit(hljs.TITLE_MODE, { className: "title.function" }),
|
||||
{
|
||||
className: 'params',
|
||||
begin: /\(/,
|
||||
end: /\)/,
|
||||
contains: [
|
||||
hljs.APOS_STRING_MODE,
|
||||
hljs.QUOTE_STRING_MODE,
|
||||
hljs.C_LINE_COMMENT_MODE,
|
||||
hljs.C_BLOCK_COMMENT_MODE,
|
||||
AS3_REST_ARG_MODE
|
||||
]
|
||||
},
|
||||
{ begin: regex.concat(/:\s*/, IDENT_FUNC_RETURN_TYPE_RE) }
|
||||
]
|
||||
},
|
||||
hljs.METHOD_GUARD
|
||||
],
|
||||
illegal: /#/
|
||||
};
|
||||
}
|
||||
|
||||
export { actionscript as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/actionscript" instead of "highlight.js/lib/languages/actionscript.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './actionscript.js';
|
||||
export default lang;
|
||||
+265
@@ -0,0 +1,265 @@
|
||||
/*
|
||||
Language: Ada
|
||||
Author: Lars Schulna <kartoffelbrei.mit.muskatnuss@gmail.org>
|
||||
Description: Ada is a general-purpose programming language that has great support for saftey critical and real-time applications.
|
||||
It has been developed by the DoD and thus has been used in military and safety-critical applications (like civil aviation).
|
||||
The first version appeared in the 80s, but it's still actively developed today with
|
||||
the newest standard being Ada2012.
|
||||
*/
|
||||
|
||||
// We try to support full Ada2012
|
||||
//
|
||||
// We highlight all appearances of types, keywords, literals (string, char, number, bool)
|
||||
// and titles (user defined function/procedure/package)
|
||||
// CSS classes are set accordingly
|
||||
//
|
||||
// Languages causing problems for language detection:
|
||||
// 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 */
|
||||
function ada(hljs) {
|
||||
// Regular expression for Ada numeric literals.
|
||||
// stolen form the VHDL highlighter
|
||||
|
||||
// Decimal literal:
|
||||
const INTEGER_RE = '\\d(_|\\d)*';
|
||||
const EXPONENT_RE = '[eE][-+]?' + INTEGER_RE;
|
||||
const DECIMAL_LITERAL_RE = INTEGER_RE + '(\\.' + INTEGER_RE + ')?' + '(' + EXPONENT_RE + ')?';
|
||||
|
||||
// Based literal:
|
||||
const BASED_INTEGER_RE = '\\w+';
|
||||
const BASED_LITERAL_RE = INTEGER_RE + '#' + BASED_INTEGER_RE + '(\\.' + BASED_INTEGER_RE + ')?' + '#' + '(' + EXPONENT_RE + ')?';
|
||||
|
||||
const NUMBER_RE = '\\b(' + BASED_LITERAL_RE + '|' + DECIMAL_LITERAL_RE + ')';
|
||||
|
||||
// Identifier regex
|
||||
const ID_REGEX = '[A-Za-z](_?[A-Za-z0-9.])*';
|
||||
|
||||
// bad chars, only allowed in literals
|
||||
const BAD_CHARS = `[]\\{\\}%#'"`;
|
||||
|
||||
// Ada doesn't have block comments, only line comments
|
||||
const COMMENTS = hljs.COMMENT('--', '$');
|
||||
|
||||
// variable declarations of the form
|
||||
// Foo : Bar := Baz;
|
||||
// where only Bar will be highlighted
|
||||
const VAR_DECLS = {
|
||||
// TODO: These spaces are not required by the Ada syntax
|
||||
// however, I have yet to see handwritten Ada code where
|
||||
// someone does not put spaces around :
|
||||
begin: '\\s+:\\s+',
|
||||
end: '\\s*(:=|;|\\)|=>|$)',
|
||||
// endsWithParent: true,
|
||||
// returnBegin: true,
|
||||
illegal: BAD_CHARS,
|
||||
contains: [
|
||||
{
|
||||
// workaround to avoid highlighting
|
||||
// named loops and declare blocks
|
||||
beginKeywords: 'loop for declare others',
|
||||
endsParent: true
|
||||
},
|
||||
{
|
||||
// properly highlight all modifiers
|
||||
className: 'keyword',
|
||||
beginKeywords: 'not null constant access function procedure in out aliased exception'
|
||||
},
|
||||
{
|
||||
className: 'type',
|
||||
begin: ID_REGEX,
|
||||
endsParent: true,
|
||||
relevance: 0
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
const KEYWORDS = [
|
||||
"abort",
|
||||
"else",
|
||||
"new",
|
||||
"return",
|
||||
"abs",
|
||||
"elsif",
|
||||
"not",
|
||||
"reverse",
|
||||
"abstract",
|
||||
"end",
|
||||
"accept",
|
||||
"entry",
|
||||
"select",
|
||||
"access",
|
||||
"exception",
|
||||
"of",
|
||||
"separate",
|
||||
"aliased",
|
||||
"exit",
|
||||
"or",
|
||||
"some",
|
||||
"all",
|
||||
"others",
|
||||
"subtype",
|
||||
"and",
|
||||
"for",
|
||||
"out",
|
||||
"synchronized",
|
||||
"array",
|
||||
"function",
|
||||
"overriding",
|
||||
"at",
|
||||
"tagged",
|
||||
"generic",
|
||||
"package",
|
||||
"task",
|
||||
"begin",
|
||||
"goto",
|
||||
"pragma",
|
||||
"terminate",
|
||||
"body",
|
||||
"private",
|
||||
"then",
|
||||
"if",
|
||||
"procedure",
|
||||
"type",
|
||||
"case",
|
||||
"in",
|
||||
"protected",
|
||||
"constant",
|
||||
"interface",
|
||||
"is",
|
||||
"raise",
|
||||
"use",
|
||||
"declare",
|
||||
"range",
|
||||
"delay",
|
||||
"limited",
|
||||
"record",
|
||||
"when",
|
||||
"delta",
|
||||
"loop",
|
||||
"rem",
|
||||
"while",
|
||||
"digits",
|
||||
"renames",
|
||||
"with",
|
||||
"do",
|
||||
"mod",
|
||||
"requeue",
|
||||
"xor"
|
||||
];
|
||||
|
||||
return {
|
||||
name: 'Ada',
|
||||
case_insensitive: true,
|
||||
keywords: {
|
||||
keyword: KEYWORDS,
|
||||
literal: [
|
||||
"True",
|
||||
"False"
|
||||
]
|
||||
},
|
||||
contains: [
|
||||
COMMENTS,
|
||||
// strings "foobar"
|
||||
{
|
||||
className: 'string',
|
||||
begin: /"/,
|
||||
end: /"/,
|
||||
contains: [
|
||||
{
|
||||
begin: /""/,
|
||||
relevance: 0
|
||||
}
|
||||
]
|
||||
},
|
||||
// characters ''
|
||||
{
|
||||
// character literals always contain one char
|
||||
className: 'string',
|
||||
begin: /'.'/
|
||||
},
|
||||
{
|
||||
// number literals
|
||||
className: 'number',
|
||||
begin: NUMBER_RE,
|
||||
relevance: 0
|
||||
},
|
||||
{
|
||||
// Attributes
|
||||
className: 'symbol',
|
||||
begin: "'" + ID_REGEX
|
||||
},
|
||||
{
|
||||
// package definition, maybe inside generic
|
||||
className: 'title',
|
||||
begin: '(\\bwith\\s+)?(\\bprivate\\s+)?\\bpackage\\s+(\\bbody\\s+)?',
|
||||
end: '(is|$)',
|
||||
keywords: 'package body',
|
||||
excludeBegin: true,
|
||||
excludeEnd: true,
|
||||
illegal: BAD_CHARS
|
||||
},
|
||||
{
|
||||
// function/procedure declaration/definition
|
||||
// maybe inside generic
|
||||
begin: '(\\b(with|overriding)\\s+)?\\b(function|procedure)\\s+',
|
||||
end: '(\\bis|\\bwith|\\brenames|\\)\\s*;)',
|
||||
keywords: 'overriding function procedure with is renames return',
|
||||
// we need to re-match the 'function' keyword, so that
|
||||
// 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
|
||||
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
// new type declarations
|
||||
// maybe inside generic
|
||||
className: 'type',
|
||||
begin: '\\b(sub)?type\\s+',
|
||||
end: '\\s+',
|
||||
keywords: 'type',
|
||||
excludeBegin: true,
|
||||
illegal: BAD_CHARS
|
||||
},
|
||||
|
||||
// see comment above the definition
|
||||
VAR_DECLS
|
||||
|
||||
// no markup
|
||||
// relevance boosters for small snippets
|
||||
// {begin: '\\s*=>\\s*'},
|
||||
// {begin: '\\s*:=\\s*'},
|
||||
// {begin: '\\s+:=\\s+'},
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
export { ada as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/ada" instead of "highlight.js/lib/languages/ada.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './ada.js';
|
||||
export default lang;
|
||||
+178
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
Language: AngelScript
|
||||
Author: Melissa Geels <melissa@nimble.tools>
|
||||
Category: scripting
|
||||
Website: https://www.angelcode.com/angelscript/
|
||||
*/
|
||||
|
||||
/** @type LanguageFn */
|
||||
function angelscript(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)'
|
||||
};
|
||||
|
||||
const objectHandleMode = {
|
||||
className: 'symbol',
|
||||
begin: '[a-zA-Z0-9_]+@'
|
||||
};
|
||||
|
||||
const genericMode = {
|
||||
className: 'keyword',
|
||||
begin: '<',
|
||||
end: '>',
|
||||
contains: [
|
||||
builtInTypeMode,
|
||||
objectHandleMode
|
||||
]
|
||||
};
|
||||
|
||||
builtInTypeMode.contains = [ genericMode ];
|
||||
objectHandleMode.contains = [ genericMode ];
|
||||
|
||||
const KEYWORDS = [
|
||||
"for",
|
||||
"in|0",
|
||||
"break",
|
||||
"continue",
|
||||
"while",
|
||||
"do|0",
|
||||
"return",
|
||||
"if",
|
||||
"else",
|
||||
"case",
|
||||
"switch",
|
||||
"namespace",
|
||||
"is",
|
||||
"cast",
|
||||
"or",
|
||||
"and",
|
||||
"xor",
|
||||
"not",
|
||||
"get|0",
|
||||
"in",
|
||||
"inout|10",
|
||||
"out",
|
||||
"override",
|
||||
"set|0",
|
||||
"private",
|
||||
"public",
|
||||
"const",
|
||||
"default|0",
|
||||
"final",
|
||||
"shared",
|
||||
"external",
|
||||
"mixin|10",
|
||||
"enum",
|
||||
"typedef",
|
||||
"funcdef",
|
||||
"this",
|
||||
"super",
|
||||
"import",
|
||||
"from",
|
||||
"interface",
|
||||
"abstract|0",
|
||||
"try",
|
||||
"catch",
|
||||
"protected",
|
||||
"explicit",
|
||||
"property"
|
||||
];
|
||||
|
||||
return {
|
||||
name: 'AngelScript',
|
||||
aliases: [ 'asc' ],
|
||||
|
||||
keywords: KEYWORDS,
|
||||
|
||||
// avoid close detection with C# and JS
|
||||
illegal: '(^using\\s+[A-Za-z0-9_\\.]+;$|\\bfunction\\s*[^\\(])',
|
||||
|
||||
contains: [
|
||||
{ // 'strings'
|
||||
className: 'string',
|
||||
begin: '\'',
|
||||
end: '\'',
|
||||
illegal: '\\n',
|
||||
contains: [ hljs.BACKSLASH_ESCAPE ],
|
||||
relevance: 0
|
||||
},
|
||||
|
||||
// """heredoc strings"""
|
||||
{
|
||||
className: 'string',
|
||||
begin: '"""',
|
||||
end: '"""'
|
||||
},
|
||||
|
||||
{ // "strings"
|
||||
className: 'string',
|
||||
begin: '"',
|
||||
end: '"',
|
||||
illegal: '\\n',
|
||||
contains: [ hljs.BACKSLASH_ESCAPE ],
|
||||
relevance: 0
|
||||
},
|
||||
|
||||
hljs.C_LINE_COMMENT_MODE, // single-line comments
|
||||
hljs.C_BLOCK_COMMENT_MODE, // comment blocks
|
||||
|
||||
{ // metadata
|
||||
className: 'string',
|
||||
begin: '^\\s*\\[',
|
||||
end: '\\]'
|
||||
},
|
||||
|
||||
{ // interface or namespace declaration
|
||||
beginKeywords: 'interface namespace',
|
||||
end: /\{/,
|
||||
illegal: '[;.\\-]',
|
||||
contains: [
|
||||
{ // interface or namespace name
|
||||
className: 'symbol',
|
||||
begin: '[a-zA-Z0-9_]+'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{ // class declaration
|
||||
beginKeywords: 'class',
|
||||
end: /\{/,
|
||||
illegal: '[;.\\-]',
|
||||
contains: [
|
||||
{ // class name
|
||||
className: 'symbol',
|
||||
begin: '[a-zA-Z0-9_]+',
|
||||
contains: [
|
||||
{
|
||||
begin: '[:,]\\s*',
|
||||
contains: [
|
||||
{
|
||||
className: 'symbol',
|
||||
begin: '[a-zA-Z0-9_]+'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
builtInTypeMode, // built-in types
|
||||
objectHandleMode, // object handles
|
||||
|
||||
{ // literals
|
||||
className: 'literal',
|
||||
begin: '\\b(null|true|false)'
|
||||
},
|
||||
|
||||
{ // numbers
|
||||
className: 'number',
|
||||
relevance: 0,
|
||||
begin: '(-?)(\\b0[xXbBoOdD][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?f?|\\.\\d+f?)([eE][-+]?\\d+f?)?)'
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
export { angelscript as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/angelscript" instead of "highlight.js/lib/languages/angelscript.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './angelscript.js';
|
||||
export default lang;
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
Language: Apache config
|
||||
Author: Ruslan Keba <rukeba@gmail.com>
|
||||
Contributors: Ivan Sagalaev <maniac@softwaremaniacs.org>
|
||||
Website: https://httpd.apache.org
|
||||
Description: language definition for Apache configuration files (httpd.conf & .htaccess)
|
||||
Category: config, web
|
||||
Audit: 2020
|
||||
*/
|
||||
|
||||
/** @type LanguageFn */
|
||||
function apache(hljs) {
|
||||
const NUMBER_REF = {
|
||||
className: 'number',
|
||||
begin: /[$%]\d+/
|
||||
};
|
||||
const NUMBER = {
|
||||
className: 'number',
|
||||
begin: /\b\d+/
|
||||
};
|
||||
const IP_ADDRESS = {
|
||||
className: "number",
|
||||
begin: /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(:\d{1,5})?/
|
||||
};
|
||||
const PORT_NUMBER = {
|
||||
className: "number",
|
||||
begin: /:\d{1,5}/
|
||||
};
|
||||
return {
|
||||
name: 'Apache config',
|
||||
aliases: [ 'apacheconf' ],
|
||||
case_insensitive: true,
|
||||
contains: [
|
||||
hljs.HASH_COMMENT_MODE,
|
||||
{
|
||||
className: 'section',
|
||||
begin: /<\/?/,
|
||||
end: />/,
|
||||
contains: [
|
||||
IP_ADDRESS,
|
||||
PORT_NUMBER,
|
||||
// low relevance prevents us from claming XML/HTML where this rule would
|
||||
// match strings inside of XML tags
|
||||
hljs.inherit(hljs.QUOTE_STRING_MODE, { relevance: 0 })
|
||||
]
|
||||
},
|
||||
{
|
||||
className: 'attribute',
|
||||
begin: /\w+/,
|
||||
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"
|
||||
] },
|
||||
starts: {
|
||||
end: /$/,
|
||||
relevance: 0,
|
||||
keywords: { literal: 'on off all deny allow' },
|
||||
contains: [
|
||||
{
|
||||
scope: "punctuation",
|
||||
match: /\\\n/
|
||||
},
|
||||
{
|
||||
className: 'meta',
|
||||
begin: /\s\[/,
|
||||
end: /\]$/
|
||||
},
|
||||
{
|
||||
className: 'variable',
|
||||
begin: /[\$%]\{/,
|
||||
end: /\}/,
|
||||
contains: [
|
||||
'self',
|
||||
NUMBER_REF
|
||||
]
|
||||
},
|
||||
IP_ADDRESS,
|
||||
NUMBER,
|
||||
hljs.QUOTE_STRING_MODE
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
illegal: /\S/
|
||||
};
|
||||
}
|
||||
|
||||
export { apache as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/apache" instead of "highlight.js/lib/languages/apache.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './apache.js';
|
||||
export default lang;
|
||||
+149
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
Language: AppleScript
|
||||
Authors: Nathan Grigg <nathan@nathanamy.org>, Dr. Drang <drdrang@gmail.com>
|
||||
Category: scripting
|
||||
Website: https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/introduction/ASLR_intro.html
|
||||
Audit: 2020
|
||||
*/
|
||||
|
||||
/** @type LanguageFn */
|
||||
function applescript(hljs) {
|
||||
const regex = hljs.regex;
|
||||
const STRING = hljs.inherit(
|
||||
hljs.QUOTE_STRING_MODE, { illegal: null });
|
||||
const PARAMS = {
|
||||
className: 'params',
|
||||
begin: /\(/,
|
||||
end: /\)/,
|
||||
contains: [
|
||||
'self',
|
||||
hljs.C_NUMBER_MODE,
|
||||
STRING
|
||||
]
|
||||
};
|
||||
const COMMENT_MODE_1 = hljs.COMMENT(/--/, /$/);
|
||||
const COMMENT_MODE_2 = hljs.COMMENT(
|
||||
/\(\*/,
|
||||
/\*\)/,
|
||||
{ contains: [
|
||||
'self', // allow nesting
|
||||
COMMENT_MODE_1
|
||||
] }
|
||||
);
|
||||
const COMMENTS = [
|
||||
COMMENT_MODE_1,
|
||||
COMMENT_MODE_2,
|
||||
hljs.HASH_COMMENT_MODE
|
||||
];
|
||||
|
||||
const KEYWORD_PATTERNS = [
|
||||
/apart from/,
|
||||
/aside from/,
|
||||
/instead of/,
|
||||
/out of/,
|
||||
/greater than/,
|
||||
/isn't|(doesn't|does not) (equal|come before|come after|contain)/,
|
||||
/(greater|less) than( or equal)?/,
|
||||
/(starts?|ends|begins?) with/,
|
||||
/contained by/,
|
||||
/comes (before|after)/,
|
||||
/a (ref|reference)/,
|
||||
/POSIX (file|path)/,
|
||||
/(date|time) string/,
|
||||
/quoted form/
|
||||
];
|
||||
|
||||
const BUILT_IN_PATTERNS = [
|
||||
/clipboard info/,
|
||||
/the clipboard/,
|
||||
/info for/,
|
||||
/list (disks|folder)/,
|
||||
/mount volume/,
|
||||
/path to/,
|
||||
/(close|open for) access/,
|
||||
/(get|set) eof/,
|
||||
/current date/,
|
||||
/do shell script/,
|
||||
/get volume settings/,
|
||||
/random number/,
|
||||
/set volume/,
|
||||
/system attribute/,
|
||||
/system info/,
|
||||
/time to GMT/,
|
||||
/(load|run|store) script/,
|
||||
/scripting components/,
|
||||
/ASCII (character|number)/,
|
||||
/localized string/,
|
||||
/choose (application|color|file|file name|folder|from list|remote application|URL)/,
|
||||
/display (alert|dialog)/
|
||||
];
|
||||
|
||||
return {
|
||||
name: 'AppleScript',
|
||||
aliases: [ 'osascript' ],
|
||||
keywords: {
|
||||
keyword:
|
||||
'about above after against and around as at back before beginning '
|
||||
+ 'behind below beneath beside between but by considering '
|
||||
+ 'contain contains continue copy div does eighth else end equal '
|
||||
+ 'equals error every exit fifth first for fourth from front '
|
||||
+ 'get given global if ignoring in into is it its last local me '
|
||||
+ 'middle mod my ninth not of on onto or over prop property put ref '
|
||||
+ 'reference repeat returning script second set seventh since '
|
||||
+ 'sixth some tell tenth that the|0 then third through thru '
|
||||
+ 'timeout times to transaction try until where while whose with '
|
||||
+ 'without',
|
||||
literal:
|
||||
'AppleScript false linefeed return pi quote result space tab true',
|
||||
built_in:
|
||||
'alias application boolean class constant date file integer list '
|
||||
+ 'number real record string text '
|
||||
+ 'activate beep count delay launch log offset read round '
|
||||
+ 'run say summarize write '
|
||||
+ 'character characters contents day frontmost id item length '
|
||||
+ 'month name|0 paragraph paragraphs rest reverse running time version '
|
||||
+ 'weekday word words year'
|
||||
},
|
||||
contains: [
|
||||
STRING,
|
||||
hljs.C_NUMBER_MODE,
|
||||
{
|
||||
className: 'built_in',
|
||||
begin: regex.concat(
|
||||
/\b/,
|
||||
regex.either(...BUILT_IN_PATTERNS),
|
||||
/\b/
|
||||
)
|
||||
},
|
||||
{
|
||||
className: 'built_in',
|
||||
begin: /^\s*return\b/
|
||||
},
|
||||
{
|
||||
className: 'literal',
|
||||
begin:
|
||||
/\b(text item delimiters|current application|missing value)\b/
|
||||
},
|
||||
{
|
||||
className: 'keyword',
|
||||
begin: regex.concat(
|
||||
/\b/,
|
||||
regex.either(...KEYWORD_PATTERNS),
|
||||
/\b/
|
||||
)
|
||||
},
|
||||
{
|
||||
beginKeywords: 'on',
|
||||
illegal: /[${=;\n]/,
|
||||
contains: [
|
||||
hljs.UNDERSCORE_TITLE_MODE,
|
||||
PARAMS
|
||||
]
|
||||
},
|
||||
...COMMENTS
|
||||
],
|
||||
illegal: /\/\/|->|=>|\[\[/
|
||||
};
|
||||
}
|
||||
|
||||
export { applescript as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/applescript" instead of "highlight.js/lib/languages/applescript.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './applescript.js';
|
||||
export default lang;
|
||||
+428
@@ -0,0 +1,428 @@
|
||||
/*
|
||||
Language: ArcGIS Arcade
|
||||
Category: scripting
|
||||
Website: https://developers.arcgis.com/arcade/
|
||||
Description: ArcGIS Arcade is an expression language used in many Esri ArcGIS products such as Pro, Online, Server, Runtime, JavaScript, and Python
|
||||
*/
|
||||
|
||||
/** @type LanguageFn */
|
||||
function arcade(hljs) {
|
||||
const regex = hljs.regex;
|
||||
const IDENT_RE = '[A-Za-z_][0-9A-Za-z_]*';
|
||||
const KEYWORDS = {
|
||||
keyword: [
|
||||
"break",
|
||||
"case",
|
||||
"catch",
|
||||
"continue",
|
||||
"debugger",
|
||||
"do",
|
||||
"else",
|
||||
"export",
|
||||
"for",
|
||||
"function",
|
||||
"if",
|
||||
"import",
|
||||
"in",
|
||||
"new",
|
||||
"of",
|
||||
"return",
|
||||
"switch",
|
||||
"try",
|
||||
"var",
|
||||
"void",
|
||||
"while"
|
||||
],
|
||||
literal: [
|
||||
"BackSlash",
|
||||
"DoubleQuote",
|
||||
"ForwardSlash",
|
||||
"Infinity",
|
||||
"NaN",
|
||||
"NewLine",
|
||||
"PI",
|
||||
"SingleQuote",
|
||||
"Tab",
|
||||
"TextFormatting",
|
||||
"false",
|
||||
"null",
|
||||
"true",
|
||||
"undefined"
|
||||
],
|
||||
built_in: [
|
||||
"Abs",
|
||||
"Acos",
|
||||
"All",
|
||||
"Angle",
|
||||
"Any",
|
||||
"Area",
|
||||
"AreaGeodetic",
|
||||
"Array",
|
||||
"Asin",
|
||||
"Atan",
|
||||
"Atan2",
|
||||
"Attachments",
|
||||
"Average",
|
||||
"Back",
|
||||
"Bearing",
|
||||
"Boolean",
|
||||
"Buffer",
|
||||
"BufferGeodetic",
|
||||
"Ceil",
|
||||
"Centroid",
|
||||
"ChangeTimeZone",
|
||||
"Clip",
|
||||
"Concatenate",
|
||||
"Console",
|
||||
"Constrain",
|
||||
"Contains",
|
||||
"ConvertDirection",
|
||||
"ConvexHull",
|
||||
"Cos",
|
||||
"Count",
|
||||
"Crosses",
|
||||
"Cut",
|
||||
"Date|0",
|
||||
"DateAdd",
|
||||
"DateDiff",
|
||||
"DateOnly",
|
||||
"Day",
|
||||
"Decode",
|
||||
"DefaultValue",
|
||||
"Densify",
|
||||
"DensifyGeodetic",
|
||||
"Dictionary",
|
||||
"Difference",
|
||||
"Disjoint",
|
||||
"Distance",
|
||||
"DistanceGeodetic",
|
||||
"DistanceToCoordinate",
|
||||
"Distinct",
|
||||
"Domain",
|
||||
"DomainCode",
|
||||
"DomainName",
|
||||
"EnvelopeIntersects",
|
||||
"Equals",
|
||||
"Erase",
|
||||
"Exp",
|
||||
"Expects",
|
||||
"Extent",
|
||||
"Feature",
|
||||
"FeatureInFilter",
|
||||
"FeatureSet",
|
||||
"FeatureSetByAssociation",
|
||||
"FeatureSetById",
|
||||
"FeatureSetByName",
|
||||
"FeatureSetByPortalItem",
|
||||
"FeatureSetByRelationshipClass",
|
||||
"FeatureSetByRelationshipName",
|
||||
"Filter",
|
||||
"FilterBySubtypeCode",
|
||||
"Find",
|
||||
"First|0",
|
||||
"Floor",
|
||||
"FromCharCode",
|
||||
"FromCodePoint",
|
||||
"FromJSON",
|
||||
"Front",
|
||||
"GdbVersion",
|
||||
"Generalize",
|
||||
"Geometry",
|
||||
"GetEnvironment",
|
||||
"GetFeatureSet",
|
||||
"GetFeatureSetInfo",
|
||||
"GetUser",
|
||||
"GroupBy",
|
||||
"Guid",
|
||||
"HasKey",
|
||||
"HasValue",
|
||||
"Hash",
|
||||
"Hour",
|
||||
"IIf",
|
||||
"ISOMonth",
|
||||
"ISOWeek",
|
||||
"ISOWeekday",
|
||||
"ISOYear",
|
||||
"Includes",
|
||||
"IndexOf",
|
||||
"Insert",
|
||||
"Intersection",
|
||||
"Intersects",
|
||||
"IsEmpty",
|
||||
"IsNan",
|
||||
"IsSelfIntersecting",
|
||||
"IsSimple",
|
||||
"KnowledgeGraphByPortalItem",
|
||||
"Left|0",
|
||||
"Length",
|
||||
"Length3D",
|
||||
"LengthGeodetic",
|
||||
"Log",
|
||||
"Lower",
|
||||
"Map",
|
||||
"Max",
|
||||
"Mean",
|
||||
"MeasureToCoordinate",
|
||||
"Mid",
|
||||
"Millisecond",
|
||||
"Min",
|
||||
"Minute",
|
||||
"Month",
|
||||
"MultiPartToSinglePart",
|
||||
"Multipoint",
|
||||
"NearestCoordinate",
|
||||
"NearestVertex",
|
||||
"NextSequenceValue",
|
||||
"None",
|
||||
"Now",
|
||||
"Number",
|
||||
"Offset",
|
||||
"OrderBy",
|
||||
"Overlaps",
|
||||
"Point",
|
||||
"PointToCoordinate",
|
||||
"Polygon",
|
||||
"Polyline",
|
||||
"Pop",
|
||||
"Portal",
|
||||
"Pow",
|
||||
"Proper",
|
||||
"Push",
|
||||
"QueryGraph",
|
||||
"Random",
|
||||
"Reduce",
|
||||
"Relate",
|
||||
"Replace",
|
||||
"Resize",
|
||||
"Reverse",
|
||||
"Right|0",
|
||||
"RingIsClockwise",
|
||||
"Rotate",
|
||||
"Round",
|
||||
"Schema",
|
||||
"Second",
|
||||
"SetGeometry",
|
||||
"Simplify",
|
||||
"Sin",
|
||||
"Slice",
|
||||
"Sort",
|
||||
"Splice",
|
||||
"Split",
|
||||
"Sqrt",
|
||||
"StandardizeFilename",
|
||||
"StandardizeGuid",
|
||||
"Stdev",
|
||||
"SubtypeCode",
|
||||
"SubtypeName",
|
||||
"Subtypes",
|
||||
"Sum",
|
||||
"SymmetricDifference",
|
||||
"Tan",
|
||||
"Text",
|
||||
"Time",
|
||||
"TimeZone",
|
||||
"TimeZoneOffset",
|
||||
"Timestamp",
|
||||
"ToCharCode",
|
||||
"ToCodePoint",
|
||||
"ToHex",
|
||||
"ToLocal",
|
||||
"ToUTC",
|
||||
"Today",
|
||||
"Top|0",
|
||||
"Touches",
|
||||
"TrackAccelerationAt",
|
||||
"TrackAccelerationWindow",
|
||||
"TrackCurrentAcceleration",
|
||||
"TrackCurrentDistance",
|
||||
"TrackCurrentSpeed",
|
||||
"TrackCurrentTime",
|
||||
"TrackDistanceAt",
|
||||
"TrackDistanceWindow",
|
||||
"TrackDuration",
|
||||
"TrackFieldWindow",
|
||||
"TrackGeometryWindow",
|
||||
"TrackIndex",
|
||||
"TrackSpeedAt",
|
||||
"TrackSpeedWindow",
|
||||
"TrackStartTime",
|
||||
"TrackWindow",
|
||||
"Trim",
|
||||
"TypeOf",
|
||||
"Union",
|
||||
"Upper",
|
||||
"UrlEncode",
|
||||
"Variance",
|
||||
"Week",
|
||||
"Weekday",
|
||||
"When|0",
|
||||
"Within",
|
||||
"Year|0",
|
||||
]
|
||||
};
|
||||
const PROFILE_VARS = [
|
||||
"aggregatedFeatures",
|
||||
"analytic",
|
||||
"config",
|
||||
"datapoint",
|
||||
"datastore",
|
||||
"editcontext",
|
||||
"feature",
|
||||
"featureSet",
|
||||
"feedfeature",
|
||||
"fencefeature",
|
||||
"fencenotificationtype",
|
||||
"graph",
|
||||
"join",
|
||||
"layer",
|
||||
"locationupdate",
|
||||
"map",
|
||||
"measure",
|
||||
"measure",
|
||||
"originalFeature",
|
||||
"record",
|
||||
"reference",
|
||||
"rowindex",
|
||||
"sourcedatastore",
|
||||
"sourcefeature",
|
||||
"sourcelayer",
|
||||
"target",
|
||||
"targetdatastore",
|
||||
"targetfeature",
|
||||
"targetlayer",
|
||||
"userInput",
|
||||
"value",
|
||||
"variables",
|
||||
"view"
|
||||
];
|
||||
const SYMBOL = {
|
||||
className: 'symbol',
|
||||
begin: '\\$' + regex.either(...PROFILE_VARS)
|
||||
};
|
||||
const NUMBER = {
|
||||
className: 'number',
|
||||
variants: [
|
||||
{ begin: '\\b(0[bB][01]+)' },
|
||||
{ begin: '\\b(0[oO][0-7]+)' },
|
||||
{ begin: hljs.C_NUMBER_RE }
|
||||
],
|
||||
relevance: 0
|
||||
};
|
||||
const SUBST = {
|
||||
className: 'subst',
|
||||
begin: '\\$\\{',
|
||||
end: '\\}',
|
||||
keywords: KEYWORDS,
|
||||
contains: [] // defined later
|
||||
};
|
||||
const TEMPLATE_STRING = {
|
||||
className: 'string',
|
||||
begin: '`',
|
||||
end: '`',
|
||||
contains: [
|
||||
hljs.BACKSLASH_ESCAPE,
|
||||
SUBST
|
||||
]
|
||||
};
|
||||
SUBST.contains = [
|
||||
hljs.APOS_STRING_MODE,
|
||||
hljs.QUOTE_STRING_MODE,
|
||||
TEMPLATE_STRING,
|
||||
NUMBER,
|
||||
hljs.REGEXP_MODE
|
||||
];
|
||||
const PARAMS_CONTAINS = SUBST.contains.concat([
|
||||
hljs.C_BLOCK_COMMENT_MODE,
|
||||
hljs.C_LINE_COMMENT_MODE
|
||||
]);
|
||||
|
||||
return {
|
||||
name: 'ArcGIS Arcade',
|
||||
case_insensitive: true,
|
||||
keywords: KEYWORDS,
|
||||
contains: [
|
||||
hljs.APOS_STRING_MODE,
|
||||
hljs.QUOTE_STRING_MODE,
|
||||
TEMPLATE_STRING,
|
||||
hljs.C_LINE_COMMENT_MODE,
|
||||
hljs.C_BLOCK_COMMENT_MODE,
|
||||
SYMBOL,
|
||||
NUMBER,
|
||||
{ // object attr container
|
||||
begin: /[{,]\s*/,
|
||||
relevance: 0,
|
||||
contains: [
|
||||
{
|
||||
begin: IDENT_RE + '\\s*:',
|
||||
returnBegin: true,
|
||||
relevance: 0,
|
||||
contains: [
|
||||
{
|
||||
className: 'attr',
|
||||
begin: IDENT_RE,
|
||||
relevance: 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{ // "value" container
|
||||
begin: '(' + hljs.RE_STARTERS_RE + '|\\b(return)\\b)\\s*',
|
||||
keywords: 'return',
|
||||
contains: [
|
||||
hljs.C_LINE_COMMENT_MODE,
|
||||
hljs.C_BLOCK_COMMENT_MODE,
|
||||
hljs.REGEXP_MODE,
|
||||
{
|
||||
className: 'function',
|
||||
begin: '(\\(.*?\\)|' + IDENT_RE + ')\\s*=>',
|
||||
returnBegin: true,
|
||||
end: '\\s*=>',
|
||||
contains: [
|
||||
{
|
||||
className: 'params',
|
||||
variants: [
|
||||
{ begin: IDENT_RE },
|
||||
{ begin: /\(\s*\)/ },
|
||||
{
|
||||
begin: /\(/,
|
||||
end: /\)/,
|
||||
excludeBegin: true,
|
||||
excludeEnd: true,
|
||||
keywords: KEYWORDS,
|
||||
contains: PARAMS_CONTAINS
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
relevance: 0
|
||||
},
|
||||
{
|
||||
beginKeywords: 'function',
|
||||
end: /\{/,
|
||||
excludeEnd: true,
|
||||
contains: [
|
||||
hljs.inherit(hljs.TITLE_MODE, {
|
||||
className: "title.function",
|
||||
begin: IDENT_RE
|
||||
}),
|
||||
{
|
||||
className: 'params',
|
||||
begin: /\(/,
|
||||
end: /\)/,
|
||||
excludeBegin: true,
|
||||
excludeEnd: true,
|
||||
contains: PARAMS_CONTAINS
|
||||
}
|
||||
],
|
||||
illegal: /\[|%/
|
||||
},
|
||||
{ begin: /\$[(.]/ }
|
||||
],
|
||||
illegal: /#(?!!)/
|
||||
};
|
||||
}
|
||||
|
||||
export { arcade as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/arcade" instead of "highlight.js/lib/languages/arcade.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './arcade.js';
|
||||
export default lang;
|
||||
+1008
File diff suppressed because it is too large
Load Diff
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/arduino" instead of "highlight.js/lib/languages/arduino.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './arduino.js';
|
||||
export default lang;
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
Language: ARM Assembly
|
||||
Author: Dan Panzarella <alsoelp@gmail.com>
|
||||
Description: ARM Assembly including Thumb and Thumb2 instructions
|
||||
Category: assembler
|
||||
*/
|
||||
|
||||
/** @type LanguageFn */
|
||||
function armasm(hljs) {
|
||||
// local labels: %?[FB]?[AT]?\d{1,2}\w+
|
||||
|
||||
const COMMENT = { variants: [
|
||||
hljs.COMMENT('^[ \\t]*(?=#)', '$', {
|
||||
relevance: 0,
|
||||
excludeBegin: true
|
||||
}),
|
||||
hljs.COMMENT('[;@]', '$', { relevance: 0 }),
|
||||
hljs.C_LINE_COMMENT_MODE,
|
||||
hljs.C_BLOCK_COMMENT_MODE
|
||||
] };
|
||||
|
||||
return {
|
||||
name: 'ARM Assembly',
|
||||
case_insensitive: true,
|
||||
aliases: [ 'arm' ],
|
||||
keywords: {
|
||||
$pattern: '\\.?' + hljs.IDENT_RE,
|
||||
meta:
|
||||
// GNU preprocs
|
||||
'.2byte .4byte .align .ascii .asciz .balign .byte .code .data .else .end .endif .endm .endr .equ .err .exitm .extern .global .hword .if .ifdef .ifndef .include .irp .long .macro .rept .req .section .set .skip .space .text .word .arm .thumb .code16 .code32 .force_thumb .thumb_func .ltorg '
|
||||
// ARM directives
|
||||
+ 'ALIAS ALIGN ARM AREA ASSERT ATTR CN CODE CODE16 CODE32 COMMON CP DATA DCB DCD DCDU DCDO DCFD DCFDU DCI DCQ DCQU DCW DCWU DN ELIF ELSE END ENDFUNC ENDIF ENDP ENTRY EQU EXPORT EXPORTAS EXTERN FIELD FILL FUNCTION GBLA GBLL GBLS GET GLOBAL IF IMPORT INCBIN INCLUDE INFO KEEP LCLA LCLL LCLS LTORG MACRO MAP MEND MEXIT NOFP OPT PRESERVE8 PROC QN READONLY RELOC REQUIRE REQUIRE8 RLIST FN ROUT SETA SETL SETS SN SPACE SUBT THUMB THUMBX TTL WHILE WEND ',
|
||||
built_in:
|
||||
'r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 r15 ' // standard registers
|
||||
+ 'w0 w1 w2 w3 w4 w5 w6 w7 w8 w9 w10 w11 w12 w13 w14 w15 ' // 32 bit ARMv8 registers
|
||||
+ 'w16 w17 w18 w19 w20 w21 w22 w23 w24 w25 w26 w27 w28 w29 w30 '
|
||||
+ 'x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 ' // 64 bit ARMv8 registers
|
||||
+ 'x16 x17 x18 x19 x20 x21 x22 x23 x24 x25 x26 x27 x28 x29 x30 '
|
||||
+ 'pc lr sp ip sl sb fp ' // typical regs plus backward compatibility
|
||||
+ 'a1 a2 a3 a4 v1 v2 v3 v4 v5 v6 v7 v8 f0 f1 f2 f3 f4 f5 f6 f7 ' // more regs and fp
|
||||
+ 'p0 p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 ' // coprocessor regs
|
||||
+ 'c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 ' // more coproc
|
||||
+ 'q0 q1 q2 q3 q4 q5 q6 q7 q8 q9 q10 q11 q12 q13 q14 q15 ' // advanced SIMD NEON regs
|
||||
|
||||
// program status registers
|
||||
+ 'cpsr_c cpsr_x cpsr_s cpsr_f cpsr_cx cpsr_cxs cpsr_xs cpsr_xsf cpsr_sf cpsr_cxsf '
|
||||
+ 'spsr_c spsr_x spsr_s spsr_f spsr_cx spsr_cxs spsr_xs spsr_xsf spsr_sf spsr_cxsf '
|
||||
|
||||
// NEON and VFP registers
|
||||
+ 's0 s1 s2 s3 s4 s5 s6 s7 s8 s9 s10 s11 s12 s13 s14 s15 '
|
||||
+ 's16 s17 s18 s19 s20 s21 s22 s23 s24 s25 s26 s27 s28 s29 s30 s31 '
|
||||
+ 'd0 d1 d2 d3 d4 d5 d6 d7 d8 d9 d10 d11 d12 d13 d14 d15 '
|
||||
+ 'd16 d17 d18 d19 d20 d21 d22 d23 d24 d25 d26 d27 d28 d29 d30 d31 '
|
||||
|
||||
+ '{PC} {VAR} {TRUE} {FALSE} {OPT} {CONFIG} {ENDIAN} {CODESIZE} {CPU} {FPU} {ARCHITECTURE} {PCSTOREOFFSET} {ARMASM_VERSION} {INTER} {ROPI} {RWPI} {SWST} {NOSWST} . @'
|
||||
},
|
||||
contains: [
|
||||
{
|
||||
className: 'keyword',
|
||||
begin: '\\b(' // mnemonics
|
||||
+ 'adc|'
|
||||
+ '(qd?|sh?|u[qh]?)?add(8|16)?|usada?8|(q|sh?|u[qh]?)?(as|sa)x|'
|
||||
+ 'and|adrl?|sbc|rs[bc]|asr|b[lx]?|blx|bxj|cbn?z|tb[bh]|bic|'
|
||||
+ 'bfc|bfi|[su]bfx|bkpt|cdp2?|clz|clrex|cmp|cmn|cpsi[ed]|cps|'
|
||||
+ 'setend|dbg|dmb|dsb|eor|isb|it[te]{0,3}|lsl|lsr|ror|rrx|'
|
||||
+ 'ldm(([id][ab])|f[ds])?|ldr((s|ex)?[bhd])?|movt?|mvn|mra|mar|'
|
||||
+ 'mul|[us]mull|smul[bwt][bt]|smu[as]d|smmul|smmla|'
|
||||
+ 'mla|umlaal|smlal?([wbt][bt]|d)|mls|smlsl?[ds]|smc|svc|sev|'
|
||||
+ 'mia([bt]{2}|ph)?|mrr?c2?|mcrr2?|mrs|msr|orr|orn|pkh(tb|bt)|rbit|'
|
||||
+ 'rev(16|sh)?|sel|[su]sat(16)?|nop|pop|push|rfe([id][ab])?|'
|
||||
+ 'stm([id][ab])?|str(ex)?[bhd]?|(qd?)?sub|(sh?|q|u[qh]?)?sub(8|16)|'
|
||||
+ '[su]xt(a?h|a?b(16)?)|srs([id][ab])?|swpb?|swi|smi|tst|teq|'
|
||||
+ 'wfe|wfi|yield'
|
||||
+ ')'
|
||||
+ '(eq|ne|cs|cc|mi|pl|vs|vc|hi|ls|ge|lt|gt|le|al|hs|lo)?' // condition codes
|
||||
+ '[sptrx]?' // legal postfixes
|
||||
+ '(?=\\s)' // followed by space
|
||||
},
|
||||
COMMENT,
|
||||
hljs.QUOTE_STRING_MODE,
|
||||
{
|
||||
className: 'string',
|
||||
begin: '\'',
|
||||
end: '[^\\\\]\'',
|
||||
relevance: 0
|
||||
},
|
||||
{
|
||||
className: 'title',
|
||||
begin: '\\|',
|
||||
end: '\\|',
|
||||
illegal: '\\n',
|
||||
relevance: 0
|
||||
},
|
||||
{
|
||||
className: 'number',
|
||||
variants: [
|
||||
{ // hex
|
||||
begin: '[#$=]?0x[0-9a-f]+' },
|
||||
{ // bin
|
||||
begin: '[#$=]?0b[01]+' },
|
||||
{ // literal
|
||||
begin: '[#$=]\\d+' },
|
||||
{ // bare number
|
||||
begin: '\\b\\d+' }
|
||||
],
|
||||
relevance: 0
|
||||
},
|
||||
{
|
||||
className: 'symbol',
|
||||
variants: [
|
||||
{ // GNU ARM syntax
|
||||
begin: '^[ \\t]*[a-z_\\.\\$][a-z0-9_\\.\\$]+:' },
|
||||
{ // ARM syntax
|
||||
begin: '^[a-z_\\.\\$][a-z0-9_\\.\\$]+' },
|
||||
{ // label reference
|
||||
begin: '[=#]\\w+' }
|
||||
],
|
||||
relevance: 0
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
export { armasm as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/armasm" instead of "highlight.js/lib/languages/armasm.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './armasm.js';
|
||||
export default lang;
|
||||
+261
@@ -0,0 +1,261 @@
|
||||
/*
|
||||
Language: AsciiDoc
|
||||
Requires: xml.js
|
||||
Author: Dan Allen <dan.j.allen@gmail.com>
|
||||
Website: http://asciidoc.org
|
||||
Description: A semantic, text-based document format that can be exported to HTML, DocBook and other backends.
|
||||
Category: markup
|
||||
*/
|
||||
|
||||
/** @type LanguageFn */
|
||||
function asciidoc(hljs) {
|
||||
const regex = hljs.regex;
|
||||
const HORIZONTAL_RULE = {
|
||||
begin: '^\'{3,}[ \\t]*$',
|
||||
relevance: 10
|
||||
};
|
||||
const ESCAPED_FORMATTING = [
|
||||
// escaped constrained formatting marks (i.e., \* \_ or \`)
|
||||
{ begin: /\\[*_`]/ },
|
||||
// escaped unconstrained formatting marks (i.e., \\** \\__ or \\``)
|
||||
// must ignore until the next formatting marks
|
||||
// this rule might not be 100% compliant with Asciidoctor 2.0 but we are entering undefined behavior territory...
|
||||
{ begin: /\\\\\*{2}[^\n]*?\*{2}/ },
|
||||
{ begin: /\\\\_{2}[^\n]*_{2}/ },
|
||||
{ begin: /\\\\`{2}[^\n]*`{2}/ },
|
||||
// guard: constrained formatting mark may not be preceded by ":", ";" or
|
||||
// "}". match these so the constrained rule doesn't see them
|
||||
{ begin: /[:;}][*_`](?![*_`])/ }
|
||||
];
|
||||
const STRONG = [
|
||||
// inline unconstrained strong (single line)
|
||||
{
|
||||
className: 'strong',
|
||||
begin: /\*{2}([^\n]+?)\*{2}/
|
||||
},
|
||||
// inline unconstrained strong (multi-line)
|
||||
{
|
||||
className: 'strong',
|
||||
begin: regex.concat(
|
||||
/\*\*/,
|
||||
/((\*(?!\*)|\\[^\n]|[^*\n\\])+\n)+/,
|
||||
/(\*(?!\*)|\\[^\n]|[^*\n\\])*/,
|
||||
/\*\*/
|
||||
),
|
||||
relevance: 0
|
||||
},
|
||||
// inline constrained strong (single line)
|
||||
{
|
||||
className: 'strong',
|
||||
// must not precede or follow a word character
|
||||
begin: /\B\*(\S|\S[^\n]*?\S)\*(?!\w)/
|
||||
},
|
||||
// inline constrained strong (multi-line)
|
||||
{
|
||||
className: 'strong',
|
||||
// must not precede or follow a word character
|
||||
begin: /\*[^\s]([^\n]+\n)+([^\n]+)\*/
|
||||
}
|
||||
];
|
||||
const EMPHASIS = [
|
||||
// inline unconstrained emphasis (single line)
|
||||
{
|
||||
className: 'emphasis',
|
||||
begin: /_{2}([^\n]+?)_{2}/
|
||||
},
|
||||
// inline unconstrained emphasis (multi-line)
|
||||
{
|
||||
className: 'emphasis',
|
||||
begin: regex.concat(
|
||||
/__/,
|
||||
/((_(?!_)|\\[^\n]|[^_\n\\])+\n)+/,
|
||||
/(_(?!_)|\\[^\n]|[^_\n\\])*/,
|
||||
/__/
|
||||
),
|
||||
relevance: 0
|
||||
},
|
||||
// inline constrained emphasis (single line)
|
||||
{
|
||||
className: 'emphasis',
|
||||
// must not precede or follow a word character
|
||||
begin: /\b_(\S|\S[^\n]*?\S)_(?!\w)/
|
||||
},
|
||||
// inline constrained emphasis (multi-line)
|
||||
{
|
||||
className: 'emphasis',
|
||||
// must not precede or follow a word character
|
||||
begin: /_[^\s]([^\n]+\n)+([^\n]+)_/
|
||||
},
|
||||
// inline constrained emphasis using single quote (legacy)
|
||||
{
|
||||
className: 'emphasis',
|
||||
// must not follow a word character or be followed by a single quote or space
|
||||
begin: '\\B\'(?![\'\\s])',
|
||||
end: '(\\n{2}|\')',
|
||||
// allow escaped single quote followed by word char
|
||||
contains: [
|
||||
{
|
||||
begin: '\\\\\'\\w',
|
||||
relevance: 0
|
||||
}
|
||||
],
|
||||
relevance: 0
|
||||
}
|
||||
];
|
||||
const ADMONITION = {
|
||||
className: 'symbol',
|
||||
begin: '^(NOTE|TIP|IMPORTANT|WARNING|CAUTION):\\s+',
|
||||
relevance: 10
|
||||
};
|
||||
const BULLET_LIST = {
|
||||
className: 'bullet',
|
||||
begin: '^(\\*+|-+|\\.+|[^\\n]+?::)\\s+'
|
||||
};
|
||||
|
||||
return {
|
||||
name: 'AsciiDoc',
|
||||
aliases: [ 'adoc' ],
|
||||
contains: [
|
||||
// block comment
|
||||
hljs.COMMENT(
|
||||
'^/{4,}\\n',
|
||||
'\\n/{4,}$',
|
||||
// can also be done as...
|
||||
// '^/{4,}$',
|
||||
// '^/{4,}$',
|
||||
{ relevance: 10 }
|
||||
),
|
||||
// line comment
|
||||
hljs.COMMENT(
|
||||
'^//',
|
||||
'$',
|
||||
{ relevance: 0 }
|
||||
),
|
||||
// title
|
||||
{
|
||||
className: 'title',
|
||||
begin: '^\\.\\w.*$'
|
||||
},
|
||||
// example, admonition & sidebar blocks
|
||||
{
|
||||
begin: '^[=\\*]{4,}\\n',
|
||||
end: '\\n^[=\\*]{4,}$',
|
||||
relevance: 10
|
||||
},
|
||||
// headings
|
||||
{
|
||||
className: 'section',
|
||||
relevance: 10,
|
||||
variants: [
|
||||
{ begin: '^(={1,6})[ \t].+?([ \t]\\1)?$' },
|
||||
{ begin: '^[^\\[\\]\\n]+?\\n[=\\-~\\^\\+]{2,}$' }
|
||||
]
|
||||
},
|
||||
// document attributes
|
||||
{
|
||||
className: 'meta',
|
||||
begin: '^:.+?:',
|
||||
end: '\\s',
|
||||
excludeEnd: true,
|
||||
relevance: 10
|
||||
},
|
||||
// block attributes
|
||||
{
|
||||
className: 'meta',
|
||||
begin: '^\\[.+?\\]$',
|
||||
relevance: 0
|
||||
},
|
||||
// quoteblocks
|
||||
{
|
||||
className: 'quote',
|
||||
begin: '^_{4,}\\n',
|
||||
end: '\\n_{4,}$',
|
||||
relevance: 10
|
||||
},
|
||||
// listing and literal blocks
|
||||
{
|
||||
className: 'code',
|
||||
begin: '^[\\-\\.]{4,}\\n',
|
||||
end: '\\n[\\-\\.]{4,}$',
|
||||
relevance: 10
|
||||
},
|
||||
// passthrough blocks
|
||||
{
|
||||
begin: '^\\+{4,}\\n',
|
||||
end: '\\n\\+{4,}$',
|
||||
contains: [
|
||||
{
|
||||
begin: '<',
|
||||
end: '>',
|
||||
subLanguage: 'xml',
|
||||
relevance: 0
|
||||
}
|
||||
],
|
||||
relevance: 10
|
||||
},
|
||||
|
||||
BULLET_LIST,
|
||||
ADMONITION,
|
||||
...ESCAPED_FORMATTING,
|
||||
...STRONG,
|
||||
...EMPHASIS,
|
||||
|
||||
// inline smart quotes
|
||||
{
|
||||
className: 'string',
|
||||
variants: [
|
||||
{ begin: "``.+?''" },
|
||||
{ begin: "`.+?'" }
|
||||
]
|
||||
},
|
||||
// inline unconstrained emphasis
|
||||
{
|
||||
className: 'code',
|
||||
begin: /`{2}/,
|
||||
end: /(\n{2}|`{2})/
|
||||
},
|
||||
// inline code snippets (TODO should get same treatment as strong and emphasis)
|
||||
{
|
||||
className: 'code',
|
||||
begin: '(`.+?`|\\+.+?\\+)',
|
||||
relevance: 0
|
||||
},
|
||||
// indented literal block
|
||||
{
|
||||
className: 'code',
|
||||
begin: '^[ \\t]',
|
||||
end: '$',
|
||||
relevance: 0
|
||||
},
|
||||
HORIZONTAL_RULE,
|
||||
// images and links
|
||||
{
|
||||
begin: '(link:)?(http|https|ftp|file|irc|image:?):\\S+?\\[[^[]*?\\]',
|
||||
returnBegin: true,
|
||||
contains: [
|
||||
{
|
||||
begin: '(link|image:?):',
|
||||
relevance: 0
|
||||
},
|
||||
{
|
||||
className: 'link',
|
||||
begin: '\\w',
|
||||
end: '[^\\[]+',
|
||||
relevance: 0
|
||||
},
|
||||
{
|
||||
className: 'string',
|
||||
begin: '\\[',
|
||||
end: '\\]',
|
||||
excludeBegin: true,
|
||||
excludeEnd: true,
|
||||
relevance: 0
|
||||
}
|
||||
],
|
||||
relevance: 10
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
export { asciidoc as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/asciidoc" instead of "highlight.js/lib/languages/asciidoc.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './asciidoc.js';
|
||||
export default lang;
|
||||
+231
@@ -0,0 +1,231 @@
|
||||
/*
|
||||
Language: AspectJ
|
||||
Author: Hakan Ozler <ozler.hakan@gmail.com>
|
||||
Website: https://www.eclipse.org/aspectj/
|
||||
Description: Syntax Highlighting for the AspectJ Language which is a general-purpose aspect-oriented extension to the Java programming language.
|
||||
Category: system
|
||||
Audit: 2020
|
||||
*/
|
||||
|
||||
/** @type LanguageFn */
|
||||
function aspectj(hljs) {
|
||||
const regex = hljs.regex;
|
||||
const KEYWORDS = [
|
||||
"false",
|
||||
"synchronized",
|
||||
"int",
|
||||
"abstract",
|
||||
"float",
|
||||
"private",
|
||||
"char",
|
||||
"boolean",
|
||||
"static",
|
||||
"null",
|
||||
"if",
|
||||
"const",
|
||||
"for",
|
||||
"true",
|
||||
"while",
|
||||
"long",
|
||||
"throw",
|
||||
"strictfp",
|
||||
"finally",
|
||||
"protected",
|
||||
"import",
|
||||
"native",
|
||||
"final",
|
||||
"return",
|
||||
"void",
|
||||
"enum",
|
||||
"else",
|
||||
"extends",
|
||||
"implements",
|
||||
"break",
|
||||
"transient",
|
||||
"new",
|
||||
"catch",
|
||||
"instanceof",
|
||||
"byte",
|
||||
"super",
|
||||
"volatile",
|
||||
"case",
|
||||
"assert",
|
||||
"short",
|
||||
"package",
|
||||
"default",
|
||||
"double",
|
||||
"public",
|
||||
"try",
|
||||
"this",
|
||||
"switch",
|
||||
"continue",
|
||||
"throws",
|
||||
"privileged",
|
||||
"aspectOf",
|
||||
"adviceexecution",
|
||||
"proceed",
|
||||
"cflowbelow",
|
||||
"cflow",
|
||||
"initialization",
|
||||
"preinitialization",
|
||||
"staticinitialization",
|
||||
"withincode",
|
||||
"target",
|
||||
"within",
|
||||
"execution",
|
||||
"getWithinTypeName",
|
||||
"handler",
|
||||
"thisJoinPoint",
|
||||
"thisJoinPointStaticPart",
|
||||
"thisEnclosingJoinPointStaticPart",
|
||||
"declare",
|
||||
"parents",
|
||||
"warning",
|
||||
"error",
|
||||
"soft",
|
||||
"precedence",
|
||||
"thisAspectInstance"
|
||||
];
|
||||
const SHORTKEYS = [
|
||||
"get",
|
||||
"set",
|
||||
"args",
|
||||
"call"
|
||||
];
|
||||
|
||||
return {
|
||||
name: 'AspectJ',
|
||||
keywords: KEYWORDS,
|
||||
illegal: /<\/|#/,
|
||||
contains: [
|
||||
hljs.COMMENT(
|
||||
/\/\*\*/,
|
||||
/\*\//,
|
||||
{
|
||||
relevance: 0,
|
||||
contains: [
|
||||
{
|
||||
// eat up @'s in emails to prevent them to be recognized as doctags
|
||||
begin: /\w+@/,
|
||||
relevance: 0
|
||||
},
|
||||
{
|
||||
className: 'doctag',
|
||||
begin: /@[A-Za-z]+/
|
||||
}
|
||||
]
|
||||
}
|
||||
),
|
||||
hljs.C_LINE_COMMENT_MODE,
|
||||
hljs.C_BLOCK_COMMENT_MODE,
|
||||
hljs.APOS_STRING_MODE,
|
||||
hljs.QUOTE_STRING_MODE,
|
||||
{
|
||||
className: 'class',
|
||||
beginKeywords: 'aspect',
|
||||
end: /[{;=]/,
|
||||
excludeEnd: true,
|
||||
illegal: /[:;"\[\]]/,
|
||||
contains: [
|
||||
{ beginKeywords: 'extends implements pertypewithin perthis pertarget percflowbelow percflow issingleton' },
|
||||
hljs.UNDERSCORE_TITLE_MODE,
|
||||
{
|
||||
begin: /\([^\)]*/,
|
||||
end: /[)]+/,
|
||||
keywords: KEYWORDS.concat(SHORTKEYS),
|
||||
excludeEnd: false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
className: 'class',
|
||||
beginKeywords: 'class interface',
|
||||
end: /[{;=]/,
|
||||
excludeEnd: true,
|
||||
relevance: 0,
|
||||
keywords: 'class interface',
|
||||
illegal: /[:"\[\]]/,
|
||||
contains: [
|
||||
{ beginKeywords: 'extends implements' },
|
||||
hljs.UNDERSCORE_TITLE_MODE
|
||||
]
|
||||
},
|
||||
{
|
||||
// AspectJ Constructs
|
||||
beginKeywords: 'pointcut after before around throwing returning',
|
||||
end: /[)]/,
|
||||
excludeEnd: false,
|
||||
illegal: /["\[\]]/,
|
||||
contains: [
|
||||
{
|
||||
begin: regex.concat(hljs.UNDERSCORE_IDENT_RE, /\s*\(/),
|
||||
returnBegin: true,
|
||||
contains: [ hljs.UNDERSCORE_TITLE_MODE ]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
begin: /[:]/,
|
||||
returnBegin: true,
|
||||
end: /[{;]/,
|
||||
relevance: 0,
|
||||
excludeEnd: false,
|
||||
keywords: KEYWORDS,
|
||||
illegal: /["\[\]]/,
|
||||
contains: [
|
||||
{
|
||||
begin: regex.concat(hljs.UNDERSCORE_IDENT_RE, /\s*\(/),
|
||||
keywords: KEYWORDS.concat(SHORTKEYS),
|
||||
relevance: 0
|
||||
},
|
||||
hljs.QUOTE_STRING_MODE
|
||||
]
|
||||
},
|
||||
{
|
||||
// this prevents 'new Name(...), or throw ...' from being recognized as a function definition
|
||||
beginKeywords: 'new throw',
|
||||
relevance: 0
|
||||
},
|
||||
{
|
||||
// the function class is a bit different for AspectJ compared to the Java language
|
||||
className: 'function',
|
||||
begin: /\w+ +\w+(\.\w+)?\s*\([^\)]*\)\s*((throws)[\w\s,]+)?[\{;]/,
|
||||
returnBegin: true,
|
||||
end: /[{;=]/,
|
||||
keywords: KEYWORDS,
|
||||
excludeEnd: true,
|
||||
contains: [
|
||||
{
|
||||
begin: regex.concat(hljs.UNDERSCORE_IDENT_RE, /\s*\(/),
|
||||
returnBegin: true,
|
||||
relevance: 0,
|
||||
contains: [ hljs.UNDERSCORE_TITLE_MODE ]
|
||||
},
|
||||
{
|
||||
className: 'params',
|
||||
begin: /\(/,
|
||||
end: /\)/,
|
||||
relevance: 0,
|
||||
keywords: KEYWORDS,
|
||||
contains: [
|
||||
hljs.APOS_STRING_MODE,
|
||||
hljs.QUOTE_STRING_MODE,
|
||||
hljs.C_NUMBER_MODE,
|
||||
hljs.C_BLOCK_COMMENT_MODE
|
||||
]
|
||||
},
|
||||
hljs.C_LINE_COMMENT_MODE,
|
||||
hljs.C_BLOCK_COMMENT_MODE
|
||||
]
|
||||
},
|
||||
hljs.C_NUMBER_MODE,
|
||||
{
|
||||
// annotation is also used in this language
|
||||
className: 'meta',
|
||||
begin: /@[A-Za-z]+/
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
export { aspectj as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/aspectj" instead of "highlight.js/lib/languages/aspectj.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './aspectj.js';
|
||||
export default lang;
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
Language: AutoHotkey
|
||||
Author: Seongwon Lee <dlimpid@gmail.com>
|
||||
Description: AutoHotkey language definition
|
||||
Category: scripting
|
||||
*/
|
||||
|
||||
/** @type LanguageFn */
|
||||
function autohotkey(hljs) {
|
||||
const BACKTICK_ESCAPE = { begin: '`[\\s\\S]' };
|
||||
|
||||
return {
|
||||
name: 'AutoHotkey',
|
||||
case_insensitive: true,
|
||||
aliases: [ 'ahk' ],
|
||||
keywords: {
|
||||
keyword: 'Break Continue Critical Exit ExitApp Gosub Goto New OnExit Pause return SetBatchLines SetTimer Suspend Thread Throw Until ahk_id ahk_class ahk_pid ahk_exe ahk_group',
|
||||
literal: 'true false NOT AND OR',
|
||||
built_in: 'ComSpec Clipboard ClipboardAll ErrorLevel'
|
||||
},
|
||||
contains: [
|
||||
BACKTICK_ESCAPE,
|
||||
hljs.inherit(hljs.QUOTE_STRING_MODE, { contains: [ BACKTICK_ESCAPE ] }),
|
||||
hljs.COMMENT(';', '$', { relevance: 0 }),
|
||||
hljs.C_BLOCK_COMMENT_MODE,
|
||||
{
|
||||
className: 'number',
|
||||
begin: hljs.NUMBER_RE,
|
||||
relevance: 0
|
||||
},
|
||||
{
|
||||
// subst would be the most accurate however fails the point of
|
||||
// highlighting. variable is comparably the most accurate that actually
|
||||
// has some effect
|
||||
className: 'variable',
|
||||
begin: '%[a-zA-Z0-9#_$@]+%'
|
||||
},
|
||||
{
|
||||
className: 'built_in',
|
||||
begin: '^\\s*\\w+\\s*(,|%)'
|
||||
// I don't really know if this is totally relevant
|
||||
},
|
||||
{
|
||||
// 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
|
||||
className: 'title',
|
||||
variants: [
|
||||
{ begin: '^[^\\n";]+::(?!=)' },
|
||||
{
|
||||
begin: '^[^\\n";]+:(?!=)',
|
||||
// zero relevance as it catches a lot of things
|
||||
// followed by a single ':' in many languages
|
||||
relevance: 0
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
className: 'meta',
|
||||
begin: '^\\s*#\\w+',
|
||||
end: '$',
|
||||
relevance: 0
|
||||
},
|
||||
{
|
||||
className: 'built_in',
|
||||
begin: 'A_[a-zA-Z0-9]+'
|
||||
},
|
||||
{
|
||||
// consecutive commas, not for highlighting but just for relevance
|
||||
begin: ',\\s*,' }
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
export { autohotkey as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/autohotkey" instead of "highlight.js/lib/languages/autohotkey.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './autohotkey.js';
|
||||
export default lang;
|
||||
+178
File diff suppressed because one or more lines are too long
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/autoit" instead of "highlight.js/lib/languages/autoit.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './autoit.js';
|
||||
export default lang;
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
Language: AVR Assembly
|
||||
Author: Vladimir Ermakov <vooon341@gmail.com>
|
||||
Category: assembler
|
||||
Website: https://www.microchip.com/webdoc/avrassembler/avrassembler.wb_instruction_list.html
|
||||
*/
|
||||
|
||||
/** @type LanguageFn */
|
||||
function avrasm(hljs) {
|
||||
return {
|
||||
name: 'AVR Assembly',
|
||||
case_insensitive: true,
|
||||
keywords: {
|
||||
$pattern: '\\.?' + hljs.IDENT_RE,
|
||||
keyword:
|
||||
/* mnemonic */
|
||||
'adc add adiw and andi asr bclr bld brbc brbs brcc brcs break breq brge brhc brhs '
|
||||
+ 'brid brie brlo brlt brmi brne brpl brsh brtc brts brvc brvs bset bst call cbi cbr '
|
||||
+ 'clc clh cli cln clr cls clt clv clz com cp cpc cpi cpse dec eicall eijmp elpm eor '
|
||||
+ 'fmul fmuls fmulsu icall ijmp in inc jmp ld ldd ldi lds lpm lsl lsr mov movw mul '
|
||||
+ 'muls mulsu neg nop or ori out pop push rcall ret reti rjmp rol ror sbc sbr sbrc sbrs '
|
||||
+ 'sec seh sbi sbci sbic sbis sbiw sei sen ser ses set sev sez sleep spm st std sts sub '
|
||||
+ 'subi swap tst wdr',
|
||||
built_in:
|
||||
/* general purpose registers */
|
||||
'r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 r15 r16 r17 r18 r19 r20 r21 r22 '
|
||||
+ 'r23 r24 r25 r26 r27 r28 r29 r30 r31 x|0 xh xl y|0 yh yl z|0 zh zl '
|
||||
/* IO Registers (ATMega128) */
|
||||
+ 'ucsr1c udr1 ucsr1a ucsr1b ubrr1l ubrr1h ucsr0c ubrr0h tccr3c tccr3a tccr3b tcnt3h '
|
||||
+ 'tcnt3l ocr3ah ocr3al ocr3bh ocr3bl ocr3ch ocr3cl icr3h icr3l etimsk etifr tccr1c '
|
||||
+ 'ocr1ch ocr1cl twcr twdr twar twsr twbr osccal xmcra xmcrb eicra spmcsr spmcr portg '
|
||||
+ 'ddrg ping portf ddrf sreg sph spl xdiv rampz eicrb eimsk gimsk gicr eifr gifr timsk '
|
||||
+ 'tifr mcucr mcucsr tccr0 tcnt0 ocr0 assr tccr1a tccr1b tcnt1h tcnt1l ocr1ah ocr1al '
|
||||
+ 'ocr1bh ocr1bl icr1h icr1l tccr2 tcnt2 ocr2 ocdr wdtcr sfior eearh eearl eedr eecr '
|
||||
+ 'porta ddra pina portb ddrb pinb portc ddrc pinc portd ddrd pind spdr spsr spcr udr0 '
|
||||
+ 'ucsr0a ucsr0b ubrr0l acsr admux adcsr adch adcl porte ddre pine pinf',
|
||||
meta:
|
||||
'.byte .cseg .db .def .device .dseg .dw .endmacro .equ .eseg .exit .include .list '
|
||||
+ '.listmac .macro .nolist .org .set'
|
||||
},
|
||||
contains: [
|
||||
hljs.C_BLOCK_COMMENT_MODE,
|
||||
hljs.COMMENT(
|
||||
';',
|
||||
'$',
|
||||
{ relevance: 0 }
|
||||
),
|
||||
hljs.C_NUMBER_MODE, // 0x..., decimal, float
|
||||
hljs.BINARY_NUMBER_MODE, // 0b...
|
||||
{
|
||||
className: 'number',
|
||||
begin: '\\b(\\$[a-zA-Z0-9]+|0o[0-7]+)' // $..., 0o...
|
||||
},
|
||||
hljs.QUOTE_STRING_MODE,
|
||||
{
|
||||
className: 'string',
|
||||
begin: '\'',
|
||||
end: '[^\\\\]\'',
|
||||
illegal: '[^\\\\][^\']'
|
||||
},
|
||||
{
|
||||
className: 'symbol',
|
||||
begin: '^[A-Za-z0-9_.$]+:'
|
||||
},
|
||||
{
|
||||
className: 'meta',
|
||||
begin: '#',
|
||||
end: '$'
|
||||
},
|
||||
{ // substitution within a macro
|
||||
className: 'subst',
|
||||
begin: '@[0-9]+'
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
export { avrasm as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/avrasm" instead of "highlight.js/lib/languages/avrasm.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './avrasm.js';
|
||||
export default lang;
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
Language: Awk
|
||||
Author: Matthew Daly <matthewbdaly@gmail.com>
|
||||
Website: https://www.gnu.org/software/gawk/manual/gawk.html
|
||||
Description: language definition for Awk scripts
|
||||
Category: scripting
|
||||
*/
|
||||
|
||||
/** @type LanguageFn */
|
||||
function awk(hljs) {
|
||||
const VARIABLE = {
|
||||
className: 'variable',
|
||||
variants: [
|
||||
{ begin: /\$[\w\d#@][\w\d_]*/ },
|
||||
{ begin: /\$\{(.*?)\}/ }
|
||||
]
|
||||
};
|
||||
const KEYWORDS = 'BEGIN END if else while do for in break continue delete next nextfile function func exit|10';
|
||||
const STRING = {
|
||||
className: 'string',
|
||||
contains: [ hljs.BACKSLASH_ESCAPE ],
|
||||
variants: [
|
||||
{
|
||||
begin: /(u|b)?r?'''/,
|
||||
end: /'''/,
|
||||
relevance: 10
|
||||
},
|
||||
{
|
||||
begin: /(u|b)?r?"""/,
|
||||
end: /"""/,
|
||||
relevance: 10
|
||||
},
|
||||
{
|
||||
begin: /(u|r|ur)'/,
|
||||
end: /'/,
|
||||
relevance: 10
|
||||
},
|
||||
{
|
||||
begin: /(u|r|ur)"/,
|
||||
end: /"/,
|
||||
relevance: 10
|
||||
},
|
||||
{
|
||||
begin: /(b|br)'/,
|
||||
end: /'/
|
||||
},
|
||||
{
|
||||
begin: /(b|br)"/,
|
||||
end: /"/
|
||||
},
|
||||
hljs.APOS_STRING_MODE,
|
||||
hljs.QUOTE_STRING_MODE
|
||||
]
|
||||
};
|
||||
return {
|
||||
name: 'Awk',
|
||||
keywords: { keyword: KEYWORDS },
|
||||
contains: [
|
||||
VARIABLE,
|
||||
STRING,
|
||||
hljs.REGEXP_MODE,
|
||||
hljs.HASH_COMMENT_MODE,
|
||||
hljs.NUMBER_MODE
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
export { awk as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/awk" instead of "highlight.js/lib/languages/awk.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './awk.js';
|
||||
export default lang;
|
||||
+188
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
Language: Microsoft X++
|
||||
Description: X++ is a language used in Microsoft Dynamics 365, Dynamics AX, and Axapta.
|
||||
Author: Dmitri Roudakov <dmitri@roudakov.ru>
|
||||
Website: https://dynamics.microsoft.com/en-us/ax-overview/
|
||||
Category: enterprise
|
||||
*/
|
||||
|
||||
/** @type LanguageFn */
|
||||
function axapta(hljs) {
|
||||
const IDENT_RE = hljs.UNDERSCORE_IDENT_RE;
|
||||
const BUILT_IN_KEYWORDS = [
|
||||
'anytype',
|
||||
'boolean',
|
||||
'byte',
|
||||
'char',
|
||||
'container',
|
||||
'date',
|
||||
'double',
|
||||
'enum',
|
||||
'guid',
|
||||
'int',
|
||||
'int64',
|
||||
'long',
|
||||
'real',
|
||||
'short',
|
||||
'str',
|
||||
'utcdatetime',
|
||||
'var'
|
||||
];
|
||||
|
||||
const LITERAL_KEYWORDS = [
|
||||
'default',
|
||||
'false',
|
||||
'null',
|
||||
'true'
|
||||
];
|
||||
|
||||
const NORMAL_KEYWORDS = [
|
||||
'abstract',
|
||||
'as',
|
||||
'asc',
|
||||
'avg',
|
||||
'break',
|
||||
'breakpoint',
|
||||
'by',
|
||||
'byref',
|
||||
'case',
|
||||
'catch',
|
||||
'changecompany',
|
||||
'class',
|
||||
'client',
|
||||
'client',
|
||||
'common',
|
||||
'const',
|
||||
'continue',
|
||||
'count',
|
||||
'crosscompany',
|
||||
'delegate',
|
||||
'delete_from',
|
||||
'desc',
|
||||
'display',
|
||||
'div',
|
||||
'do',
|
||||
'edit',
|
||||
'else',
|
||||
'eventhandler',
|
||||
'exists',
|
||||
'extends',
|
||||
'final',
|
||||
'finally',
|
||||
'firstfast',
|
||||
'firstonly',
|
||||
'firstonly1',
|
||||
'firstonly10',
|
||||
'firstonly100',
|
||||
'firstonly1000',
|
||||
'flush',
|
||||
'for',
|
||||
'forceliterals',
|
||||
'forcenestedloop',
|
||||
'forceplaceholders',
|
||||
'forceselectorder',
|
||||
'forupdate',
|
||||
'from',
|
||||
'generateonly',
|
||||
'group',
|
||||
'hint',
|
||||
'if',
|
||||
'implements',
|
||||
'in',
|
||||
'index',
|
||||
'insert_recordset',
|
||||
'interface',
|
||||
'internal',
|
||||
'is',
|
||||
'join',
|
||||
'like',
|
||||
'maxof',
|
||||
'minof',
|
||||
'mod',
|
||||
'namespace',
|
||||
'new',
|
||||
'next',
|
||||
'nofetch',
|
||||
'notexists',
|
||||
'optimisticlock',
|
||||
'order',
|
||||
'outer',
|
||||
'pessimisticlock',
|
||||
'print',
|
||||
'private',
|
||||
'protected',
|
||||
'public',
|
||||
'readonly',
|
||||
'repeatableread',
|
||||
'retry',
|
||||
'return',
|
||||
'reverse',
|
||||
'select',
|
||||
'server',
|
||||
'setting',
|
||||
'static',
|
||||
'sum',
|
||||
'super',
|
||||
'switch',
|
||||
'this',
|
||||
'throw',
|
||||
'try',
|
||||
'ttsabort',
|
||||
'ttsbegin',
|
||||
'ttscommit',
|
||||
'unchecked',
|
||||
'update_recordset',
|
||||
'using',
|
||||
'validtimestate',
|
||||
'void',
|
||||
'where',
|
||||
'while'
|
||||
];
|
||||
|
||||
const KEYWORDS = {
|
||||
keyword: NORMAL_KEYWORDS,
|
||||
built_in: BUILT_IN_KEYWORDS,
|
||||
literal: LITERAL_KEYWORDS
|
||||
};
|
||||
|
||||
const CLASS_DEFINITION = {
|
||||
variants: [
|
||||
{ match: [
|
||||
/(class|interface)\s+/,
|
||||
IDENT_RE,
|
||||
/\s+(extends|implements)\s+/,
|
||||
IDENT_RE
|
||||
] },
|
||||
{ match: [
|
||||
/class\s+/,
|
||||
IDENT_RE
|
||||
] }
|
||||
],
|
||||
scope: {
|
||||
2: "title.class",
|
||||
4: "title.class.inherited"
|
||||
},
|
||||
keywords: KEYWORDS
|
||||
};
|
||||
|
||||
return {
|
||||
name: 'X++',
|
||||
aliases: [ 'x++' ],
|
||||
keywords: KEYWORDS,
|
||||
contains: [
|
||||
hljs.C_LINE_COMMENT_MODE,
|
||||
hljs.C_BLOCK_COMMENT_MODE,
|
||||
hljs.APOS_STRING_MODE,
|
||||
hljs.QUOTE_STRING_MODE,
|
||||
hljs.C_NUMBER_MODE,
|
||||
{
|
||||
className: 'meta',
|
||||
begin: '#',
|
||||
end: '$'
|
||||
},
|
||||
CLASS_DEFINITION
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
export { axapta as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/axapta" instead of "highlight.js/lib/languages/axapta.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './axapta.js';
|
||||
export default lang;
|
||||
+409
@@ -0,0 +1,409 @@
|
||||
/*
|
||||
Language: Bash
|
||||
Author: vah <vahtenberg@gmail.com>
|
||||
Contributrors: Benjamin Pannell <contact@sierrasoftworks.com>
|
||||
Website: https://www.gnu.org/software/bash/
|
||||
Category: common, scripting
|
||||
*/
|
||||
|
||||
/** @type LanguageFn */
|
||||
function bash(hljs) {
|
||||
const regex = hljs.regex;
|
||||
const VAR = {};
|
||||
const BRACED_VAR = {
|
||||
begin: /\$\{/,
|
||||
end: /\}/,
|
||||
contains: [
|
||||
"self",
|
||||
{
|
||||
begin: /:-/,
|
||||
contains: [ VAR ]
|
||||
} // default values
|
||||
]
|
||||
};
|
||||
Object.assign(VAR, {
|
||||
className: 'variable',
|
||||
variants: [
|
||||
{ begin: regex.concat(/\$[\w\d#@][\w\d_]*/,
|
||||
// negative look-ahead tries to avoid matching patterns that are not
|
||||
// Perl at all like $ident$, @ident@, etc.
|
||||
`(?![\\w\\d])(?![$])`) },
|
||||
BRACED_VAR
|
||||
]
|
||||
});
|
||||
|
||||
const SUBST = {
|
||||
className: 'subst',
|
||||
begin: /\$\(/,
|
||||
end: /\)/,
|
||||
contains: [ hljs.BACKSLASH_ESCAPE ]
|
||||
};
|
||||
const COMMENT = hljs.inherit(
|
||||
hljs.COMMENT(),
|
||||
{
|
||||
match: [
|
||||
/(^|\s)/,
|
||||
/#.*$/
|
||||
],
|
||||
scope: {
|
||||
2: 'comment'
|
||||
}
|
||||
}
|
||||
);
|
||||
const HERE_DOC = {
|
||||
begin: /<<-?\s*(?=\w+)/,
|
||||
starts: { contains: [
|
||||
hljs.END_SAME_AS_BEGIN({
|
||||
begin: /(\w+)/,
|
||||
end: /(\w+)/,
|
||||
className: 'string'
|
||||
})
|
||||
] }
|
||||
};
|
||||
const QUOTE_STRING = {
|
||||
className: 'string',
|
||||
begin: /"/,
|
||||
end: /"/,
|
||||
contains: [
|
||||
hljs.BACKSLASH_ESCAPE,
|
||||
VAR,
|
||||
SUBST
|
||||
]
|
||||
};
|
||||
SUBST.contains.push(QUOTE_STRING);
|
||||
const ESCAPED_QUOTE = {
|
||||
match: /\\"/
|
||||
};
|
||||
const APOS_STRING = {
|
||||
className: 'string',
|
||||
begin: /'/,
|
||||
end: /'/
|
||||
};
|
||||
const ESCAPED_APOS = {
|
||||
match: /\\'/
|
||||
};
|
||||
const ARITHMETIC = {
|
||||
begin: /\$?\(\(/,
|
||||
end: /\)\)/,
|
||||
contains: [
|
||||
{
|
||||
begin: /\d+#[0-9a-f]+/,
|
||||
className: "number"
|
||||
},
|
||||
hljs.NUMBER_MODE,
|
||||
VAR
|
||||
]
|
||||
};
|
||||
const SH_LIKE_SHELLS = [
|
||||
"fish",
|
||||
"bash",
|
||||
"zsh",
|
||||
"sh",
|
||||
"csh",
|
||||
"ksh",
|
||||
"tcsh",
|
||||
"dash",
|
||||
"scsh",
|
||||
];
|
||||
const KNOWN_SHEBANG = hljs.SHEBANG({
|
||||
binary: `(${SH_LIKE_SHELLS.join("|")})`,
|
||||
relevance: 10
|
||||
});
|
||||
const FUNCTION = {
|
||||
className: 'function',
|
||||
begin: /\w[\w\d_]*\s*\(\s*\)\s*\{/,
|
||||
returnBegin: true,
|
||||
contains: [ hljs.inherit(hljs.TITLE_MODE, { begin: /\w[\w\d_]*/ }) ],
|
||||
relevance: 0
|
||||
};
|
||||
|
||||
const KEYWORDS = [
|
||||
"if",
|
||||
"then",
|
||||
"else",
|
||||
"elif",
|
||||
"fi",
|
||||
"time",
|
||||
"for",
|
||||
"while",
|
||||
"until",
|
||||
"in",
|
||||
"do",
|
||||
"done",
|
||||
"case",
|
||||
"esac",
|
||||
"coproc",
|
||||
"function",
|
||||
"select"
|
||||
];
|
||||
|
||||
const LITERALS = [
|
||||
"true",
|
||||
"false"
|
||||
];
|
||||
|
||||
// to consume paths to prevent keyword matches inside them
|
||||
const PATH_MODE = { match: /(\/[a-z._-]+)+/ };
|
||||
|
||||
// http://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html
|
||||
const SHELL_BUILT_INS = [
|
||||
"break",
|
||||
"cd",
|
||||
"continue",
|
||||
"eval",
|
||||
"exec",
|
||||
"exit",
|
||||
"export",
|
||||
"getopts",
|
||||
"hash",
|
||||
"pwd",
|
||||
"readonly",
|
||||
"return",
|
||||
"shift",
|
||||
"test",
|
||||
"times",
|
||||
"trap",
|
||||
"umask",
|
||||
"unset"
|
||||
];
|
||||
|
||||
const BASH_BUILT_INS = [
|
||||
"alias",
|
||||
"bind",
|
||||
"builtin",
|
||||
"caller",
|
||||
"command",
|
||||
"declare",
|
||||
"echo",
|
||||
"enable",
|
||||
"help",
|
||||
"let",
|
||||
"local",
|
||||
"logout",
|
||||
"mapfile",
|
||||
"printf",
|
||||
"read",
|
||||
"readarray",
|
||||
"source",
|
||||
"sudo",
|
||||
"type",
|
||||
"typeset",
|
||||
"ulimit",
|
||||
"unalias"
|
||||
];
|
||||
|
||||
const ZSH_BUILT_INS = [
|
||||
"autoload",
|
||||
"bg",
|
||||
"bindkey",
|
||||
"bye",
|
||||
"cap",
|
||||
"chdir",
|
||||
"clone",
|
||||
"comparguments",
|
||||
"compcall",
|
||||
"compctl",
|
||||
"compdescribe",
|
||||
"compfiles",
|
||||
"compgroups",
|
||||
"compquote",
|
||||
"comptags",
|
||||
"comptry",
|
||||
"compvalues",
|
||||
"dirs",
|
||||
"disable",
|
||||
"disown",
|
||||
"echotc",
|
||||
"echoti",
|
||||
"emulate",
|
||||
"fc",
|
||||
"fg",
|
||||
"float",
|
||||
"functions",
|
||||
"getcap",
|
||||
"getln",
|
||||
"history",
|
||||
"integer",
|
||||
"jobs",
|
||||
"kill",
|
||||
"limit",
|
||||
"log",
|
||||
"noglob",
|
||||
"popd",
|
||||
"print",
|
||||
"pushd",
|
||||
"pushln",
|
||||
"rehash",
|
||||
"sched",
|
||||
"setcap",
|
||||
"setopt",
|
||||
"stat",
|
||||
"suspend",
|
||||
"ttyctl",
|
||||
"unfunction",
|
||||
"unhash",
|
||||
"unlimit",
|
||||
"unsetopt",
|
||||
"vared",
|
||||
"wait",
|
||||
"whence",
|
||||
"where",
|
||||
"which",
|
||||
"zcompile",
|
||||
"zformat",
|
||||
"zftp",
|
||||
"zle",
|
||||
"zmodload",
|
||||
"zparseopts",
|
||||
"zprof",
|
||||
"zpty",
|
||||
"zregexparse",
|
||||
"zsocket",
|
||||
"zstyle",
|
||||
"ztcp"
|
||||
];
|
||||
|
||||
const GNU_CORE_UTILS = [
|
||||
"chcon",
|
||||
"chgrp",
|
||||
"chown",
|
||||
"chmod",
|
||||
"cp",
|
||||
"dd",
|
||||
"df",
|
||||
"dir",
|
||||
"dircolors",
|
||||
"ln",
|
||||
"ls",
|
||||
"mkdir",
|
||||
"mkfifo",
|
||||
"mknod",
|
||||
"mktemp",
|
||||
"mv",
|
||||
"realpath",
|
||||
"rm",
|
||||
"rmdir",
|
||||
"shred",
|
||||
"sync",
|
||||
"touch",
|
||||
"truncate",
|
||||
"vdir",
|
||||
"b2sum",
|
||||
"base32",
|
||||
"base64",
|
||||
"cat",
|
||||
"cksum",
|
||||
"comm",
|
||||
"csplit",
|
||||
"cut",
|
||||
"expand",
|
||||
"fmt",
|
||||
"fold",
|
||||
"head",
|
||||
"join",
|
||||
"md5sum",
|
||||
"nl",
|
||||
"numfmt",
|
||||
"od",
|
||||
"paste",
|
||||
"ptx",
|
||||
"pr",
|
||||
"sha1sum",
|
||||
"sha224sum",
|
||||
"sha256sum",
|
||||
"sha384sum",
|
||||
"sha512sum",
|
||||
"shuf",
|
||||
"sort",
|
||||
"split",
|
||||
"sum",
|
||||
"tac",
|
||||
"tail",
|
||||
"tr",
|
||||
"tsort",
|
||||
"unexpand",
|
||||
"uniq",
|
||||
"wc",
|
||||
"arch",
|
||||
"basename",
|
||||
"chroot",
|
||||
"date",
|
||||
"dirname",
|
||||
"du",
|
||||
"echo",
|
||||
"env",
|
||||
"expr",
|
||||
"factor",
|
||||
// "false", // keyword literal already
|
||||
"groups",
|
||||
"hostid",
|
||||
"id",
|
||||
"link",
|
||||
"logname",
|
||||
"nice",
|
||||
"nohup",
|
||||
"nproc",
|
||||
"pathchk",
|
||||
"pinky",
|
||||
"printenv",
|
||||
"printf",
|
||||
"pwd",
|
||||
"readlink",
|
||||
"runcon",
|
||||
"seq",
|
||||
"sleep",
|
||||
"stat",
|
||||
"stdbuf",
|
||||
"stty",
|
||||
"tee",
|
||||
"test",
|
||||
"timeout",
|
||||
// "true", // keyword literal already
|
||||
"tty",
|
||||
"uname",
|
||||
"unlink",
|
||||
"uptime",
|
||||
"users",
|
||||
"who",
|
||||
"whoami",
|
||||
"yes"
|
||||
];
|
||||
|
||||
return {
|
||||
name: 'Bash',
|
||||
aliases: [
|
||||
'sh',
|
||||
'zsh'
|
||||
],
|
||||
keywords: {
|
||||
$pattern: /\b[a-z][a-z0-9._-]+\b/,
|
||||
keyword: KEYWORDS,
|
||||
literal: LITERALS,
|
||||
built_in: [
|
||||
...SHELL_BUILT_INS,
|
||||
...BASH_BUILT_INS,
|
||||
// Shell modifiers
|
||||
"set",
|
||||
"shopt",
|
||||
...ZSH_BUILT_INS,
|
||||
...GNU_CORE_UTILS
|
||||
]
|
||||
},
|
||||
contains: [
|
||||
KNOWN_SHEBANG, // to catch known shells and boost relevancy
|
||||
hljs.SHEBANG(), // to catch unknown shells but still highlight the shebang
|
||||
FUNCTION,
|
||||
ARITHMETIC,
|
||||
COMMENT,
|
||||
HERE_DOC,
|
||||
PATH_MODE,
|
||||
QUOTE_STRING,
|
||||
ESCAPED_QUOTE,
|
||||
APOS_STRING,
|
||||
ESCAPED_APOS,
|
||||
VAR
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
export { bash as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/bash" instead of "highlight.js/lib/languages/bash.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './bash.js';
|
||||
export default lang;
|
||||
+236
@@ -0,0 +1,236 @@
|
||||
/*
|
||||
Language: BASIC
|
||||
Author: Raphaël Assénat <raph@raphnet.net>
|
||||
Description: Based on the BASIC reference from the Tandy 1000 guide
|
||||
Website: https://en.wikipedia.org/wiki/Tandy_1000
|
||||
Category: system
|
||||
*/
|
||||
|
||||
/** @type LanguageFn */
|
||||
function basic(hljs) {
|
||||
const KEYWORDS = [
|
||||
"ABS",
|
||||
"ASC",
|
||||
"AND",
|
||||
"ATN",
|
||||
"AUTO|0",
|
||||
"BEEP",
|
||||
"BLOAD|10",
|
||||
"BSAVE|10",
|
||||
"CALL",
|
||||
"CALLS",
|
||||
"CDBL",
|
||||
"CHAIN",
|
||||
"CHDIR",
|
||||
"CHR$|10",
|
||||
"CINT",
|
||||
"CIRCLE",
|
||||
"CLEAR",
|
||||
"CLOSE",
|
||||
"CLS",
|
||||
"COLOR",
|
||||
"COM",
|
||||
"COMMON",
|
||||
"CONT",
|
||||
"COS",
|
||||
"CSNG",
|
||||
"CSRLIN",
|
||||
"CVD",
|
||||
"CVI",
|
||||
"CVS",
|
||||
"DATA",
|
||||
"DATE$",
|
||||
"DEFDBL",
|
||||
"DEFINT",
|
||||
"DEFSNG",
|
||||
"DEFSTR",
|
||||
"DEF|0",
|
||||
"SEG",
|
||||
"USR",
|
||||
"DELETE",
|
||||
"DIM",
|
||||
"DRAW",
|
||||
"EDIT",
|
||||
"END",
|
||||
"ENVIRON",
|
||||
"ENVIRON$",
|
||||
"EOF",
|
||||
"EQV",
|
||||
"ERASE",
|
||||
"ERDEV",
|
||||
"ERDEV$",
|
||||
"ERL",
|
||||
"ERR",
|
||||
"ERROR",
|
||||
"EXP",
|
||||
"FIELD",
|
||||
"FILES",
|
||||
"FIX",
|
||||
"FOR|0",
|
||||
"FRE",
|
||||
"GET",
|
||||
"GOSUB|10",
|
||||
"GOTO",
|
||||
"HEX$",
|
||||
"IF",
|
||||
"THEN",
|
||||
"ELSE|0",
|
||||
"INKEY$",
|
||||
"INP",
|
||||
"INPUT",
|
||||
"INPUT#",
|
||||
"INPUT$",
|
||||
"INSTR",
|
||||
"IMP",
|
||||
"INT",
|
||||
"IOCTL",
|
||||
"IOCTL$",
|
||||
"KEY",
|
||||
"ON",
|
||||
"OFF",
|
||||
"LIST",
|
||||
"KILL",
|
||||
"LEFT$",
|
||||
"LEN",
|
||||
"LET",
|
||||
"LINE",
|
||||
"LLIST",
|
||||
"LOAD",
|
||||
"LOC",
|
||||
"LOCATE",
|
||||
"LOF",
|
||||
"LOG",
|
||||
"LPRINT",
|
||||
"USING",
|
||||
"LSET",
|
||||
"MERGE",
|
||||
"MID$",
|
||||
"MKDIR",
|
||||
"MKD$",
|
||||
"MKI$",
|
||||
"MKS$",
|
||||
"MOD",
|
||||
"NAME",
|
||||
"NEW",
|
||||
"NEXT",
|
||||
"NOISE",
|
||||
"NOT",
|
||||
"OCT$",
|
||||
"ON",
|
||||
"OR",
|
||||
"PEN",
|
||||
"PLAY",
|
||||
"STRIG",
|
||||
"OPEN",
|
||||
"OPTION",
|
||||
"BASE",
|
||||
"OUT",
|
||||
"PAINT",
|
||||
"PALETTE",
|
||||
"PCOPY",
|
||||
"PEEK",
|
||||
"PMAP",
|
||||
"POINT",
|
||||
"POKE",
|
||||
"POS",
|
||||
"PRINT",
|
||||
"PRINT]",
|
||||
"PSET",
|
||||
"PRESET",
|
||||
"PUT",
|
||||
"RANDOMIZE",
|
||||
"READ",
|
||||
"REM",
|
||||
"RENUM",
|
||||
"RESET|0",
|
||||
"RESTORE",
|
||||
"RESUME",
|
||||
"RETURN|0",
|
||||
"RIGHT$",
|
||||
"RMDIR",
|
||||
"RND",
|
||||
"RSET",
|
||||
"RUN",
|
||||
"SAVE",
|
||||
"SCREEN",
|
||||
"SGN",
|
||||
"SHELL",
|
||||
"SIN",
|
||||
"SOUND",
|
||||
"SPACE$",
|
||||
"SPC",
|
||||
"SQR",
|
||||
"STEP",
|
||||
"STICK",
|
||||
"STOP",
|
||||
"STR$",
|
||||
"STRING$",
|
||||
"SWAP",
|
||||
"SYSTEM",
|
||||
"TAB",
|
||||
"TAN",
|
||||
"TIME$",
|
||||
"TIMER",
|
||||
"TROFF",
|
||||
"TRON",
|
||||
"TO",
|
||||
"USR",
|
||||
"VAL",
|
||||
"VARPTR",
|
||||
"VARPTR$",
|
||||
"VIEW",
|
||||
"WAIT",
|
||||
"WHILE",
|
||||
"WEND",
|
||||
"WIDTH",
|
||||
"WINDOW",
|
||||
"WRITE",
|
||||
"XOR"
|
||||
];
|
||||
|
||||
return {
|
||||
name: 'BASIC',
|
||||
case_insensitive: true,
|
||||
illegal: '^\.',
|
||||
// Support explicitly typed variables that end with $%! or #.
|
||||
keywords: {
|
||||
$pattern: '[a-zA-Z][a-zA-Z0-9_$%!#]*',
|
||||
keyword: KEYWORDS
|
||||
},
|
||||
contains: [
|
||||
{
|
||||
// Match strings that start with " and end with " or a line break
|
||||
scope: 'string',
|
||||
begin: /"/,
|
||||
end: /"|$/,
|
||||
contains: [ hljs.BACKSLASH_ESCAPE ]
|
||||
},
|
||||
hljs.COMMENT('REM', '$', { relevance: 10 }),
|
||||
hljs.COMMENT('\'', '$', { relevance: 0 }),
|
||||
{
|
||||
// Match line numbers
|
||||
className: 'symbol',
|
||||
begin: '^[0-9]+ ',
|
||||
relevance: 10
|
||||
},
|
||||
{
|
||||
// Match typed numeric constants (1000, 12.34!, 1.2e5, 1.5#, 1.2D2)
|
||||
className: 'number',
|
||||
begin: '\\b\\d+(\\.\\d+)?([edED]\\d+)?[#\!]?',
|
||||
relevance: 0
|
||||
},
|
||||
{
|
||||
// Match hexadecimal numbers (&Hxxxx)
|
||||
className: 'number',
|
||||
begin: '(&[hH][0-9a-fA-F]{1,4})'
|
||||
},
|
||||
{
|
||||
// Match octal numbers (&Oxxxxxx)
|
||||
className: 'number',
|
||||
begin: '(&[oO][0-7]{1,6})'
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
export { basic as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/basic" instead of "highlight.js/lib/languages/basic.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './basic.js';
|
||||
export default lang;
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
Language: Backus–Naur Form
|
||||
Website: https://en.wikipedia.org/wiki/Backus–Naur_form
|
||||
Category: syntax
|
||||
Author: Oleg Efimov <efimovov@gmail.com>
|
||||
*/
|
||||
|
||||
/** @type LanguageFn */
|
||||
function bnf(hljs) {
|
||||
return {
|
||||
name: 'Backus–Naur Form',
|
||||
contains: [
|
||||
// Attribute
|
||||
{
|
||||
className: 'attribute',
|
||||
begin: /</,
|
||||
end: />/
|
||||
},
|
||||
// Specific
|
||||
{
|
||||
begin: /::=/,
|
||||
end: /$/,
|
||||
contains: [
|
||||
{
|
||||
begin: /</,
|
||||
end: />/
|
||||
},
|
||||
// Common
|
||||
hljs.C_LINE_COMMENT_MODE,
|
||||
hljs.C_BLOCK_COMMENT_MODE,
|
||||
hljs.APOS_STRING_MODE,
|
||||
hljs.QUOTE_STRING_MODE
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
export { bnf as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/bnf" instead of "highlight.js/lib/languages/bnf.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './bnf.js';
|
||||
export default lang;
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
Language: Brainfuck
|
||||
Author: Evgeny Stepanischev <imbolk@gmail.com>
|
||||
Website: https://esolangs.org/wiki/Brainfuck
|
||||
*/
|
||||
|
||||
/** @type LanguageFn */
|
||||
function brainfuck(hljs) {
|
||||
const LITERAL = {
|
||||
className: 'literal',
|
||||
begin: /[+-]+/,
|
||||
relevance: 0
|
||||
};
|
||||
return {
|
||||
name: 'Brainfuck',
|
||||
aliases: [ 'bf' ],
|
||||
contains: [
|
||||
hljs.COMMENT(
|
||||
/[^\[\]\.,\+\-<> \r\n]/,
|
||||
/[\[\]\.,\+\-<> \r\n]/,
|
||||
{
|
||||
contains: [
|
||||
{
|
||||
match: /[ ]+[^\[\]\.,\+\-<> \r\n]/,
|
||||
relevance: 0
|
||||
}
|
||||
],
|
||||
returnEnd: true,
|
||||
relevance: 0
|
||||
}
|
||||
),
|
||||
{
|
||||
className: 'title',
|
||||
begin: '[\\[\\]]',
|
||||
relevance: 0
|
||||
},
|
||||
{
|
||||
className: 'string',
|
||||
begin: '[\\.,]',
|
||||
relevance: 0
|
||||
},
|
||||
{
|
||||
// this mode works as the only relevance counter
|
||||
// it looks ahead to find the start of a run of literals
|
||||
// so only the runs are counted as relevant
|
||||
begin: /(?=\+\+|--)/,
|
||||
contains: [ LITERAL ]
|
||||
},
|
||||
LITERAL
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
export { brainfuck as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/brainfuck" instead of "highlight.js/lib/languages/brainfuck.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './brainfuck.js';
|
||||
export default lang;
|
||||
+333
@@ -0,0 +1,333 @@
|
||||
/*
|
||||
Language: C
|
||||
Category: common, system
|
||||
Website: https://en.wikipedia.org/wiki/C_(programming_language)
|
||||
*/
|
||||
|
||||
/** @type LanguageFn */
|
||||
function c(hljs) {
|
||||
const regex = hljs.regex;
|
||||
// added for historic reasons because `hljs.C_LINE_COMMENT_MODE` does
|
||||
// not include such support nor can we be sure all the grammars depending
|
||||
// on it would desire this behavior
|
||||
const C_LINE_COMMENT_MODE = hljs.COMMENT('//', '$', { contains: [ { begin: /\\\n/ } ] });
|
||||
const DECLTYPE_AUTO_RE = 'decltype\\(auto\\)';
|
||||
const NAMESPACE_RE = '[a-zA-Z_]\\w*::';
|
||||
const TEMPLATE_ARGUMENT_RE = '<[^<>]+>';
|
||||
const FUNCTION_TYPE_RE = '('
|
||||
+ DECLTYPE_AUTO_RE + '|'
|
||||
+ regex.optional(NAMESPACE_RE)
|
||||
+ '[a-zA-Z_]\\w*' + regex.optional(TEMPLATE_ARGUMENT_RE)
|
||||
+ ')';
|
||||
|
||||
|
||||
const TYPES = {
|
||||
className: 'type',
|
||||
variants: [
|
||||
{ begin: '\\b[a-z\\d_]*_t\\b' },
|
||||
{ match: /\batomic_[a-z]{3,6}\b/ }
|
||||
]
|
||||
|
||||
};
|
||||
|
||||
// https://en.cppreference.com/w/cpp/language/escape
|
||||
// \\ \x \xFF \u2837 \u00323747 \374
|
||||
const CHARACTER_ESCAPES = '\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)';
|
||||
const STRINGS = {
|
||||
className: 'string',
|
||||
variants: [
|
||||
{
|
||||
begin: '(u8?|U|L)?"',
|
||||
end: '"',
|
||||
illegal: '\\n',
|
||||
contains: [ hljs.BACKSLASH_ESCAPE ]
|
||||
},
|
||||
{
|
||||
begin: '(u8?|U|L)?\'(' + CHARACTER_ESCAPES + "|.)",
|
||||
end: '\'',
|
||||
illegal: '.'
|
||||
},
|
||||
hljs.END_SAME_AS_BEGIN({
|
||||
begin: /(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,
|
||||
end: /\)([^()\\ ]{0,16})"/
|
||||
})
|
||||
]
|
||||
};
|
||||
|
||||
const NUMBERS = {
|
||||
className: 'number',
|
||||
variants: [
|
||||
{ match: /\b(0b[01']+)/ },
|
||||
{ match: /(-?)\b([\d']+(\.[\d']*)?|\.[\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)/ },
|
||||
{ match: /(-?)\b(0[xX][a-fA-F0-9]+(?:'[a-fA-F0-9]+)*(?:\.[a-fA-F0-9]*(?:'[a-fA-F0-9]*)*)?(?:[pP][-+]?[0-9]+)?(l|L)?(u|U)?)/ },
|
||||
{ match: /(-?)\b\d+(?:'\d+)*(?:\.\d*(?:'\d*)*)?(?:[eE][-+]?\d+)?/ }
|
||||
],
|
||||
relevance: 0
|
||||
};
|
||||
|
||||
const PREPROCESSOR = {
|
||||
className: 'meta',
|
||||
begin: /#\s*[a-z]+\b/,
|
||||
end: /$/,
|
||||
keywords: { keyword:
|
||||
'if else elif endif define undef warning error line '
|
||||
+ 'pragma _Pragma ifdef ifndef elifdef elifndef include' },
|
||||
contains: [
|
||||
{
|
||||
begin: /\\\n/,
|
||||
relevance: 0
|
||||
},
|
||||
hljs.inherit(STRINGS, { className: 'string' }),
|
||||
{
|
||||
className: 'string',
|
||||
begin: /<.*?>/
|
||||
},
|
||||
C_LINE_COMMENT_MODE,
|
||||
hljs.C_BLOCK_COMMENT_MODE
|
||||
]
|
||||
};
|
||||
|
||||
const TITLE_MODE = {
|
||||
className: 'title',
|
||||
begin: regex.optional(NAMESPACE_RE) + hljs.IDENT_RE,
|
||||
relevance: 0
|
||||
};
|
||||
|
||||
const FUNCTION_TITLE = regex.optional(NAMESPACE_RE) + hljs.IDENT_RE + '\\s*\\(';
|
||||
|
||||
const C_KEYWORDS = [
|
||||
"asm",
|
||||
"auto",
|
||||
"break",
|
||||
"case",
|
||||
"continue",
|
||||
"default",
|
||||
"do",
|
||||
"else",
|
||||
"enum",
|
||||
"extern",
|
||||
"for",
|
||||
"fortran",
|
||||
"goto",
|
||||
"if",
|
||||
"inline",
|
||||
"register",
|
||||
"restrict",
|
||||
"return",
|
||||
"sizeof",
|
||||
"typeof",
|
||||
"typeof_unqual",
|
||||
"struct",
|
||||
"switch",
|
||||
"typedef",
|
||||
"union",
|
||||
"volatile",
|
||||
"while",
|
||||
"_Alignas",
|
||||
"_Alignof",
|
||||
"_Atomic",
|
||||
"_Generic",
|
||||
"_Noreturn",
|
||||
"_Static_assert",
|
||||
"_Thread_local",
|
||||
// aliases
|
||||
"alignas",
|
||||
"alignof",
|
||||
"noreturn",
|
||||
"static_assert",
|
||||
"thread_local",
|
||||
// not a C keyword but is, for all intents and purposes, treated exactly like one.
|
||||
"_Pragma"
|
||||
];
|
||||
|
||||
const C_TYPES = [
|
||||
"float",
|
||||
"double",
|
||||
"signed",
|
||||
"unsigned",
|
||||
"int",
|
||||
"short",
|
||||
"long",
|
||||
"char",
|
||||
"void",
|
||||
"_Bool",
|
||||
"_BitInt",
|
||||
"_Complex",
|
||||
"_Imaginary",
|
||||
"_Decimal32",
|
||||
"_Decimal64",
|
||||
"_Decimal96",
|
||||
"_Decimal128",
|
||||
"_Decimal64x",
|
||||
"_Decimal128x",
|
||||
"_Float16",
|
||||
"_Float32",
|
||||
"_Float64",
|
||||
"_Float128",
|
||||
"_Float32x",
|
||||
"_Float64x",
|
||||
"_Float128x",
|
||||
// modifiers
|
||||
"const",
|
||||
"static",
|
||||
"constexpr",
|
||||
// aliases
|
||||
"complex",
|
||||
"bool",
|
||||
"imaginary"
|
||||
];
|
||||
|
||||
const KEYWORDS = {
|
||||
keyword: C_KEYWORDS,
|
||||
type: C_TYPES,
|
||||
literal: 'true false NULL',
|
||||
// TODO: apply hinting work similar to what was done in cpp.js
|
||||
built_in: 'std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream '
|
||||
+ 'auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set '
|
||||
+ 'unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos '
|
||||
+ 'asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp '
|
||||
+ 'fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper '
|
||||
+ 'isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow '
|
||||
+ 'printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp '
|
||||
+ 'strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan '
|
||||
+ 'vfprintf vprintf vsprintf endl initializer_list unique_ptr',
|
||||
};
|
||||
|
||||
const EXPRESSION_CONTAINS = [
|
||||
PREPROCESSOR,
|
||||
TYPES,
|
||||
C_LINE_COMMENT_MODE,
|
||||
hljs.C_BLOCK_COMMENT_MODE,
|
||||
NUMBERS,
|
||||
STRINGS
|
||||
];
|
||||
|
||||
const EXPRESSION_CONTEXT = {
|
||||
// This mode covers expression context where we can't expect a function
|
||||
// definition and shouldn't highlight anything that looks like one:
|
||||
// `return some()`, `else if()`, `(x*sum(1, 2))`
|
||||
variants: [
|
||||
{
|
||||
begin: /=/,
|
||||
end: /;/
|
||||
},
|
||||
{
|
||||
begin: /\(/,
|
||||
end: /\)/
|
||||
},
|
||||
{
|
||||
beginKeywords: 'new throw return else',
|
||||
end: /;/
|
||||
}
|
||||
],
|
||||
keywords: KEYWORDS,
|
||||
contains: EXPRESSION_CONTAINS.concat([
|
||||
{
|
||||
begin: /\(/,
|
||||
end: /\)/,
|
||||
keywords: KEYWORDS,
|
||||
contains: EXPRESSION_CONTAINS.concat([ 'self' ]),
|
||||
relevance: 0
|
||||
}
|
||||
]),
|
||||
relevance: 0
|
||||
};
|
||||
|
||||
const FUNCTION_DECLARATION = {
|
||||
begin: '(' + FUNCTION_TYPE_RE + '[\\*&\\s]+)+' + FUNCTION_TITLE,
|
||||
returnBegin: true,
|
||||
end: /[{;=]/,
|
||||
excludeEnd: true,
|
||||
keywords: KEYWORDS,
|
||||
illegal: /[^\w\s\*&:<>.]/,
|
||||
contains: [
|
||||
{ // to prevent it from being confused as the function title
|
||||
begin: DECLTYPE_AUTO_RE,
|
||||
keywords: KEYWORDS,
|
||||
relevance: 0
|
||||
},
|
||||
{
|
||||
begin: FUNCTION_TITLE,
|
||||
returnBegin: true,
|
||||
contains: [ hljs.inherit(TITLE_MODE, { className: "title.function" }) ],
|
||||
relevance: 0
|
||||
},
|
||||
// allow for multiple declarations, e.g.:
|
||||
// extern void f(int), g(char);
|
||||
{
|
||||
relevance: 0,
|
||||
match: /,/
|
||||
},
|
||||
{
|
||||
className: 'params',
|
||||
begin: /\(/,
|
||||
end: /\)/,
|
||||
keywords: KEYWORDS,
|
||||
relevance: 0,
|
||||
contains: [
|
||||
C_LINE_COMMENT_MODE,
|
||||
hljs.C_BLOCK_COMMENT_MODE,
|
||||
STRINGS,
|
||||
NUMBERS,
|
||||
TYPES,
|
||||
// Count matching parentheses.
|
||||
{
|
||||
begin: /\(/,
|
||||
end: /\)/,
|
||||
keywords: KEYWORDS,
|
||||
relevance: 0,
|
||||
contains: [
|
||||
'self',
|
||||
C_LINE_COMMENT_MODE,
|
||||
hljs.C_BLOCK_COMMENT_MODE,
|
||||
STRINGS,
|
||||
NUMBERS,
|
||||
TYPES
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
TYPES,
|
||||
C_LINE_COMMENT_MODE,
|
||||
hljs.C_BLOCK_COMMENT_MODE,
|
||||
PREPROCESSOR
|
||||
]
|
||||
};
|
||||
|
||||
return {
|
||||
name: "C",
|
||||
aliases: [ 'h' ],
|
||||
keywords: KEYWORDS,
|
||||
// Until differentiations are added between `c` and `cpp`, `c` will
|
||||
// not be auto-detected to avoid auto-detect conflicts between C and C++
|
||||
disableAutodetect: true,
|
||||
illegal: '</',
|
||||
contains: [].concat(
|
||||
EXPRESSION_CONTEXT,
|
||||
FUNCTION_DECLARATION,
|
||||
EXPRESSION_CONTAINS,
|
||||
[
|
||||
PREPROCESSOR,
|
||||
{
|
||||
begin: hljs.IDENT_RE + '::',
|
||||
keywords: KEYWORDS
|
||||
},
|
||||
{
|
||||
className: 'class',
|
||||
beginKeywords: 'enum class struct union',
|
||||
end: /[{;:<>=]/,
|
||||
contains: [
|
||||
{ beginKeywords: "final class struct" },
|
||||
hljs.TITLE_MODE
|
||||
]
|
||||
}
|
||||
]),
|
||||
exports: {
|
||||
preprocessor: PREPROCESSOR,
|
||||
strings: STRINGS,
|
||||
keywords: KEYWORDS
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export { c as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/c" instead of "highlight.js/lib/languages/c.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './c.js';
|
||||
export default lang;
|
||||
+160
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
Language: C/AL
|
||||
Author: Kenneth Fuglsang Christensen <kfuglsang@gmail.com>
|
||||
Description: Provides highlighting of Microsoft Dynamics NAV C/AL code files
|
||||
Website: https://docs.microsoft.com/en-us/dynamics-nav/programming-in-c-al
|
||||
Category: enterprise
|
||||
*/
|
||||
|
||||
/** @type LanguageFn */
|
||||
function cal(hljs) {
|
||||
const regex = hljs.regex;
|
||||
const KEYWORDS = [
|
||||
"div",
|
||||
"mod",
|
||||
"in",
|
||||
"and",
|
||||
"or",
|
||||
"not",
|
||||
"xor",
|
||||
"asserterror",
|
||||
"begin",
|
||||
"case",
|
||||
"do",
|
||||
"downto",
|
||||
"else",
|
||||
"end",
|
||||
"exit",
|
||||
"for",
|
||||
"local",
|
||||
"if",
|
||||
"of",
|
||||
"repeat",
|
||||
"then",
|
||||
"to",
|
||||
"until",
|
||||
"while",
|
||||
"with",
|
||||
"var"
|
||||
];
|
||||
const LITERALS = 'false true';
|
||||
const COMMENT_MODES = [
|
||||
hljs.C_LINE_COMMENT_MODE,
|
||||
hljs.COMMENT(
|
||||
/\{/,
|
||||
/\}/,
|
||||
{ relevance: 0 }
|
||||
),
|
||||
hljs.COMMENT(
|
||||
/\(\*/,
|
||||
/\*\)/,
|
||||
{ relevance: 10 }
|
||||
)
|
||||
];
|
||||
const STRING = {
|
||||
className: 'string',
|
||||
begin: /'/,
|
||||
end: /'/,
|
||||
contains: [ { begin: /''/ } ]
|
||||
};
|
||||
const CHAR_STRING = {
|
||||
className: 'string',
|
||||
begin: /(#\d+)+/
|
||||
};
|
||||
const DATE = {
|
||||
className: 'number',
|
||||
begin: '\\b\\d+(\\.\\d+)?(DT|D|T)',
|
||||
relevance: 0
|
||||
};
|
||||
const DBL_QUOTED_VARIABLE = {
|
||||
className: 'string', // not a string technically but makes sense to be highlighted in the same style
|
||||
begin: '"',
|
||||
end: '"'
|
||||
};
|
||||
|
||||
const PROCEDURE = {
|
||||
match: [
|
||||
/procedure/,
|
||||
/\s+/,
|
||||
/[a-zA-Z_][\w@]*/,
|
||||
/\s*/
|
||||
],
|
||||
scope: {
|
||||
1: "keyword",
|
||||
3: "title.function"
|
||||
},
|
||||
contains: [
|
||||
{
|
||||
className: 'params',
|
||||
begin: /\(/,
|
||||
end: /\)/,
|
||||
keywords: KEYWORDS,
|
||||
contains: [
|
||||
STRING,
|
||||
CHAR_STRING,
|
||||
hljs.NUMBER_MODE
|
||||
]
|
||||
},
|
||||
...COMMENT_MODES
|
||||
]
|
||||
};
|
||||
|
||||
const OBJECT_TYPES = [
|
||||
"Table",
|
||||
"Form",
|
||||
"Report",
|
||||
"Dataport",
|
||||
"Codeunit",
|
||||
"XMLport",
|
||||
"MenuSuite",
|
||||
"Page",
|
||||
"Query"
|
||||
];
|
||||
const OBJECT = {
|
||||
match: [
|
||||
/OBJECT/,
|
||||
/\s+/,
|
||||
regex.either(...OBJECT_TYPES),
|
||||
/\s+/,
|
||||
/\d+/,
|
||||
/\s+(?=[^\s])/,
|
||||
/.*/,
|
||||
/$/
|
||||
],
|
||||
relevance: 3,
|
||||
scope: {
|
||||
1: "keyword",
|
||||
3: "type",
|
||||
5: "number",
|
||||
7: "title"
|
||||
}
|
||||
};
|
||||
|
||||
const PROPERTY = {
|
||||
match: /[\w]+(?=\=)/,
|
||||
scope: "attribute",
|
||||
relevance: 0
|
||||
};
|
||||
|
||||
return {
|
||||
name: 'C/AL',
|
||||
case_insensitive: true,
|
||||
keywords: {
|
||||
keyword: KEYWORDS,
|
||||
literal: LITERALS
|
||||
},
|
||||
illegal: /\/\*/,
|
||||
contains: [
|
||||
PROPERTY,
|
||||
STRING,
|
||||
CHAR_STRING,
|
||||
DATE,
|
||||
DBL_QUOTED_VARIABLE,
|
||||
hljs.NUMBER_MODE,
|
||||
OBJECT,
|
||||
PROCEDURE
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
export { cal as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/cal" instead of "highlight.js/lib/languages/cal.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './cal.js';
|
||||
export default lang;
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
Language: Cap’n Proto
|
||||
Author: Oleg Efimov <efimovov@gmail.com>
|
||||
Description: Cap’n Proto message definition format
|
||||
Website: https://capnproto.org/capnp-tool.html
|
||||
Category: protocols
|
||||
*/
|
||||
|
||||
/** @type LanguageFn */
|
||||
function capnproto(hljs) {
|
||||
const KEYWORDS = [
|
||||
"struct",
|
||||
"enum",
|
||||
"interface",
|
||||
"union",
|
||||
"group",
|
||||
"import",
|
||||
"using",
|
||||
"const",
|
||||
"annotation",
|
||||
"extends",
|
||||
"in",
|
||||
"of",
|
||||
"on",
|
||||
"as",
|
||||
"with",
|
||||
"from",
|
||||
"fixed"
|
||||
];
|
||||
const TYPES = [
|
||||
"Void",
|
||||
"Bool",
|
||||
"Int8",
|
||||
"Int16",
|
||||
"Int32",
|
||||
"Int64",
|
||||
"UInt8",
|
||||
"UInt16",
|
||||
"UInt32",
|
||||
"UInt64",
|
||||
"Float32",
|
||||
"Float64",
|
||||
"Text",
|
||||
"Data",
|
||||
"AnyPointer",
|
||||
"AnyStruct",
|
||||
"Capability",
|
||||
"List"
|
||||
];
|
||||
const LITERALS = [
|
||||
"true",
|
||||
"false"
|
||||
];
|
||||
const CLASS_DEFINITION = {
|
||||
variants: [
|
||||
{ match: [
|
||||
/(struct|enum|interface)/,
|
||||
/\s+/,
|
||||
hljs.IDENT_RE
|
||||
] },
|
||||
{ match: [
|
||||
/extends/,
|
||||
/\s*\(/,
|
||||
hljs.IDENT_RE,
|
||||
/\s*\)/
|
||||
] }
|
||||
],
|
||||
scope: {
|
||||
1: "keyword",
|
||||
3: "title.class"
|
||||
}
|
||||
};
|
||||
return {
|
||||
name: 'Cap’n Proto',
|
||||
aliases: [ 'capnp' ],
|
||||
keywords: {
|
||||
keyword: KEYWORDS,
|
||||
type: TYPES,
|
||||
literal: LITERALS
|
||||
},
|
||||
contains: [
|
||||
hljs.QUOTE_STRING_MODE,
|
||||
hljs.NUMBER_MODE,
|
||||
hljs.HASH_COMMENT_MODE,
|
||||
{
|
||||
className: 'meta',
|
||||
begin: /@0x[\w\d]{16};/,
|
||||
illegal: /\n/
|
||||
},
|
||||
{
|
||||
className: 'symbol',
|
||||
begin: /@\d+\b/
|
||||
},
|
||||
CLASS_DEFINITION
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
export { capnproto as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/capnproto" instead of "highlight.js/lib/languages/capnproto.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './capnproto.js';
|
||||
export default lang;
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
Language: Ceylon
|
||||
Author: Lucas Werkmeister <mail@lucaswerkmeister.de>
|
||||
Website: https://ceylon-lang.org
|
||||
Category: system
|
||||
*/
|
||||
|
||||
/** @type LanguageFn */
|
||||
function ceylon(hljs) {
|
||||
// 2.3. Identifiers and keywords
|
||||
const KEYWORDS = [
|
||||
"assembly",
|
||||
"module",
|
||||
"package",
|
||||
"import",
|
||||
"alias",
|
||||
"class",
|
||||
"interface",
|
||||
"object",
|
||||
"given",
|
||||
"value",
|
||||
"assign",
|
||||
"void",
|
||||
"function",
|
||||
"new",
|
||||
"of",
|
||||
"extends",
|
||||
"satisfies",
|
||||
"abstracts",
|
||||
"in",
|
||||
"out",
|
||||
"return",
|
||||
"break",
|
||||
"continue",
|
||||
"throw",
|
||||
"assert",
|
||||
"dynamic",
|
||||
"if",
|
||||
"else",
|
||||
"switch",
|
||||
"case",
|
||||
"for",
|
||||
"while",
|
||||
"try",
|
||||
"catch",
|
||||
"finally",
|
||||
"then",
|
||||
"let",
|
||||
"this",
|
||||
"outer",
|
||||
"super",
|
||||
"is",
|
||||
"exists",
|
||||
"nonempty"
|
||||
];
|
||||
// 7.4.1 Declaration Modifiers
|
||||
const DECLARATION_MODIFIERS = [
|
||||
"shared",
|
||||
"abstract",
|
||||
"formal",
|
||||
"default",
|
||||
"actual",
|
||||
"variable",
|
||||
"late",
|
||||
"native",
|
||||
"deprecated",
|
||||
"final",
|
||||
"sealed",
|
||||
"annotation",
|
||||
"suppressWarnings",
|
||||
"small"
|
||||
];
|
||||
// 7.4.2 Documentation
|
||||
const DOCUMENTATION = [
|
||||
"doc",
|
||||
"by",
|
||||
"license",
|
||||
"see",
|
||||
"throws",
|
||||
"tagged"
|
||||
];
|
||||
const SUBST = {
|
||||
className: 'subst',
|
||||
excludeBegin: true,
|
||||
excludeEnd: true,
|
||||
begin: /``/,
|
||||
end: /``/,
|
||||
keywords: KEYWORDS,
|
||||
relevance: 10
|
||||
};
|
||||
const EXPRESSIONS = [
|
||||
{
|
||||
// verbatim string
|
||||
className: 'string',
|
||||
begin: '"""',
|
||||
end: '"""',
|
||||
relevance: 10
|
||||
},
|
||||
{
|
||||
// string literal or template
|
||||
className: 'string',
|
||||
begin: '"',
|
||||
end: '"',
|
||||
contains: [ SUBST ]
|
||||
},
|
||||
{
|
||||
// character literal
|
||||
className: 'string',
|
||||
begin: "'",
|
||||
end: "'"
|
||||
},
|
||||
{
|
||||
// numeric literal
|
||||
className: 'number',
|
||||
begin: '#[0-9a-fA-F_]+|\\$[01_]+|[0-9_]+(?:\\.[0-9_](?:[eE][+-]?\\d+)?)?[kMGTPmunpf]?',
|
||||
relevance: 0
|
||||
}
|
||||
];
|
||||
SUBST.contains = EXPRESSIONS;
|
||||
|
||||
return {
|
||||
name: 'Ceylon',
|
||||
keywords: {
|
||||
keyword: KEYWORDS.concat(DECLARATION_MODIFIERS),
|
||||
meta: DOCUMENTATION
|
||||
},
|
||||
illegal: '\\$[^01]|#[^0-9a-fA-F]',
|
||||
contains: [
|
||||
hljs.C_LINE_COMMENT_MODE,
|
||||
hljs.COMMENT('/\\*', '\\*/', { contains: [ 'self' ] }),
|
||||
{
|
||||
// compiler annotation
|
||||
className: 'meta',
|
||||
begin: '@[a-z]\\w*(?::"[^"]*")?'
|
||||
}
|
||||
].concat(EXPRESSIONS)
|
||||
};
|
||||
}
|
||||
|
||||
export { ceylon as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/ceylon" instead of "highlight.js/lib/languages/ceylon.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './ceylon.js';
|
||||
export default lang;
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
Language: Clean
|
||||
Author: Camil Staps <info@camilstaps.nl>
|
||||
Category: functional
|
||||
Website: http://clean.cs.ru.nl
|
||||
*/
|
||||
|
||||
/** @type LanguageFn */
|
||||
function clean(hljs) {
|
||||
const KEYWORDS = [
|
||||
"if",
|
||||
"let",
|
||||
"in",
|
||||
"with",
|
||||
"where",
|
||||
"case",
|
||||
"of",
|
||||
"class",
|
||||
"instance",
|
||||
"otherwise",
|
||||
"implementation",
|
||||
"definition",
|
||||
"system",
|
||||
"module",
|
||||
"from",
|
||||
"import",
|
||||
"qualified",
|
||||
"as",
|
||||
"special",
|
||||
"code",
|
||||
"inline",
|
||||
"foreign",
|
||||
"export",
|
||||
"ccall",
|
||||
"stdcall",
|
||||
"generic",
|
||||
"derive",
|
||||
"infix",
|
||||
"infixl",
|
||||
"infixr"
|
||||
];
|
||||
return {
|
||||
name: 'Clean',
|
||||
aliases: [
|
||||
'icl',
|
||||
'dcl'
|
||||
],
|
||||
keywords: {
|
||||
keyword: KEYWORDS,
|
||||
built_in:
|
||||
'Int Real Char Bool',
|
||||
literal:
|
||||
'True False'
|
||||
},
|
||||
contains: [
|
||||
hljs.C_LINE_COMMENT_MODE,
|
||||
hljs.C_BLOCK_COMMENT_MODE,
|
||||
hljs.APOS_STRING_MODE,
|
||||
hljs.QUOTE_STRING_MODE,
|
||||
hljs.C_NUMBER_MODE,
|
||||
{ // relevance booster
|
||||
begin: '->|<-[|:]?|#!?|>>=|\\{\\||\\|\\}|:==|=:|<>' }
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
export { clean as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/clean" instead of "highlight.js/lib/languages/clean.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './clean.js';
|
||||
export default lang;
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
Language: Clojure REPL
|
||||
Description: Clojure REPL sessions
|
||||
Author: Ivan Sagalaev <maniac@softwaremaniacs.org>
|
||||
Requires: clojure.js
|
||||
Website: https://clojure.org
|
||||
Category: lisp
|
||||
*/
|
||||
|
||||
/** @type LanguageFn */
|
||||
function clojureRepl(hljs) {
|
||||
return {
|
||||
name: 'Clojure REPL',
|
||||
contains: [
|
||||
{
|
||||
className: 'meta.prompt',
|
||||
begin: /^([\w.-]+|\s*#_)?=>/,
|
||||
starts: {
|
||||
end: /$/,
|
||||
subLanguage: 'clojure'
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
export { clojureRepl as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/clojure-repl" instead of "highlight.js/lib/languages/clojure-repl.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './clojure-repl.js';
|
||||
export default lang;
|
||||
+184
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
Language: Clojure
|
||||
Description: Clojure syntax (based on lisp.js)
|
||||
Author: mfornos
|
||||
Website: https://clojure.org
|
||||
Category: lisp
|
||||
*/
|
||||
|
||||
/** @type LanguageFn */
|
||||
function clojure(hljs) {
|
||||
const SYMBOLSTART = 'a-zA-Z_\\-!.?+*=<>&\'';
|
||||
const SYMBOL_RE = '[#]?[' + SYMBOLSTART + '][' + SYMBOLSTART + '0-9/;:$#]*';
|
||||
const globals = 'def defonce defprotocol defstruct defmulti defmethod defn- defn defmacro deftype defrecord';
|
||||
const keywords = {
|
||||
$pattern: SYMBOL_RE,
|
||||
built_in:
|
||||
// Clojure keywords
|
||||
globals + ' '
|
||||
+ 'cond apply if-not if-let if not not= =|0 <|0 >|0 <=|0 >=|0 ==|0 +|0 /|0 *|0 -|0 rem '
|
||||
+ 'quot neg? pos? delay? symbol? keyword? true? false? integer? empty? coll? list? '
|
||||
+ 'set? ifn? fn? associative? sequential? sorted? counted? reversible? number? decimal? '
|
||||
+ 'class? distinct? isa? float? rational? reduced? ratio? odd? even? char? seq? vector? '
|
||||
+ 'string? map? nil? contains? zero? instance? not-every? not-any? libspec? -> ->> .. . '
|
||||
+ 'inc compare do dotimes mapcat take remove take-while drop letfn drop-last take-last '
|
||||
+ 'drop-while while intern condp case reduced cycle split-at split-with repeat replicate '
|
||||
+ 'iterate range merge zipmap declare line-seq sort comparator sort-by dorun doall nthnext '
|
||||
+ 'nthrest partition eval doseq await await-for let agent atom send send-off release-pending-sends '
|
||||
+ 'add-watch mapv filterv remove-watch agent-error restart-agent set-error-handler error-handler '
|
||||
+ 'set-error-mode! error-mode shutdown-agents quote var fn loop recur throw try monitor-enter '
|
||||
+ 'monitor-exit macroexpand macroexpand-1 for dosync and or '
|
||||
+ 'when when-not when-let comp juxt partial sequence memoize constantly complement identity assert '
|
||||
+ 'peek pop doto proxy first rest cons cast coll last butlast '
|
||||
+ 'sigs reify second ffirst fnext nfirst nnext meta with-meta ns in-ns create-ns import '
|
||||
+ 'refer keys select-keys vals key val rseq name namespace promise into transient persistent! conj! '
|
||||
+ 'assoc! dissoc! pop! disj! use class type num float double short byte boolean bigint biginteger '
|
||||
+ 'bigdec print-method print-dup throw-if printf format load compile get-in update-in pr pr-on newline '
|
||||
+ 'flush read slurp read-line subvec with-open memfn time re-find re-groups rand-int rand mod locking '
|
||||
+ 'assert-valid-fdecl alias resolve ref deref refset swap! reset! set-validator! compare-and-set! alter-meta! '
|
||||
+ 'reset-meta! commute get-validator alter ref-set ref-history-count ref-min-history ref-max-history ensure sync io! '
|
||||
+ 'new next conj set! to-array future future-call into-array aset gen-class reduce map filter find empty '
|
||||
+ 'hash-map hash-set sorted-map sorted-map-by sorted-set sorted-set-by vec vector seq flatten reverse assoc dissoc list '
|
||||
+ 'disj get union difference intersection extend extend-type extend-protocol int nth delay count concat chunk chunk-buffer '
|
||||
+ 'chunk-append chunk-first chunk-rest max min dec unchecked-inc-int unchecked-inc unchecked-dec-inc unchecked-dec unchecked-negate '
|
||||
+ 'unchecked-add-int unchecked-add unchecked-subtract-int unchecked-subtract chunk-next chunk-cons chunked-seq? prn vary-meta '
|
||||
+ 'lazy-seq spread list* str find-keyword keyword symbol gensym force rationalize'
|
||||
};
|
||||
|
||||
const SYMBOL = {
|
||||
begin: SYMBOL_RE,
|
||||
relevance: 0
|
||||
};
|
||||
const NUMBER = {
|
||||
scope: 'number',
|
||||
relevance: 0,
|
||||
variants: [
|
||||
{ match: /[-+]?0[xX][0-9a-fA-F]+N?/ }, // hexadecimal // 0x2a
|
||||
{ match: /[-+]?0[0-7]+N?/ }, // octal // 052
|
||||
{ match: /[-+]?[1-9][0-9]?[rR][0-9a-zA-Z]+N?/ }, // variable radix from 2 to 36 // 2r101010, 8r52, 36r16
|
||||
{ match: /[-+]?[0-9]+\/[0-9]+N?/ }, // ratio // 1/2
|
||||
{ match: /[-+]?[0-9]+((\.[0-9]*([eE][+-]?[0-9]+)?M?)|([eE][+-]?[0-9]+M?|M))/ }, // float // 0.42 4.2E-1M 42E1 42M
|
||||
{ match: /[-+]?([1-9][0-9]*|0)N?/ }, // int (don't match leading 0) // 42 42N
|
||||
]
|
||||
};
|
||||
const CHARACTER = {
|
||||
scope: 'character',
|
||||
variants: [
|
||||
{ match: /\\o[0-3]?[0-7]{1,2}/ }, // Unicode Octal 0 - 377
|
||||
{ match: /\\u[0-9a-fA-F]{4}/ }, // Unicode Hex 0000 - FFFF
|
||||
{ match: /\\(newline|space|tab|formfeed|backspace|return)/ }, // special characters
|
||||
{
|
||||
match: /\\\S/,
|
||||
relevance: 0
|
||||
} // any non-whitespace char
|
||||
]
|
||||
};
|
||||
const REGEX = {
|
||||
scope: 'regex',
|
||||
begin: /#"/,
|
||||
end: /"/,
|
||||
contains: [ hljs.BACKSLASH_ESCAPE ]
|
||||
};
|
||||
const STRING = hljs.inherit(hljs.QUOTE_STRING_MODE, { illegal: null });
|
||||
const COMMA = {
|
||||
scope: 'punctuation',
|
||||
match: /,/,
|
||||
relevance: 0
|
||||
};
|
||||
const COMMENT = hljs.COMMENT(
|
||||
';',
|
||||
'$',
|
||||
{ relevance: 0 }
|
||||
);
|
||||
const LITERAL = {
|
||||
className: 'literal',
|
||||
begin: /\b(true|false|nil)\b/
|
||||
};
|
||||
const COLLECTION = {
|
||||
begin: "\\[|(#::?" + SYMBOL_RE + ")?\\{",
|
||||
end: '[\\]\\}]',
|
||||
relevance: 0
|
||||
};
|
||||
const KEY = {
|
||||
className: 'symbol',
|
||||
begin: '[:]{1,2}' + SYMBOL_RE
|
||||
};
|
||||
const LIST = {
|
||||
begin: '\\(',
|
||||
end: '\\)'
|
||||
};
|
||||
const BODY = {
|
||||
endsWithParent: true,
|
||||
relevance: 0
|
||||
};
|
||||
const NAME = {
|
||||
keywords: keywords,
|
||||
className: 'name',
|
||||
begin: SYMBOL_RE,
|
||||
relevance: 0,
|
||||
starts: BODY
|
||||
};
|
||||
const DEFAULT_CONTAINS = [
|
||||
COMMA,
|
||||
LIST,
|
||||
CHARACTER,
|
||||
REGEX,
|
||||
STRING,
|
||||
COMMENT,
|
||||
KEY,
|
||||
COLLECTION,
|
||||
NUMBER,
|
||||
LITERAL,
|
||||
SYMBOL
|
||||
];
|
||||
|
||||
const GLOBAL = {
|
||||
beginKeywords: globals,
|
||||
keywords: {
|
||||
$pattern: SYMBOL_RE,
|
||||
keyword: globals
|
||||
},
|
||||
end: '(\\[|#|\\d|"|:|\\{|\\)|\\(|$)',
|
||||
contains: [
|
||||
{
|
||||
className: 'title',
|
||||
begin: SYMBOL_RE,
|
||||
relevance: 0,
|
||||
excludeEnd: true,
|
||||
// we can only have a single title
|
||||
endsParent: true
|
||||
}
|
||||
].concat(DEFAULT_CONTAINS)
|
||||
};
|
||||
|
||||
LIST.contains = [
|
||||
GLOBAL,
|
||||
NAME,
|
||||
BODY
|
||||
];
|
||||
BODY.contains = DEFAULT_CONTAINS;
|
||||
COLLECTION.contains = DEFAULT_CONTAINS;
|
||||
|
||||
return {
|
||||
name: 'Clojure',
|
||||
aliases: [
|
||||
'clj',
|
||||
'edn'
|
||||
],
|
||||
illegal: /\S/,
|
||||
contains: [
|
||||
COMMA,
|
||||
LIST,
|
||||
CHARACTER,
|
||||
REGEX,
|
||||
STRING,
|
||||
COMMENT,
|
||||
KEY,
|
||||
COLLECTION,
|
||||
NUMBER,
|
||||
LITERAL
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
export { clojure as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/clojure" instead of "highlight.js/lib/languages/clojure.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './clojure.js';
|
||||
export default lang;
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
Language: CMake
|
||||
Description: CMake is an open-source cross-platform system for build automation.
|
||||
Author: Igor Kalnitsky <igor@kalnitsky.org>
|
||||
Website: https://cmake.org
|
||||
Category: build-system
|
||||
*/
|
||||
|
||||
/** @type LanguageFn */
|
||||
function cmake(hljs) {
|
||||
return {
|
||||
name: 'CMake',
|
||||
aliases: [ 'cmake.in' ],
|
||||
case_insensitive: true,
|
||||
keywords: { keyword:
|
||||
// scripting commands
|
||||
'break cmake_host_system_information cmake_minimum_required cmake_parse_arguments '
|
||||
+ 'cmake_policy configure_file continue elseif else endforeach endfunction endif endmacro '
|
||||
+ 'endwhile execute_process file find_file find_library find_package find_path '
|
||||
+ 'find_program foreach function get_cmake_property get_directory_property '
|
||||
+ 'get_filename_component get_property if include include_guard list macro '
|
||||
+ 'mark_as_advanced math message option return separate_arguments '
|
||||
+ 'set_directory_properties set_property set site_name string unset variable_watch while '
|
||||
// project commands
|
||||
+ 'add_compile_definitions add_compile_options add_custom_command add_custom_target '
|
||||
+ 'add_definitions add_dependencies add_executable add_library add_link_options '
|
||||
+ 'add_subdirectory add_test aux_source_directory build_command create_test_sourcelist '
|
||||
+ 'define_property enable_language enable_testing export fltk_wrap_ui '
|
||||
+ 'get_source_file_property get_target_property get_test_property include_directories '
|
||||
+ 'include_external_msproject include_regular_expression install link_directories '
|
||||
+ 'link_libraries load_cache project qt_wrap_cpp qt_wrap_ui remove_definitions '
|
||||
+ 'set_source_files_properties set_target_properties set_tests_properties source_group '
|
||||
+ 'target_compile_definitions target_compile_features target_compile_options '
|
||||
+ 'target_include_directories target_link_directories target_link_libraries '
|
||||
+ 'target_link_options target_sources try_compile try_run '
|
||||
// CTest commands
|
||||
+ 'ctest_build ctest_configure ctest_coverage ctest_empty_binary_directory ctest_memcheck '
|
||||
+ 'ctest_read_custom_files ctest_run_script ctest_sleep ctest_start ctest_submit '
|
||||
+ 'ctest_test ctest_update ctest_upload '
|
||||
// deprecated commands
|
||||
+ 'build_name exec_program export_library_dependencies install_files install_programs '
|
||||
+ 'install_targets load_command make_directory output_required_files remove '
|
||||
+ 'subdir_depends subdirs use_mangled_mesa utility_source variable_requires write_file '
|
||||
+ 'qt5_use_modules qt5_use_package qt5_wrap_cpp '
|
||||
// core keywords
|
||||
+ 'on off true false and or not command policy target test exists is_newer_than '
|
||||
+ 'is_directory is_symlink is_absolute matches less greater equal less_equal '
|
||||
+ 'greater_equal strless strgreater strequal strless_equal strgreater_equal version_less '
|
||||
+ 'version_greater version_equal version_less_equal version_greater_equal in_list defined' },
|
||||
contains: [
|
||||
{
|
||||
className: 'variable',
|
||||
begin: /\$\{/,
|
||||
end: /\}/
|
||||
},
|
||||
hljs.COMMENT(/#\[\[/, /]]/),
|
||||
hljs.HASH_COMMENT_MODE,
|
||||
hljs.QUOTE_STRING_MODE,
|
||||
hljs.NUMBER_MODE
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
export { cmake as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/cmake" instead of "highlight.js/lib/languages/cmake.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './cmake.js';
|
||||
export default lang;
|
||||
+368
@@ -0,0 +1,368 @@
|
||||
const KEYWORDS = [
|
||||
"as", // for exports
|
||||
"in",
|
||||
"of",
|
||||
"if",
|
||||
"for",
|
||||
"while",
|
||||
"finally",
|
||||
"var",
|
||||
"new",
|
||||
"function",
|
||||
"do",
|
||||
"return",
|
||||
"void",
|
||||
"else",
|
||||
"break",
|
||||
"catch",
|
||||
"instanceof",
|
||||
"with",
|
||||
"throw",
|
||||
"case",
|
||||
"default",
|
||||
"try",
|
||||
"switch",
|
||||
"continue",
|
||||
"typeof",
|
||||
"delete",
|
||||
"let",
|
||||
"yield",
|
||||
"const",
|
||||
"class",
|
||||
// JS handles these with a special rule
|
||||
// "get",
|
||||
// "set",
|
||||
"debugger",
|
||||
"async",
|
||||
"await",
|
||||
"static",
|
||||
"import",
|
||||
"from",
|
||||
"export",
|
||||
"extends",
|
||||
// It's reached stage 3, which is "recommended for implementation":
|
||||
"using"
|
||||
];
|
||||
const LITERALS = [
|
||||
"true",
|
||||
"false",
|
||||
"null",
|
||||
"undefined",
|
||||
"NaN",
|
||||
"Infinity"
|
||||
];
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects
|
||||
const TYPES = [
|
||||
// Fundamental objects
|
||||
"Object",
|
||||
"Function",
|
||||
"Boolean",
|
||||
"Symbol",
|
||||
// numbers and dates
|
||||
"Math",
|
||||
"Date",
|
||||
"Number",
|
||||
"BigInt",
|
||||
// text
|
||||
"String",
|
||||
"RegExp",
|
||||
// Indexed collections
|
||||
"Array",
|
||||
"Float32Array",
|
||||
"Float64Array",
|
||||
"Int8Array",
|
||||
"Uint8Array",
|
||||
"Uint8ClampedArray",
|
||||
"Int16Array",
|
||||
"Int32Array",
|
||||
"Uint16Array",
|
||||
"Uint32Array",
|
||||
"BigInt64Array",
|
||||
"BigUint64Array",
|
||||
// Keyed collections
|
||||
"Set",
|
||||
"Map",
|
||||
"WeakSet",
|
||||
"WeakMap",
|
||||
// Structured data
|
||||
"ArrayBuffer",
|
||||
"SharedArrayBuffer",
|
||||
"Atomics",
|
||||
"DataView",
|
||||
"JSON",
|
||||
// Control abstraction objects
|
||||
"Promise",
|
||||
"Generator",
|
||||
"GeneratorFunction",
|
||||
"AsyncFunction",
|
||||
// Reflection
|
||||
"Reflect",
|
||||
"Proxy",
|
||||
// Internationalization
|
||||
"Intl",
|
||||
// WebAssembly
|
||||
"WebAssembly"
|
||||
];
|
||||
|
||||
const ERROR_TYPES = [
|
||||
"Error",
|
||||
"EvalError",
|
||||
"InternalError",
|
||||
"RangeError",
|
||||
"ReferenceError",
|
||||
"SyntaxError",
|
||||
"TypeError",
|
||||
"URIError"
|
||||
];
|
||||
|
||||
const BUILT_IN_GLOBALS = [
|
||||
"setInterval",
|
||||
"setTimeout",
|
||||
"clearInterval",
|
||||
"clearTimeout",
|
||||
|
||||
"require",
|
||||
"exports",
|
||||
|
||||
"eval",
|
||||
"isFinite",
|
||||
"isNaN",
|
||||
"parseFloat",
|
||||
"parseInt",
|
||||
"decodeURI",
|
||||
"decodeURIComponent",
|
||||
"encodeURI",
|
||||
"encodeURIComponent",
|
||||
"escape",
|
||||
"unescape"
|
||||
];
|
||||
|
||||
const BUILT_INS = [].concat(
|
||||
BUILT_IN_GLOBALS,
|
||||
TYPES,
|
||||
ERROR_TYPES
|
||||
);
|
||||
|
||||
/*
|
||||
Language: CoffeeScript
|
||||
Author: Dmytrii Nagirniak <dnagir@gmail.com>
|
||||
Contributors: Oleg Efimov <efimovov@gmail.com>, Cédric Néhémie <cedric.nehemie@gmail.com>
|
||||
Description: CoffeeScript is a programming language that transcompiles to JavaScript. For info about language see http://coffeescript.org/
|
||||
Category: scripting
|
||||
Website: https://coffeescript.org
|
||||
*/
|
||||
|
||||
|
||||
/** @type LanguageFn */
|
||||
function coffeescript(hljs) {
|
||||
const COFFEE_BUILT_INS = [
|
||||
'npm',
|
||||
'print'
|
||||
];
|
||||
const COFFEE_LITERALS = [
|
||||
'yes',
|
||||
'no',
|
||||
'on',
|
||||
'off'
|
||||
];
|
||||
const COFFEE_KEYWORDS = [
|
||||
'then',
|
||||
'unless',
|
||||
'until',
|
||||
'loop',
|
||||
'by',
|
||||
'when',
|
||||
'and',
|
||||
'or',
|
||||
'is',
|
||||
'isnt',
|
||||
'not'
|
||||
];
|
||||
const NOT_VALID_KEYWORDS = [
|
||||
"var",
|
||||
"const",
|
||||
"let",
|
||||
"function",
|
||||
"static"
|
||||
];
|
||||
const excluding = (list) =>
|
||||
(kw) => !list.includes(kw);
|
||||
const KEYWORDS$1 = {
|
||||
keyword: KEYWORDS.concat(COFFEE_KEYWORDS).filter(excluding(NOT_VALID_KEYWORDS)),
|
||||
literal: LITERALS.concat(COFFEE_LITERALS),
|
||||
built_in: BUILT_INS.concat(COFFEE_BUILT_INS)
|
||||
};
|
||||
const JS_IDENT_RE = '[A-Za-z$_][0-9A-Za-z$_]*';
|
||||
const SUBST = {
|
||||
className: 'subst',
|
||||
begin: /#\{/,
|
||||
end: /\}/,
|
||||
keywords: KEYWORDS$1
|
||||
};
|
||||
const EXPRESSIONS = [
|
||||
hljs.BINARY_NUMBER_MODE,
|
||||
hljs.inherit(hljs.C_NUMBER_MODE, { starts: {
|
||||
end: '(\\s*/)?',
|
||||
relevance: 0
|
||||
} }), // a number tries to eat the following slash to prevent treating it as a regexp
|
||||
{
|
||||
className: 'string',
|
||||
variants: [
|
||||
{
|
||||
begin: /'''/,
|
||||
end: /'''/,
|
||||
contains: [ hljs.BACKSLASH_ESCAPE ]
|
||||
},
|
||||
{
|
||||
begin: /'/,
|
||||
end: /'/,
|
||||
contains: [ hljs.BACKSLASH_ESCAPE ]
|
||||
},
|
||||
{
|
||||
begin: /"""/,
|
||||
end: /"""/,
|
||||
contains: [
|
||||
hljs.BACKSLASH_ESCAPE,
|
||||
SUBST
|
||||
]
|
||||
},
|
||||
{
|
||||
begin: /"/,
|
||||
end: /"/,
|
||||
contains: [
|
||||
hljs.BACKSLASH_ESCAPE,
|
||||
SUBST
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
className: 'regexp',
|
||||
variants: [
|
||||
{
|
||||
begin: '///',
|
||||
end: '///',
|
||||
contains: [
|
||||
SUBST,
|
||||
hljs.HASH_COMMENT_MODE
|
||||
]
|
||||
},
|
||||
{
|
||||
begin: '//[gim]{0,3}(?=\\W)',
|
||||
relevance: 0
|
||||
},
|
||||
{
|
||||
// regex can't start with space to parse x / 2 / 3 as two divisions
|
||||
// regex can't start with *, and it supports an "illegal" in the main mode
|
||||
begin: /\/(?![ *]).*?(?![\\]).\/[gim]{0,3}(?=\W)/ }
|
||||
]
|
||||
},
|
||||
{ begin: '@' + JS_IDENT_RE // relevance booster
|
||||
},
|
||||
{
|
||||
subLanguage: 'javascript',
|
||||
excludeBegin: true,
|
||||
excludeEnd: true,
|
||||
variants: [
|
||||
{
|
||||
begin: '```',
|
||||
end: '```'
|
||||
},
|
||||
{
|
||||
begin: '`',
|
||||
end: '`'
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
SUBST.contains = EXPRESSIONS;
|
||||
|
||||
const TITLE = hljs.inherit(hljs.TITLE_MODE, { begin: JS_IDENT_RE });
|
||||
const POSSIBLE_PARAMS_RE = '(\\(.*\\)\\s*)?\\B[-=]>';
|
||||
const PARAMS = {
|
||||
className: 'params',
|
||||
begin: '\\([^\\(]',
|
||||
returnBegin: true,
|
||||
/* We need another contained nameless mode to not have every nested
|
||||
pair of parens to be called "params" */
|
||||
contains: [
|
||||
{
|
||||
begin: /\(/,
|
||||
end: /\)/,
|
||||
keywords: KEYWORDS$1,
|
||||
contains: [ 'self' ].concat(EXPRESSIONS)
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
const CLASS_DEFINITION = {
|
||||
variants: [
|
||||
{ match: [
|
||||
/class\s+/,
|
||||
JS_IDENT_RE,
|
||||
/\s+extends\s+/,
|
||||
JS_IDENT_RE
|
||||
] },
|
||||
{ match: [
|
||||
/class\s+/,
|
||||
JS_IDENT_RE
|
||||
] }
|
||||
],
|
||||
scope: {
|
||||
2: "title.class",
|
||||
4: "title.class.inherited"
|
||||
},
|
||||
keywords: KEYWORDS$1
|
||||
};
|
||||
|
||||
return {
|
||||
name: 'CoffeeScript',
|
||||
aliases: [
|
||||
'coffee',
|
||||
'cson',
|
||||
'iced'
|
||||
],
|
||||
keywords: KEYWORDS$1,
|
||||
illegal: /\/\*/,
|
||||
contains: [
|
||||
...EXPRESSIONS,
|
||||
hljs.COMMENT('###', '###'),
|
||||
hljs.HASH_COMMENT_MODE,
|
||||
{
|
||||
className: 'function',
|
||||
begin: '^\\s*' + JS_IDENT_RE + '\\s*=\\s*' + POSSIBLE_PARAMS_RE,
|
||||
end: '[-=]>',
|
||||
returnBegin: true,
|
||||
contains: [
|
||||
TITLE,
|
||||
PARAMS
|
||||
]
|
||||
},
|
||||
{
|
||||
// anonymous function start
|
||||
begin: /[:\(,=]\s*/,
|
||||
relevance: 0,
|
||||
contains: [
|
||||
{
|
||||
className: 'function',
|
||||
begin: POSSIBLE_PARAMS_RE,
|
||||
end: '[-=]>',
|
||||
returnBegin: true,
|
||||
contains: [ PARAMS ]
|
||||
}
|
||||
]
|
||||
},
|
||||
CLASS_DEFINITION,
|
||||
{
|
||||
begin: JS_IDENT_RE + ':',
|
||||
end: ':',
|
||||
returnBegin: true,
|
||||
returnEnd: true,
|
||||
relevance: 0
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
export { coffeescript as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/coffeescript" instead of "highlight.js/lib/languages/coffeescript.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './coffeescript.js';
|
||||
export default lang;
|
||||
+445
@@ -0,0 +1,445 @@
|
||||
/*
|
||||
Language: Coq
|
||||
Author: Stephan Boyer <stephan@stephanboyer.com>
|
||||
Category: functional
|
||||
Website: https://coq.inria.fr
|
||||
*/
|
||||
|
||||
/** @type LanguageFn */
|
||||
function coq(hljs) {
|
||||
const KEYWORDS = [
|
||||
"_|0",
|
||||
"as",
|
||||
"at",
|
||||
"cofix",
|
||||
"else",
|
||||
"end",
|
||||
"exists",
|
||||
"exists2",
|
||||
"fix",
|
||||
"for",
|
||||
"forall",
|
||||
"fun",
|
||||
"if",
|
||||
"IF",
|
||||
"in",
|
||||
"let",
|
||||
"match",
|
||||
"mod",
|
||||
"Prop",
|
||||
"return",
|
||||
"Set",
|
||||
"then",
|
||||
"Type",
|
||||
"using",
|
||||
"where",
|
||||
"with",
|
||||
"Abort",
|
||||
"About",
|
||||
"Add",
|
||||
"Admit",
|
||||
"Admitted",
|
||||
"All",
|
||||
"Arguments",
|
||||
"Assumptions",
|
||||
"Axiom",
|
||||
"Back",
|
||||
"BackTo",
|
||||
"Backtrack",
|
||||
"Bind",
|
||||
"Blacklist",
|
||||
"Canonical",
|
||||
"Cd",
|
||||
"Check",
|
||||
"Class",
|
||||
"Classes",
|
||||
"Close",
|
||||
"Coercion",
|
||||
"Coercions",
|
||||
"CoFixpoint",
|
||||
"CoInductive",
|
||||
"Collection",
|
||||
"Combined",
|
||||
"Compute",
|
||||
"Conjecture",
|
||||
"Conjectures",
|
||||
"Constant",
|
||||
"constr",
|
||||
"Constraint",
|
||||
"Constructors",
|
||||
"Context",
|
||||
"Corollary",
|
||||
"CreateHintDb",
|
||||
"Cut",
|
||||
"Declare",
|
||||
"Defined",
|
||||
"Definition",
|
||||
"Delimit",
|
||||
"Dependencies",
|
||||
"Dependent",
|
||||
"Derive",
|
||||
"Drop",
|
||||
"eauto",
|
||||
"End",
|
||||
"Equality",
|
||||
"Eval",
|
||||
"Example",
|
||||
"Existential",
|
||||
"Existentials",
|
||||
"Existing",
|
||||
"Export",
|
||||
"exporting",
|
||||
"Extern",
|
||||
"Extract",
|
||||
"Extraction",
|
||||
"Fact",
|
||||
"Field",
|
||||
"Fields",
|
||||
"File",
|
||||
"Fixpoint",
|
||||
"Focus",
|
||||
"for",
|
||||
"From",
|
||||
"Function",
|
||||
"Functional",
|
||||
"Generalizable",
|
||||
"Global",
|
||||
"Goal",
|
||||
"Grab",
|
||||
"Grammar",
|
||||
"Graph",
|
||||
"Guarded",
|
||||
"Heap",
|
||||
"Hint",
|
||||
"HintDb",
|
||||
"Hints",
|
||||
"Hypotheses",
|
||||
"Hypothesis",
|
||||
"ident",
|
||||
"Identity",
|
||||
"If",
|
||||
"Immediate",
|
||||
"Implicit",
|
||||
"Import",
|
||||
"Include",
|
||||
"Inductive",
|
||||
"Infix",
|
||||
"Info",
|
||||
"Initial",
|
||||
"Inline",
|
||||
"Inspect",
|
||||
"Instance",
|
||||
"Instances",
|
||||
"Intro",
|
||||
"Intros",
|
||||
"Inversion",
|
||||
"Inversion_clear",
|
||||
"Language",
|
||||
"Left",
|
||||
"Lemma",
|
||||
"Let",
|
||||
"Libraries",
|
||||
"Library",
|
||||
"Load",
|
||||
"LoadPath",
|
||||
"Local",
|
||||
"Locate",
|
||||
"Ltac",
|
||||
"ML",
|
||||
"Mode",
|
||||
"Module",
|
||||
"Modules",
|
||||
"Monomorphic",
|
||||
"Morphism",
|
||||
"Next",
|
||||
"NoInline",
|
||||
"Notation",
|
||||
"Obligation",
|
||||
"Obligations",
|
||||
"Opaque",
|
||||
"Open",
|
||||
"Optimize",
|
||||
"Options",
|
||||
"Parameter",
|
||||
"Parameters",
|
||||
"Parametric",
|
||||
"Path",
|
||||
"Paths",
|
||||
"pattern",
|
||||
"Polymorphic",
|
||||
"Preterm",
|
||||
"Print",
|
||||
"Printing",
|
||||
"Program",
|
||||
"Projections",
|
||||
"Proof",
|
||||
"Proposition",
|
||||
"Pwd",
|
||||
"Qed",
|
||||
"Quit",
|
||||
"Rec",
|
||||
"Record",
|
||||
"Recursive",
|
||||
"Redirect",
|
||||
"Relation",
|
||||
"Remark",
|
||||
"Remove",
|
||||
"Require",
|
||||
"Reserved",
|
||||
"Reset",
|
||||
"Resolve",
|
||||
"Restart",
|
||||
"Rewrite",
|
||||
"Right",
|
||||
"Ring",
|
||||
"Rings",
|
||||
"Save",
|
||||
"Scheme",
|
||||
"Scope",
|
||||
"Scopes",
|
||||
"Script",
|
||||
"Search",
|
||||
"SearchAbout",
|
||||
"SearchHead",
|
||||
"SearchPattern",
|
||||
"SearchRewrite",
|
||||
"Section",
|
||||
"Separate",
|
||||
"Set",
|
||||
"Setoid",
|
||||
"Show",
|
||||
"Solve",
|
||||
"Sorted",
|
||||
"Step",
|
||||
"Strategies",
|
||||
"Strategy",
|
||||
"Structure",
|
||||
"SubClass",
|
||||
"Table",
|
||||
"Tables",
|
||||
"Tactic",
|
||||
"Term",
|
||||
"Test",
|
||||
"Theorem",
|
||||
"Time",
|
||||
"Timeout",
|
||||
"Transparent",
|
||||
"Type",
|
||||
"Typeclasses",
|
||||
"Types",
|
||||
"Undelimit",
|
||||
"Undo",
|
||||
"Unfocus",
|
||||
"Unfocused",
|
||||
"Unfold",
|
||||
"Universe",
|
||||
"Universes",
|
||||
"Unset",
|
||||
"Unshelve",
|
||||
"using",
|
||||
"Variable",
|
||||
"Variables",
|
||||
"Variant",
|
||||
"Verbose",
|
||||
"Visibility",
|
||||
"where",
|
||||
"with"
|
||||
];
|
||||
const BUILT_INS = [
|
||||
"abstract",
|
||||
"absurd",
|
||||
"admit",
|
||||
"after",
|
||||
"apply",
|
||||
"as",
|
||||
"assert",
|
||||
"assumption",
|
||||
"at",
|
||||
"auto",
|
||||
"autorewrite",
|
||||
"autounfold",
|
||||
"before",
|
||||
"bottom",
|
||||
"btauto",
|
||||
"by",
|
||||
"case",
|
||||
"case_eq",
|
||||
"cbn",
|
||||
"cbv",
|
||||
"change",
|
||||
"classical_left",
|
||||
"classical_right",
|
||||
"clear",
|
||||
"clearbody",
|
||||
"cofix",
|
||||
"compare",
|
||||
"compute",
|
||||
"congruence",
|
||||
"constr_eq",
|
||||
"constructor",
|
||||
"contradict",
|
||||
"contradiction",
|
||||
"cut",
|
||||
"cutrewrite",
|
||||
"cycle",
|
||||
"decide",
|
||||
"decompose",
|
||||
"dependent",
|
||||
"destruct",
|
||||
"destruction",
|
||||
"dintuition",
|
||||
"discriminate",
|
||||
"discrR",
|
||||
"do",
|
||||
"double",
|
||||
"dtauto",
|
||||
"eapply",
|
||||
"eassumption",
|
||||
"eauto",
|
||||
"ecase",
|
||||
"econstructor",
|
||||
"edestruct",
|
||||
"ediscriminate",
|
||||
"eelim",
|
||||
"eexact",
|
||||
"eexists",
|
||||
"einduction",
|
||||
"einjection",
|
||||
"eleft",
|
||||
"elim",
|
||||
"elimtype",
|
||||
"enough",
|
||||
"equality",
|
||||
"erewrite",
|
||||
"eright",
|
||||
"esimplify_eq",
|
||||
"esplit",
|
||||
"evar",
|
||||
"exact",
|
||||
"exactly_once",
|
||||
"exfalso",
|
||||
"exists",
|
||||
"f_equal",
|
||||
"fail",
|
||||
"field",
|
||||
"field_simplify",
|
||||
"field_simplify_eq",
|
||||
"first",
|
||||
"firstorder",
|
||||
"fix",
|
||||
"fold",
|
||||
"fourier",
|
||||
"functional",
|
||||
"generalize",
|
||||
"generalizing",
|
||||
"gfail",
|
||||
"give_up",
|
||||
"has_evar",
|
||||
"hnf",
|
||||
"idtac",
|
||||
"in",
|
||||
"induction",
|
||||
"injection",
|
||||
"instantiate",
|
||||
"intro",
|
||||
"intro_pattern",
|
||||
"intros",
|
||||
"intuition",
|
||||
"inversion",
|
||||
"inversion_clear",
|
||||
"is_evar",
|
||||
"is_var",
|
||||
"lapply",
|
||||
"lazy",
|
||||
"left",
|
||||
"lia",
|
||||
"lra",
|
||||
"move",
|
||||
"native_compute",
|
||||
"nia",
|
||||
"nsatz",
|
||||
"omega",
|
||||
"once",
|
||||
"pattern",
|
||||
"pose",
|
||||
"progress",
|
||||
"proof",
|
||||
"psatz",
|
||||
"quote",
|
||||
"record",
|
||||
"red",
|
||||
"refine",
|
||||
"reflexivity",
|
||||
"remember",
|
||||
"rename",
|
||||
"repeat",
|
||||
"replace",
|
||||
"revert",
|
||||
"revgoals",
|
||||
"rewrite",
|
||||
"rewrite_strat",
|
||||
"right",
|
||||
"ring",
|
||||
"ring_simplify",
|
||||
"rtauto",
|
||||
"set",
|
||||
"setoid_reflexivity",
|
||||
"setoid_replace",
|
||||
"setoid_rewrite",
|
||||
"setoid_symmetry",
|
||||
"setoid_transitivity",
|
||||
"shelve",
|
||||
"shelve_unifiable",
|
||||
"simpl",
|
||||
"simple",
|
||||
"simplify_eq",
|
||||
"solve",
|
||||
"specialize",
|
||||
"split",
|
||||
"split_Rabs",
|
||||
"split_Rmult",
|
||||
"stepl",
|
||||
"stepr",
|
||||
"subst",
|
||||
"sum",
|
||||
"swap",
|
||||
"symmetry",
|
||||
"tactic",
|
||||
"tauto",
|
||||
"time",
|
||||
"timeout",
|
||||
"top",
|
||||
"transitivity",
|
||||
"trivial",
|
||||
"try",
|
||||
"tryif",
|
||||
"unfold",
|
||||
"unify",
|
||||
"until",
|
||||
"using",
|
||||
"vm_compute",
|
||||
"with"
|
||||
];
|
||||
return {
|
||||
name: 'Coq',
|
||||
keywords: {
|
||||
keyword: KEYWORDS,
|
||||
built_in: BUILT_INS
|
||||
},
|
||||
contains: [
|
||||
hljs.QUOTE_STRING_MODE,
|
||||
hljs.COMMENT('\\(\\*', '\\*\\)'),
|
||||
hljs.C_NUMBER_MODE,
|
||||
{
|
||||
className: 'type',
|
||||
excludeBegin: true,
|
||||
begin: '\\|\\s*',
|
||||
end: '\\w+'
|
||||
},
|
||||
{ // relevance booster
|
||||
begin: /[-=]>/ }
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
export { coq as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/coq" instead of "highlight.js/lib/languages/coq.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './coq.js';
|
||||
export default lang;
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
Language: Caché Object Script
|
||||
Author: Nikita Savchenko <zitros.lab@gmail.com>
|
||||
Category: enterprise, scripting
|
||||
Website: https://cedocs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls
|
||||
*/
|
||||
|
||||
/** @type LanguageFn */
|
||||
function cos(hljs) {
|
||||
const STRINGS = {
|
||||
className: 'string',
|
||||
variants: [
|
||||
{
|
||||
begin: '"',
|
||||
end: '"',
|
||||
contains: [
|
||||
{ // escaped
|
||||
begin: "\"\"",
|
||||
relevance: 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
const NUMBERS = {
|
||||
className: "number",
|
||||
begin: "\\b(\\d+(\\.\\d*)?|\\.\\d+)",
|
||||
relevance: 0
|
||||
};
|
||||
|
||||
const COS_KEYWORDS =
|
||||
'property parameter class classmethod clientmethod extends as break '
|
||||
+ 'catch close continue do d|0 else elseif for goto halt hang h|0 if job '
|
||||
+ 'j|0 kill k|0 lock l|0 merge new open quit q|0 read r|0 return set s|0 '
|
||||
+ 'tcommit throw trollback try tstart use view while write w|0 xecute x|0 '
|
||||
+ 'zkill znspace zn ztrap zwrite zw zzdump zzwrite print zbreak zinsert '
|
||||
+ 'zload zprint zremove zsave zzprint mv mvcall mvcrt mvdim mvprint zquit '
|
||||
+ 'zsync ascii';
|
||||
|
||||
// registered function - no need in them due to all functions are highlighted,
|
||||
// but I'll just leave this here.
|
||||
|
||||
// "$bit", "$bitcount",
|
||||
// "$bitfind", "$bitlogic", "$case", "$char", "$classmethod", "$classname",
|
||||
// "$compile", "$data", "$decimal", "$double", "$extract", "$factor",
|
||||
// "$find", "$fnumber", "$get", "$increment", "$inumber", "$isobject",
|
||||
// "$isvaliddouble", "$isvalidnum", "$justify", "$length", "$list",
|
||||
// "$listbuild", "$listdata", "$listfind", "$listfromstring", "$listget",
|
||||
// "$listlength", "$listnext", "$listsame", "$listtostring", "$listvalid",
|
||||
// "$locate", "$match", "$method", "$name", "$nconvert", "$next",
|
||||
// "$normalize", "$now", "$number", "$order", "$parameter", "$piece",
|
||||
// "$prefetchoff", "$prefetchon", "$property", "$qlength", "$qsubscript",
|
||||
// "$query", "$random", "$replace", "$reverse", "$sconvert", "$select",
|
||||
// "$sortbegin", "$sortend", "$stack", "$text", "$translate", "$view",
|
||||
// "$wascii", "$wchar", "$wextract", "$wfind", "$wiswide", "$wlength",
|
||||
// "$wreverse", "$xecute", "$zabs", "$zarccos", "$zarcsin", "$zarctan",
|
||||
// "$zcos", "$zcot", "$zcsc", "$zdate", "$zdateh", "$zdatetime",
|
||||
// "$zdatetimeh", "$zexp", "$zhex", "$zln", "$zlog", "$zpower", "$zsec",
|
||||
// "$zsin", "$zsqr", "$ztan", "$ztime", "$ztimeh", "$zboolean",
|
||||
// "$zconvert", "$zcrc", "$zcyc", "$zdascii", "$zdchar", "$zf",
|
||||
// "$ziswide", "$zlascii", "$zlchar", "$zname", "$zposition", "$zqascii",
|
||||
// "$zqchar", "$zsearch", "$zseek", "$zstrip", "$zwascii", "$zwchar",
|
||||
// "$zwidth", "$zwpack", "$zwbpack", "$zwunpack", "$zwbunpack", "$zzenkaku",
|
||||
// "$change", "$mv", "$mvat", "$mvfmt", "$mvfmts", "$mviconv",
|
||||
// "$mviconvs", "$mvinmat", "$mvlover", "$mvoconv", "$mvoconvs", "$mvraise",
|
||||
// "$mvtrans", "$mvv", "$mvname", "$zbitand", "$zbitcount", "$zbitfind",
|
||||
// "$zbitget", "$zbitlen", "$zbitnot", "$zbitor", "$zbitset", "$zbitstr",
|
||||
// "$zbitxor", "$zincrement", "$znext", "$zorder", "$zprevious", "$zsort",
|
||||
// "device", "$ecode", "$estack", "$etrap", "$halt", "$horolog",
|
||||
// "$io", "$job", "$key", "$namespace", "$principal", "$quit", "$roles",
|
||||
// "$storage", "$system", "$test", "$this", "$tlevel", "$username",
|
||||
// "$x", "$y", "$za", "$zb", "$zchild", "$zeof", "$zeos", "$zerror",
|
||||
// "$zhorolog", "$zio", "$zjob", "$zmode", "$znspace", "$zparent", "$zpi",
|
||||
// "$zpos", "$zreference", "$zstorage", "$ztimestamp", "$ztimezone",
|
||||
// "$ztrap", "$zversion"
|
||||
|
||||
return {
|
||||
name: 'Caché Object Script',
|
||||
case_insensitive: true,
|
||||
aliases: [ "cls" ],
|
||||
keywords: COS_KEYWORDS,
|
||||
contains: [
|
||||
NUMBERS,
|
||||
STRINGS,
|
||||
hljs.C_LINE_COMMENT_MODE,
|
||||
hljs.C_BLOCK_COMMENT_MODE,
|
||||
{
|
||||
className: "comment",
|
||||
begin: /;/,
|
||||
end: "$",
|
||||
relevance: 0
|
||||
},
|
||||
{ // Functions and user-defined functions: write $ztime(60*60*3), $$myFunc(10), $$^Val(1)
|
||||
className: "built_in",
|
||||
begin: /(?:\$\$?|\.\.)\^?[a-zA-Z]+/
|
||||
},
|
||||
{ // Macro command: quit $$$OK
|
||||
className: "built_in",
|
||||
begin: /\$\$\$[a-zA-Z]+/
|
||||
},
|
||||
{ // Special (global) variables: write %request.Content; Built-in classes: %Library.Integer
|
||||
className: "built_in",
|
||||
begin: /%[a-z]+(?:\.[a-z]+)*/
|
||||
},
|
||||
{ // Global variable: set ^globalName = 12 write ^globalName
|
||||
className: "symbol",
|
||||
begin: /\^%?[a-zA-Z][\w]*/
|
||||
},
|
||||
{ // Some control constructions: do ##class(Package.ClassName).Method(), ##super()
|
||||
className: "keyword",
|
||||
begin: /##class|##super|#define|#dim/
|
||||
},
|
||||
// sub-languages: are not fully supported by hljs by 11/15/2015
|
||||
// left for the future implementation.
|
||||
{
|
||||
begin: /&sql\(/,
|
||||
end: /\)/,
|
||||
excludeBegin: true,
|
||||
excludeEnd: true,
|
||||
subLanguage: "sql"
|
||||
},
|
||||
{
|
||||
begin: /&(js|jscript|javascript)</,
|
||||
end: />/,
|
||||
excludeBegin: true,
|
||||
excludeEnd: true,
|
||||
subLanguage: "javascript"
|
||||
},
|
||||
{
|
||||
// this brakes first and last tag, but this is the only way to embed a valid html
|
||||
begin: /&html<\s*</,
|
||||
end: />\s*>/,
|
||||
subLanguage: "xml"
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
export { cos as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/cos" instead of "highlight.js/lib/languages/cos.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './cos.js';
|
||||
export default lang;
|
||||
+605
@@ -0,0 +1,605 @@
|
||||
/*
|
||||
Language: C++
|
||||
Category: common, system
|
||||
Website: https://isocpp.org
|
||||
*/
|
||||
|
||||
/** @type LanguageFn */
|
||||
function cpp(hljs) {
|
||||
const regex = hljs.regex;
|
||||
// added for historic reasons because `hljs.C_LINE_COMMENT_MODE` does
|
||||
// not include such support nor can we be sure all the grammars depending
|
||||
// on it would desire this behavior
|
||||
const C_LINE_COMMENT_MODE = hljs.COMMENT('//', '$', { contains: [ { begin: /\\\n/ } ] });
|
||||
const DECLTYPE_AUTO_RE = 'decltype\\(auto\\)';
|
||||
const NAMESPACE_RE = '[a-zA-Z_]\\w*::';
|
||||
const TEMPLATE_ARGUMENT_RE = '<[^<>]+>';
|
||||
const FUNCTION_TYPE_RE = '(?!struct)('
|
||||
+ DECLTYPE_AUTO_RE + '|'
|
||||
+ regex.optional(NAMESPACE_RE)
|
||||
+ '[a-zA-Z_]\\w*' + regex.optional(TEMPLATE_ARGUMENT_RE)
|
||||
+ ')';
|
||||
|
||||
const CPP_PRIMITIVE_TYPES = {
|
||||
className: 'type',
|
||||
begin: '\\b[a-z\\d_]*_t\\b'
|
||||
};
|
||||
|
||||
// https://en.cppreference.com/w/cpp/language/escape
|
||||
// \\ \x \xFF \u2837 \u00323747 \374
|
||||
const CHARACTER_ESCAPES = '\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)';
|
||||
const STRINGS = {
|
||||
className: 'string',
|
||||
variants: [
|
||||
{
|
||||
begin: '(u8?|U|L)?"',
|
||||
end: '"',
|
||||
illegal: '\\n',
|
||||
contains: [ hljs.BACKSLASH_ESCAPE ]
|
||||
},
|
||||
{
|
||||
begin: '(u8?|U|L)?\'(' + CHARACTER_ESCAPES + '|.)',
|
||||
end: '\'',
|
||||
illegal: '.'
|
||||
},
|
||||
hljs.END_SAME_AS_BEGIN({
|
||||
begin: /(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,
|
||||
end: /\)([^()\\ ]{0,16})"/
|
||||
})
|
||||
]
|
||||
};
|
||||
|
||||
const NUMBERS = {
|
||||
className: 'number',
|
||||
variants: [
|
||||
// Floating-point literal.
|
||||
{ begin:
|
||||
"[+-]?(?:" // Leading sign.
|
||||
// Decimal.
|
||||
+ "(?:"
|
||||
+"[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?"
|
||||
+ "|\\.[0-9](?:'?[0-9])*"
|
||||
+ ")(?:[Ee][+-]?[0-9](?:'?[0-9])*)?"
|
||||
+ "|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*"
|
||||
// Hexadecimal.
|
||||
+ "|0[Xx](?:"
|
||||
+"[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?"
|
||||
+ "|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*"
|
||||
+ ")[Pp][+-]?[0-9](?:'?[0-9])*"
|
||||
+ ")(?:" // Literal suffixes.
|
||||
+ "[Ff](?:16|32|64|128)?"
|
||||
+ "|(BF|bf)16"
|
||||
+ "|[Ll]"
|
||||
+ "|" // Literal suffix is optional.
|
||||
+ ")"
|
||||
},
|
||||
// Integer literal.
|
||||
{ begin:
|
||||
"[+-]?\\b(?:" // Leading sign.
|
||||
+ "0[Bb][01](?:'?[01])*" // Binary.
|
||||
+ "|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*" // Hexadecimal.
|
||||
+ "|0(?:'?[0-7])*" // Octal or just a lone zero.
|
||||
+ "|[1-9](?:'?[0-9])*" // Decimal.
|
||||
+ ")(?:" // Literal suffixes.
|
||||
+ "[Uu](?:LL?|ll?)"
|
||||
+ "|[Uu][Zz]?"
|
||||
+ "|(?:LL?|ll?)[Uu]?"
|
||||
+ "|[Zz][Uu]"
|
||||
+ "|" // Literal suffix is optional.
|
||||
+ ")"
|
||||
// Note: there are user-defined literal suffixes too, but perhaps having the custom suffix not part of the
|
||||
// literal highlight actually makes it stand out more.
|
||||
}
|
||||
],
|
||||
relevance: 0
|
||||
};
|
||||
|
||||
const PREPROCESSOR = {
|
||||
className: 'meta',
|
||||
begin: /#\s*[a-z]+\b/,
|
||||
end: /$/,
|
||||
keywords: { keyword:
|
||||
'if else elif endif define undef warning error line '
|
||||
+ 'pragma _Pragma ifdef ifndef include' },
|
||||
contains: [
|
||||
{
|
||||
begin: /\\\n/,
|
||||
relevance: 0
|
||||
},
|
||||
hljs.inherit(STRINGS, { className: 'string' }),
|
||||
{
|
||||
className: 'string',
|
||||
begin: /<.*?>/
|
||||
},
|
||||
C_LINE_COMMENT_MODE,
|
||||
hljs.C_BLOCK_COMMENT_MODE
|
||||
]
|
||||
};
|
||||
|
||||
const TITLE_MODE = {
|
||||
className: 'title',
|
||||
begin: regex.optional(NAMESPACE_RE) + hljs.IDENT_RE,
|
||||
relevance: 0
|
||||
};
|
||||
|
||||
const FUNCTION_TITLE = regex.optional(NAMESPACE_RE) + hljs.IDENT_RE + '\\s*\\(';
|
||||
|
||||
// https://en.cppreference.com/w/cpp/keyword
|
||||
const RESERVED_KEYWORDS = [
|
||||
'alignas',
|
||||
'alignof',
|
||||
'and',
|
||||
'and_eq',
|
||||
'asm',
|
||||
'atomic_cancel',
|
||||
'atomic_commit',
|
||||
'atomic_noexcept',
|
||||
'auto',
|
||||
'bitand',
|
||||
'bitor',
|
||||
'break',
|
||||
'case',
|
||||
'catch',
|
||||
'class',
|
||||
'co_await',
|
||||
'co_return',
|
||||
'co_yield',
|
||||
'compl',
|
||||
'concept',
|
||||
'const_cast|10',
|
||||
'consteval',
|
||||
'constexpr',
|
||||
'constinit',
|
||||
'continue',
|
||||
'decltype',
|
||||
'default',
|
||||
'delete',
|
||||
'do',
|
||||
'dynamic_cast|10',
|
||||
'else',
|
||||
'enum',
|
||||
'explicit',
|
||||
'export',
|
||||
'extern',
|
||||
'false',
|
||||
'final',
|
||||
'for',
|
||||
'friend',
|
||||
'goto',
|
||||
'if',
|
||||
'import',
|
||||
'inline',
|
||||
'module',
|
||||
'mutable',
|
||||
'namespace',
|
||||
'new',
|
||||
'noexcept',
|
||||
'not',
|
||||
'not_eq',
|
||||
'nullptr',
|
||||
'operator',
|
||||
'or',
|
||||
'or_eq',
|
||||
'override',
|
||||
'private',
|
||||
'protected',
|
||||
'public',
|
||||
'reflexpr',
|
||||
'register',
|
||||
'reinterpret_cast|10',
|
||||
'requires',
|
||||
'return',
|
||||
'sizeof',
|
||||
'static_assert',
|
||||
'static_cast|10',
|
||||
'struct',
|
||||
'switch',
|
||||
'synchronized',
|
||||
'template',
|
||||
'this',
|
||||
'thread_local',
|
||||
'throw',
|
||||
'transaction_safe',
|
||||
'transaction_safe_dynamic',
|
||||
'true',
|
||||
'try',
|
||||
'typedef',
|
||||
'typeid',
|
||||
'typename',
|
||||
'union',
|
||||
'using',
|
||||
'virtual',
|
||||
'volatile',
|
||||
'while',
|
||||
'xor',
|
||||
'xor_eq'
|
||||
];
|
||||
|
||||
// https://en.cppreference.com/w/cpp/keyword
|
||||
const RESERVED_TYPES = [
|
||||
'bool',
|
||||
'char',
|
||||
'char16_t',
|
||||
'char32_t',
|
||||
'char8_t',
|
||||
'double',
|
||||
'float',
|
||||
'int',
|
||||
'long',
|
||||
'short',
|
||||
'void',
|
||||
'wchar_t',
|
||||
'unsigned',
|
||||
'signed',
|
||||
'const',
|
||||
'static'
|
||||
];
|
||||
|
||||
const TYPE_HINTS = [
|
||||
'any',
|
||||
'auto_ptr',
|
||||
'barrier',
|
||||
'binary_semaphore',
|
||||
'bitset',
|
||||
'complex',
|
||||
'condition_variable',
|
||||
'condition_variable_any',
|
||||
'counting_semaphore',
|
||||
'deque',
|
||||
'false_type',
|
||||
'flat_map',
|
||||
'flat_set',
|
||||
'future',
|
||||
'imaginary',
|
||||
'initializer_list',
|
||||
'istringstream',
|
||||
'jthread',
|
||||
'latch',
|
||||
'lock_guard',
|
||||
'multimap',
|
||||
'multiset',
|
||||
'mutex',
|
||||
'optional',
|
||||
'ostringstream',
|
||||
'packaged_task',
|
||||
'pair',
|
||||
'promise',
|
||||
'priority_queue',
|
||||
'queue',
|
||||
'recursive_mutex',
|
||||
'recursive_timed_mutex',
|
||||
'scoped_lock',
|
||||
'set',
|
||||
'shared_future',
|
||||
'shared_lock',
|
||||
'shared_mutex',
|
||||
'shared_timed_mutex',
|
||||
'shared_ptr',
|
||||
'stack',
|
||||
'string_view',
|
||||
'stringstream',
|
||||
'timed_mutex',
|
||||
'thread',
|
||||
'true_type',
|
||||
'tuple',
|
||||
'unique_lock',
|
||||
'unique_ptr',
|
||||
'unordered_map',
|
||||
'unordered_multimap',
|
||||
'unordered_multiset',
|
||||
'unordered_set',
|
||||
'variant',
|
||||
'vector',
|
||||
'weak_ptr',
|
||||
'wstring',
|
||||
'wstring_view'
|
||||
];
|
||||
|
||||
const FUNCTION_HINTS = [
|
||||
'abort',
|
||||
'abs',
|
||||
'acos',
|
||||
'apply',
|
||||
'as_const',
|
||||
'asin',
|
||||
'atan',
|
||||
'atan2',
|
||||
'calloc',
|
||||
'ceil',
|
||||
'cerr',
|
||||
'cin',
|
||||
'clog',
|
||||
'cos',
|
||||
'cosh',
|
||||
'cout',
|
||||
'declval',
|
||||
'endl',
|
||||
'exchange',
|
||||
'exit',
|
||||
'exp',
|
||||
'fabs',
|
||||
'floor',
|
||||
'fmod',
|
||||
'forward',
|
||||
'fprintf',
|
||||
'fputs',
|
||||
'free',
|
||||
'frexp',
|
||||
'fscanf',
|
||||
'future',
|
||||
'invoke',
|
||||
'isalnum',
|
||||
'isalpha',
|
||||
'iscntrl',
|
||||
'isdigit',
|
||||
'isgraph',
|
||||
'islower',
|
||||
'isprint',
|
||||
'ispunct',
|
||||
'isspace',
|
||||
'isupper',
|
||||
'isxdigit',
|
||||
'labs',
|
||||
'launder',
|
||||
'ldexp',
|
||||
'log',
|
||||
'log10',
|
||||
'make_pair',
|
||||
'make_shared',
|
||||
'make_shared_for_overwrite',
|
||||
'make_tuple',
|
||||
'make_unique',
|
||||
'malloc',
|
||||
'memchr',
|
||||
'memcmp',
|
||||
'memcpy',
|
||||
'memset',
|
||||
'modf',
|
||||
'move',
|
||||
'pow',
|
||||
'printf',
|
||||
'putchar',
|
||||
'puts',
|
||||
'realloc',
|
||||
'scanf',
|
||||
'sin',
|
||||
'sinh',
|
||||
'snprintf',
|
||||
'sprintf',
|
||||
'sqrt',
|
||||
'sscanf',
|
||||
'std',
|
||||
'stderr',
|
||||
'stdin',
|
||||
'stdout',
|
||||
'strcat',
|
||||
'strchr',
|
||||
'strcmp',
|
||||
'strcpy',
|
||||
'strcspn',
|
||||
'strlen',
|
||||
'strncat',
|
||||
'strncmp',
|
||||
'strncpy',
|
||||
'strpbrk',
|
||||
'strrchr',
|
||||
'strspn',
|
||||
'strstr',
|
||||
'swap',
|
||||
'tan',
|
||||
'tanh',
|
||||
'terminate',
|
||||
'to_underlying',
|
||||
'tolower',
|
||||
'toupper',
|
||||
'vfprintf',
|
||||
'visit',
|
||||
'vprintf',
|
||||
'vsprintf'
|
||||
];
|
||||
|
||||
const LITERALS = [
|
||||
'NULL',
|
||||
'false',
|
||||
'nullopt',
|
||||
'nullptr',
|
||||
'true'
|
||||
];
|
||||
|
||||
// https://en.cppreference.com/w/cpp/keyword
|
||||
const BUILT_IN = [ '_Pragma' ];
|
||||
|
||||
const CPP_KEYWORDS = {
|
||||
type: RESERVED_TYPES,
|
||||
keyword: RESERVED_KEYWORDS,
|
||||
literal: LITERALS,
|
||||
built_in: BUILT_IN,
|
||||
_type_hints: TYPE_HINTS
|
||||
};
|
||||
|
||||
const FUNCTION_DISPATCH = {
|
||||
className: 'function.dispatch',
|
||||
relevance: 0,
|
||||
keywords: {
|
||||
// Only for relevance, not highlighting.
|
||||
_hint: FUNCTION_HINTS },
|
||||
begin: regex.concat(
|
||||
/\b/,
|
||||
/(?!decltype)/,
|
||||
/(?!if)/,
|
||||
/(?!for)/,
|
||||
/(?!switch)/,
|
||||
/(?!while)/,
|
||||
hljs.IDENT_RE,
|
||||
regex.lookahead(/(<[^<>]+>|)\s*\(/))
|
||||
};
|
||||
|
||||
const EXPRESSION_CONTAINS = [
|
||||
FUNCTION_DISPATCH,
|
||||
PREPROCESSOR,
|
||||
CPP_PRIMITIVE_TYPES,
|
||||
C_LINE_COMMENT_MODE,
|
||||
hljs.C_BLOCK_COMMENT_MODE,
|
||||
NUMBERS,
|
||||
STRINGS
|
||||
];
|
||||
|
||||
const EXPRESSION_CONTEXT = {
|
||||
// This mode covers expression context where we can't expect a function
|
||||
// definition and shouldn't highlight anything that looks like one:
|
||||
// `return some()`, `else if()`, `(x*sum(1, 2))`
|
||||
variants: [
|
||||
{
|
||||
begin: /=/,
|
||||
end: /;/
|
||||
},
|
||||
{
|
||||
begin: /\(/,
|
||||
end: /\)/
|
||||
},
|
||||
{
|
||||
beginKeywords: 'new throw return else',
|
||||
end: /;/
|
||||
}
|
||||
],
|
||||
keywords: CPP_KEYWORDS,
|
||||
contains: EXPRESSION_CONTAINS.concat([
|
||||
{
|
||||
begin: /\(/,
|
||||
end: /\)/,
|
||||
keywords: CPP_KEYWORDS,
|
||||
contains: EXPRESSION_CONTAINS.concat([ 'self' ]),
|
||||
relevance: 0
|
||||
}
|
||||
]),
|
||||
relevance: 0
|
||||
};
|
||||
|
||||
const FUNCTION_DECLARATION = {
|
||||
className: 'function',
|
||||
begin: '(' + FUNCTION_TYPE_RE + '[\\*&\\s]+)+' + FUNCTION_TITLE,
|
||||
returnBegin: true,
|
||||
end: /[{;=]/,
|
||||
excludeEnd: true,
|
||||
keywords: CPP_KEYWORDS,
|
||||
illegal: /[^\w\s\*&:<>.]/,
|
||||
contains: [
|
||||
{ // to prevent it from being confused as the function title
|
||||
begin: DECLTYPE_AUTO_RE,
|
||||
keywords: CPP_KEYWORDS,
|
||||
relevance: 0
|
||||
},
|
||||
{
|
||||
begin: FUNCTION_TITLE,
|
||||
returnBegin: true,
|
||||
contains: [ TITLE_MODE ],
|
||||
relevance: 0
|
||||
},
|
||||
// needed because we do not have look-behind on the below rule
|
||||
// to prevent it from grabbing the final : in a :: pair
|
||||
{
|
||||
begin: /::/,
|
||||
relevance: 0
|
||||
},
|
||||
// initializers
|
||||
{
|
||||
begin: /:/,
|
||||
endsWithParent: true,
|
||||
contains: [
|
||||
STRINGS,
|
||||
NUMBERS
|
||||
]
|
||||
},
|
||||
// allow for multiple declarations, e.g.:
|
||||
// extern void f(int), g(char);
|
||||
{
|
||||
relevance: 0,
|
||||
match: /,/
|
||||
},
|
||||
{
|
||||
className: 'params',
|
||||
begin: /\(/,
|
||||
end: /\)/,
|
||||
keywords: CPP_KEYWORDS,
|
||||
relevance: 0,
|
||||
contains: [
|
||||
C_LINE_COMMENT_MODE,
|
||||
hljs.C_BLOCK_COMMENT_MODE,
|
||||
STRINGS,
|
||||
NUMBERS,
|
||||
CPP_PRIMITIVE_TYPES,
|
||||
// Count matching parentheses.
|
||||
{
|
||||
begin: /\(/,
|
||||
end: /\)/,
|
||||
keywords: CPP_KEYWORDS,
|
||||
relevance: 0,
|
||||
contains: [
|
||||
'self',
|
||||
C_LINE_COMMENT_MODE,
|
||||
hljs.C_BLOCK_COMMENT_MODE,
|
||||
STRINGS,
|
||||
NUMBERS,
|
||||
CPP_PRIMITIVE_TYPES
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
CPP_PRIMITIVE_TYPES,
|
||||
C_LINE_COMMENT_MODE,
|
||||
hljs.C_BLOCK_COMMENT_MODE,
|
||||
PREPROCESSOR
|
||||
]
|
||||
};
|
||||
|
||||
return {
|
||||
name: 'C++',
|
||||
aliases: [
|
||||
'cc',
|
||||
'c++',
|
||||
'h++',
|
||||
'hpp',
|
||||
'hh',
|
||||
'hxx',
|
||||
'cxx'
|
||||
],
|
||||
keywords: CPP_KEYWORDS,
|
||||
illegal: '</',
|
||||
classNameAliases: { 'function.dispatch': 'built_in' },
|
||||
contains: [].concat(
|
||||
EXPRESSION_CONTEXT,
|
||||
FUNCTION_DECLARATION,
|
||||
FUNCTION_DISPATCH,
|
||||
EXPRESSION_CONTAINS,
|
||||
[
|
||||
PREPROCESSOR,
|
||||
{ // containers: ie, `vector <int> rooms (9);`
|
||||
begin: '\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)',
|
||||
end: '>',
|
||||
keywords: CPP_KEYWORDS,
|
||||
contains: [
|
||||
'self',
|
||||
CPP_PRIMITIVE_TYPES
|
||||
]
|
||||
},
|
||||
{
|
||||
begin: hljs.IDENT_RE + '::',
|
||||
keywords: CPP_KEYWORDS
|
||||
},
|
||||
{
|
||||
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'
|
||||
}
|
||||
}
|
||||
])
|
||||
};
|
||||
}
|
||||
|
||||
export { cpp as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/cpp" instead of "highlight.js/lib/languages/cpp.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './cpp.js';
|
||||
export default lang;
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
Language: crmsh
|
||||
Author: Kristoffer Gronlund <kgronlund@suse.com>
|
||||
Website: http://crmsh.github.io
|
||||
Description: Syntax Highlighting for the crmsh DSL
|
||||
Category: config
|
||||
*/
|
||||
|
||||
/** @type LanguageFn */
|
||||
function crmsh(hljs) {
|
||||
const RESOURCES = 'primitive rsc_template';
|
||||
const COMMANDS = 'group clone ms master location colocation order fencing_topology '
|
||||
+ 'rsc_ticket acl_target acl_group user role '
|
||||
+ 'tag xml';
|
||||
const PROPERTY_SETS = 'property rsc_defaults op_defaults';
|
||||
const KEYWORDS = 'params meta operations op rule attributes utilization';
|
||||
const OPERATORS = 'read write deny defined not_defined in_range date spec in '
|
||||
+ 'ref reference attribute type xpath version and or lt gt tag '
|
||||
+ 'lte gte eq ne \\';
|
||||
const TYPES = 'number string';
|
||||
const LITERALS = 'Master Started Slave Stopped start promote demote stop monitor true false';
|
||||
|
||||
return {
|
||||
name: 'crmsh',
|
||||
aliases: [
|
||||
'crm',
|
||||
'pcmk'
|
||||
],
|
||||
case_insensitive: true,
|
||||
keywords: {
|
||||
keyword: KEYWORDS + ' ' + OPERATORS + ' ' + TYPES,
|
||||
literal: LITERALS
|
||||
},
|
||||
contains: [
|
||||
hljs.HASH_COMMENT_MODE,
|
||||
{
|
||||
beginKeywords: 'node',
|
||||
starts: {
|
||||
end: '\\s*([\\w_-]+:)?',
|
||||
starts: {
|
||||
className: 'title',
|
||||
end: '\\s*[\\$\\w_][\\w_-]*'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
beginKeywords: RESOURCES,
|
||||
starts: {
|
||||
className: 'title',
|
||||
end: '\\s*[\\$\\w_][\\w_-]*',
|
||||
starts: { end: '\\s*@?[\\w_][\\w_\\.:-]*' }
|
||||
}
|
||||
},
|
||||
{
|
||||
begin: '\\b(' + COMMANDS.split(' ').join('|') + ')\\s+',
|
||||
keywords: COMMANDS,
|
||||
starts: {
|
||||
className: 'title',
|
||||
end: '[\\$\\w_][\\w_-]*'
|
||||
}
|
||||
},
|
||||
{
|
||||
beginKeywords: PROPERTY_SETS,
|
||||
starts: {
|
||||
className: 'title',
|
||||
end: '\\s*([\\w_-]+:)?'
|
||||
}
|
||||
},
|
||||
hljs.QUOTE_STRING_MODE,
|
||||
{
|
||||
className: 'meta',
|
||||
begin: '(ocf|systemd|service|lsb):[\\w_:-]+',
|
||||
relevance: 0
|
||||
},
|
||||
{
|
||||
className: 'number',
|
||||
begin: '\\b\\d+(\\.\\d+)?(ms|s|h|m)?',
|
||||
relevance: 0
|
||||
},
|
||||
{
|
||||
className: 'literal',
|
||||
begin: '[-]?(infinity|inf)',
|
||||
relevance: 0
|
||||
},
|
||||
{
|
||||
className: 'attr',
|
||||
begin: /([A-Za-z$_#][\w_-]+)=/,
|
||||
relevance: 0
|
||||
},
|
||||
{
|
||||
className: 'tag',
|
||||
begin: '</?',
|
||||
end: '/?>',
|
||||
relevance: 0
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
export { crmsh as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/crmsh" instead of "highlight.js/lib/languages/crmsh.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './crmsh.js';
|
||||
export default lang;
|
||||
+312
@@ -0,0 +1,312 @@
|
||||
/*
|
||||
Language: Crystal
|
||||
Author: TSUYUSATO Kitsune <make.just.on@gmail.com>
|
||||
Website: https://crystal-lang.org
|
||||
Category: system
|
||||
*/
|
||||
|
||||
/** @type LanguageFn */
|
||||
function crystal(hljs) {
|
||||
const INT_SUFFIX = '(_?[ui](8|16|32|64|128))?';
|
||||
const FLOAT_SUFFIX = '(_?f(32|64))?';
|
||||
const CRYSTAL_IDENT_RE = '[a-zA-Z_]\\w*[!?=]?';
|
||||
const CRYSTAL_METHOD_RE = '[a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|[=!]~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~|]|//|//=|&[-+*]=?|&\\*\\*|\\[\\][=?]?';
|
||||
const CRYSTAL_PATH_RE = '[A-Za-z_]\\w*(::\\w+)*(\\?|!)?';
|
||||
const CRYSTAL_KEYWORDS = {
|
||||
$pattern: CRYSTAL_IDENT_RE,
|
||||
keyword:
|
||||
'abstract alias annotation as as? asm begin break case class def do else elsif end ensure enum extend for fun if '
|
||||
+ 'include instance_sizeof is_a? lib macro module next nil? of out pointerof private protected rescue responds_to? '
|
||||
+ 'return require select self sizeof struct super then type typeof union uninitialized unless until verbatim when while with yield '
|
||||
+ '__DIR__ __END_LINE__ __FILE__ __LINE__',
|
||||
literal: 'false nil true'
|
||||
};
|
||||
const SUBST = {
|
||||
className: 'subst',
|
||||
begin: /#\{/,
|
||||
end: /\}/,
|
||||
keywords: CRYSTAL_KEYWORDS
|
||||
};
|
||||
// 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 = {
|
||||
className: 'template-variable',
|
||||
variants: [
|
||||
{
|
||||
begin: '\\{\\{',
|
||||
end: '\\}\\}'
|
||||
},
|
||||
{
|
||||
begin: '\\{%',
|
||||
end: '%\\}'
|
||||
}
|
||||
],
|
||||
keywords: CRYSTAL_KEYWORDS
|
||||
};
|
||||
|
||||
function recursiveParen(begin, end) {
|
||||
const
|
||||
contains = [
|
||||
{
|
||||
begin: begin,
|
||||
end: end
|
||||
}
|
||||
];
|
||||
contains[0].contains = contains;
|
||||
return contains;
|
||||
}
|
||||
const STRING = {
|
||||
className: 'string',
|
||||
contains: [
|
||||
hljs.BACKSLASH_ESCAPE,
|
||||
SUBST
|
||||
],
|
||||
variants: [
|
||||
{
|
||||
begin: /'/,
|
||||
end: /'/
|
||||
},
|
||||
{
|
||||
begin: /"/,
|
||||
end: /"/
|
||||
},
|
||||
{
|
||||
begin: /`/,
|
||||
end: /`/
|
||||
},
|
||||
{
|
||||
begin: '%[Qwi]?\\(',
|
||||
end: '\\)',
|
||||
contains: recursiveParen('\\(', '\\)')
|
||||
},
|
||||
{
|
||||
begin: '%[Qwi]?\\[',
|
||||
end: '\\]',
|
||||
contains: recursiveParen('\\[', '\\]')
|
||||
},
|
||||
{
|
||||
begin: '%[Qwi]?\\{',
|
||||
end: /\}/,
|
||||
contains: recursiveParen(/\{/, /\}/)
|
||||
},
|
||||
{
|
||||
begin: '%[Qwi]?<',
|
||||
end: '>',
|
||||
contains: recursiveParen('<', '>')
|
||||
},
|
||||
{
|
||||
begin: '%[Qwi]?\\|',
|
||||
end: '\\|'
|
||||
},
|
||||
{
|
||||
begin: /<<-\w+$/,
|
||||
end: /^\s*\w+$/
|
||||
}
|
||||
],
|
||||
relevance: 0
|
||||
};
|
||||
const Q_STRING = {
|
||||
className: 'string',
|
||||
variants: [
|
||||
{
|
||||
begin: '%q\\(',
|
||||
end: '\\)',
|
||||
contains: recursiveParen('\\(', '\\)')
|
||||
},
|
||||
{
|
||||
begin: '%q\\[',
|
||||
end: '\\]',
|
||||
contains: recursiveParen('\\[', '\\]')
|
||||
},
|
||||
{
|
||||
begin: '%q\\{',
|
||||
end: /\}/,
|
||||
contains: recursiveParen(/\{/, /\}/)
|
||||
},
|
||||
{
|
||||
begin: '%q<',
|
||||
end: '>',
|
||||
contains: recursiveParen('<', '>')
|
||||
},
|
||||
{
|
||||
begin: '%q\\|',
|
||||
end: '\\|'
|
||||
},
|
||||
{
|
||||
begin: /<<-'\w+'$/,
|
||||
end: /^\s*\w+$/
|
||||
}
|
||||
],
|
||||
relevance: 0
|
||||
};
|
||||
const REGEXP = {
|
||||
begin: '(?!%\\})(' + hljs.RE_STARTERS_RE + '|\\n|\\b(case|if|select|unless|until|when|while)\\b)\\s*',
|
||||
keywords: 'case if select unless until when while',
|
||||
contains: [
|
||||
{
|
||||
className: 'regexp',
|
||||
contains: [
|
||||
hljs.BACKSLASH_ESCAPE,
|
||||
SUBST
|
||||
],
|
||||
variants: [
|
||||
{
|
||||
begin: '//[a-z]*',
|
||||
relevance: 0
|
||||
},
|
||||
{
|
||||
begin: '/(?!\\/)',
|
||||
end: '/[a-z]*'
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
relevance: 0
|
||||
};
|
||||
const REGEXP2 = {
|
||||
className: 'regexp',
|
||||
contains: [
|
||||
hljs.BACKSLASH_ESCAPE,
|
||||
SUBST
|
||||
],
|
||||
variants: [
|
||||
{
|
||||
begin: '%r\\(',
|
||||
end: '\\)',
|
||||
contains: recursiveParen('\\(', '\\)')
|
||||
},
|
||||
{
|
||||
begin: '%r\\[',
|
||||
end: '\\]',
|
||||
contains: recursiveParen('\\[', '\\]')
|
||||
},
|
||||
{
|
||||
begin: '%r\\{',
|
||||
end: /\}/,
|
||||
contains: recursiveParen(/\{/, /\}/)
|
||||
},
|
||||
{
|
||||
begin: '%r<',
|
||||
end: '>',
|
||||
contains: recursiveParen('<', '>')
|
||||
},
|
||||
{
|
||||
begin: '%r\\|',
|
||||
end: '\\|'
|
||||
}
|
||||
],
|
||||
relevance: 0
|
||||
};
|
||||
const ATTRIBUTE = {
|
||||
className: 'meta',
|
||||
begin: '@\\[',
|
||||
end: '\\]',
|
||||
contains: [ hljs.inherit(hljs.QUOTE_STRING_MODE, { className: 'string' }) ]
|
||||
};
|
||||
const CRYSTAL_DEFAULT_CONTAINS = [
|
||||
EXPANSION,
|
||||
STRING,
|
||||
Q_STRING,
|
||||
REGEXP2,
|
||||
REGEXP,
|
||||
ATTRIBUTE,
|
||||
VARIABLE,
|
||||
hljs.HASH_COMMENT_MODE,
|
||||
{
|
||||
className: 'class',
|
||||
beginKeywords: 'class module struct',
|
||||
end: '$|;',
|
||||
illegal: /=/,
|
||||
contains: [
|
||||
hljs.HASH_COMMENT_MODE,
|
||||
hljs.inherit(hljs.TITLE_MODE, { begin: CRYSTAL_PATH_RE }),
|
||||
{ // relevance booster for inheritance
|
||||
begin: '<' }
|
||||
]
|
||||
},
|
||||
{
|
||||
className: 'class',
|
||||
beginKeywords: 'lib enum union',
|
||||
end: '$|;',
|
||||
illegal: /=/,
|
||||
contains: [
|
||||
hljs.HASH_COMMENT_MODE,
|
||||
hljs.inherit(hljs.TITLE_MODE, { begin: CRYSTAL_PATH_RE })
|
||||
]
|
||||
},
|
||||
{
|
||||
beginKeywords: 'annotation',
|
||||
end: '$|;',
|
||||
illegal: /=/,
|
||||
contains: [
|
||||
hljs.HASH_COMMENT_MODE,
|
||||
hljs.inherit(hljs.TITLE_MODE, { begin: CRYSTAL_PATH_RE })
|
||||
],
|
||||
relevance: 2
|
||||
},
|
||||
{
|
||||
className: 'function',
|
||||
beginKeywords: 'def',
|
||||
end: /\B\b/,
|
||||
contains: [
|
||||
hljs.inherit(hljs.TITLE_MODE, {
|
||||
begin: CRYSTAL_METHOD_RE,
|
||||
endsParent: true
|
||||
})
|
||||
]
|
||||
},
|
||||
{
|
||||
className: 'function',
|
||||
beginKeywords: 'fun macro',
|
||||
end: /\B\b/,
|
||||
contains: [
|
||||
hljs.inherit(hljs.TITLE_MODE, {
|
||||
begin: CRYSTAL_METHOD_RE,
|
||||
endsParent: true
|
||||
})
|
||||
],
|
||||
relevance: 2
|
||||
},
|
||||
{
|
||||
className: 'symbol',
|
||||
begin: hljs.UNDERSCORE_IDENT_RE + '(!|\\?)?:',
|
||||
relevance: 0
|
||||
},
|
||||
{
|
||||
className: 'symbol',
|
||||
begin: ':',
|
||||
contains: [
|
||||
STRING,
|
||||
{ begin: CRYSTAL_METHOD_RE }
|
||||
],
|
||||
relevance: 0
|
||||
},
|
||||
{
|
||||
className: 'number',
|
||||
variants: [
|
||||
{ begin: '\\b0b([01_]+)' + INT_SUFFIX },
|
||||
{ begin: '\\b0o([0-7_]+)' + INT_SUFFIX },
|
||||
{ begin: '\\b0x([A-Fa-f0-9_]+)' + INT_SUFFIX },
|
||||
{ begin: '\\b([1-9][0-9_]*[0-9]|[0-9])(\\.[0-9][0-9_]*)?([eE]_?[-+]?[0-9_]*)?' + FLOAT_SUFFIX + '(?!_)' },
|
||||
{ begin: '\\b([1-9][0-9_]*|0)' + INT_SUFFIX }
|
||||
],
|
||||
relevance: 0
|
||||
}
|
||||
];
|
||||
SUBST.contains = CRYSTAL_DEFAULT_CONTAINS;
|
||||
EXPANSION.contains = CRYSTAL_DEFAULT_CONTAINS.slice(1); // without EXPANSION
|
||||
|
||||
return {
|
||||
name: 'Crystal',
|
||||
aliases: [ 'cr' ],
|
||||
keywords: CRYSTAL_KEYWORDS,
|
||||
contains: CRYSTAL_DEFAULT_CONTAINS
|
||||
};
|
||||
}
|
||||
|
||||
export { crystal as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/crystal" instead of "highlight.js/lib/languages/crystal.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './crystal.js';
|
||||
export default lang;
|
||||
+412
@@ -0,0 +1,412 @@
|
||||
/*
|
||||
Language: C#
|
||||
Author: Jason Diamond <jason@diamond.name>
|
||||
Contributor: Nicolas LLOBERA <nllobera@gmail.com>, Pieter Vantorre <pietervantorre@gmail.com>, David Pine <david.pine@microsoft.com>
|
||||
Website: https://docs.microsoft.com/dotnet/csharp/
|
||||
Category: common
|
||||
*/
|
||||
|
||||
/** @type LanguageFn */
|
||||
function csharp(hljs) {
|
||||
const BUILT_IN_KEYWORDS = [
|
||||
'bool',
|
||||
'byte',
|
||||
'char',
|
||||
'decimal',
|
||||
'delegate',
|
||||
'double',
|
||||
'dynamic',
|
||||
'enum',
|
||||
'float',
|
||||
'int',
|
||||
'long',
|
||||
'nint',
|
||||
'nuint',
|
||||
'object',
|
||||
'sbyte',
|
||||
'short',
|
||||
'string',
|
||||
'ulong',
|
||||
'uint',
|
||||
'ushort'
|
||||
];
|
||||
const FUNCTION_MODIFIERS = [
|
||||
'public',
|
||||
'private',
|
||||
'protected',
|
||||
'static',
|
||||
'internal',
|
||||
'protected',
|
||||
'abstract',
|
||||
'async',
|
||||
'extern',
|
||||
'override',
|
||||
'unsafe',
|
||||
'virtual',
|
||||
'new',
|
||||
'sealed',
|
||||
'partial'
|
||||
];
|
||||
const LITERAL_KEYWORDS = [
|
||||
'default',
|
||||
'false',
|
||||
'null',
|
||||
'true'
|
||||
];
|
||||
const NORMAL_KEYWORDS = [
|
||||
'abstract',
|
||||
'as',
|
||||
'base',
|
||||
'break',
|
||||
'case',
|
||||
'catch',
|
||||
'class',
|
||||
'const',
|
||||
'continue',
|
||||
'do',
|
||||
'else',
|
||||
'event',
|
||||
'explicit',
|
||||
'extern',
|
||||
'finally',
|
||||
'fixed',
|
||||
'for',
|
||||
'foreach',
|
||||
'goto',
|
||||
'if',
|
||||
'implicit',
|
||||
'in',
|
||||
'interface',
|
||||
'internal',
|
||||
'is',
|
||||
'lock',
|
||||
'namespace',
|
||||
'new',
|
||||
'operator',
|
||||
'out',
|
||||
'override',
|
||||
'params',
|
||||
'private',
|
||||
'protected',
|
||||
'public',
|
||||
'readonly',
|
||||
'record',
|
||||
'ref',
|
||||
'return',
|
||||
'scoped',
|
||||
'sealed',
|
||||
'sizeof',
|
||||
'stackalloc',
|
||||
'static',
|
||||
'struct',
|
||||
'switch',
|
||||
'this',
|
||||
'throw',
|
||||
'try',
|
||||
'typeof',
|
||||
'unchecked',
|
||||
'unsafe',
|
||||
'using',
|
||||
'virtual',
|
||||
'void',
|
||||
'volatile',
|
||||
'while'
|
||||
];
|
||||
const CONTEXTUAL_KEYWORDS = [
|
||||
'add',
|
||||
'alias',
|
||||
'and',
|
||||
'ascending',
|
||||
'args',
|
||||
'async',
|
||||
'await',
|
||||
'by',
|
||||
'descending',
|
||||
'dynamic',
|
||||
'equals',
|
||||
'file',
|
||||
'from',
|
||||
'get',
|
||||
'global',
|
||||
'group',
|
||||
'init',
|
||||
'into',
|
||||
'join',
|
||||
'let',
|
||||
'nameof',
|
||||
'not',
|
||||
'notnull',
|
||||
'on',
|
||||
'or',
|
||||
'orderby',
|
||||
'partial',
|
||||
'record',
|
||||
'remove',
|
||||
'required',
|
||||
'scoped',
|
||||
'select',
|
||||
'set',
|
||||
'unmanaged',
|
||||
'value|0',
|
||||
'var',
|
||||
'when',
|
||||
'where',
|
||||
'with',
|
||||
'yield'
|
||||
];
|
||||
|
||||
const KEYWORDS = {
|
||||
keyword: NORMAL_KEYWORDS.concat(CONTEXTUAL_KEYWORDS),
|
||||
built_in: BUILT_IN_KEYWORDS,
|
||||
literal: LITERAL_KEYWORDS
|
||||
};
|
||||
const TITLE_MODE = hljs.inherit(hljs.TITLE_MODE, { begin: '[a-zA-Z](\\.?\\w)*' });
|
||||
const NUMBERS = {
|
||||
className: 'number',
|
||||
variants: [
|
||||
{ begin: '\\b(0b[01\']+)' },
|
||||
{ begin: '(-?)\\b([\\d\']+(\\.[\\d\']*)?|\\.[\\d\']+)(u|U|l|L|ul|UL|f|F|b|B)' },
|
||||
{ begin: '(-?)(\\b0[xX][a-fA-F0-9\']+|(\\b[\\d\']+(\\.[\\d\']*)?|\\.[\\d\']+)([eE][-+]?[\\d\']+)?)' }
|
||||
],
|
||||
relevance: 0
|
||||
};
|
||||
const RAW_STRING = {
|
||||
className: 'string',
|
||||
begin: /"""("*)(?!")(.|\n)*?"""\1/,
|
||||
relevance: 1
|
||||
};
|
||||
const VERBATIM_STRING = {
|
||||
className: 'string',
|
||||
begin: '@"',
|
||||
end: '"',
|
||||
contains: [ { begin: '""' } ]
|
||||
};
|
||||
const VERBATIM_STRING_NO_LF = hljs.inherit(VERBATIM_STRING, { illegal: /\n/ });
|
||||
const SUBST = {
|
||||
className: 'subst',
|
||||
begin: /\{/,
|
||||
end: /\}/,
|
||||
keywords: KEYWORDS
|
||||
};
|
||||
const SUBST_NO_LF = hljs.inherit(SUBST, { illegal: /\n/ });
|
||||
const INTERPOLATED_STRING = {
|
||||
className: 'string',
|
||||
begin: /\$"/,
|
||||
end: '"',
|
||||
illegal: /\n/,
|
||||
contains: [
|
||||
{ begin: /\{\{/ },
|
||||
{ begin: /\}\}/ },
|
||||
hljs.BACKSLASH_ESCAPE,
|
||||
SUBST_NO_LF
|
||||
]
|
||||
};
|
||||
const INTERPOLATED_VERBATIM_STRING = {
|
||||
className: 'string',
|
||||
begin: /\$@"/,
|
||||
end: '"',
|
||||
contains: [
|
||||
{ begin: /\{\{/ },
|
||||
{ begin: /\}\}/ },
|
||||
{ begin: '""' },
|
||||
SUBST
|
||||
]
|
||||
};
|
||||
const INTERPOLATED_VERBATIM_STRING_NO_LF = hljs.inherit(INTERPOLATED_VERBATIM_STRING, {
|
||||
illegal: /\n/,
|
||||
contains: [
|
||||
{ begin: /\{\{/ },
|
||||
{ begin: /\}\}/ },
|
||||
{ begin: '""' },
|
||||
SUBST_NO_LF
|
||||
]
|
||||
});
|
||||
SUBST.contains = [
|
||||
INTERPOLATED_VERBATIM_STRING,
|
||||
INTERPOLATED_STRING,
|
||||
VERBATIM_STRING,
|
||||
hljs.APOS_STRING_MODE,
|
||||
hljs.QUOTE_STRING_MODE,
|
||||
NUMBERS,
|
||||
hljs.C_BLOCK_COMMENT_MODE
|
||||
];
|
||||
SUBST_NO_LF.contains = [
|
||||
INTERPOLATED_VERBATIM_STRING_NO_LF,
|
||||
INTERPOLATED_STRING,
|
||||
VERBATIM_STRING_NO_LF,
|
||||
hljs.APOS_STRING_MODE,
|
||||
hljs.QUOTE_STRING_MODE,
|
||||
NUMBERS,
|
||||
hljs.inherit(hljs.C_BLOCK_COMMENT_MODE, { illegal: /\n/ })
|
||||
];
|
||||
const STRING = { variants: [
|
||||
RAW_STRING,
|
||||
INTERPOLATED_VERBATIM_STRING,
|
||||
INTERPOLATED_STRING,
|
||||
VERBATIM_STRING,
|
||||
hljs.APOS_STRING_MODE,
|
||||
hljs.QUOTE_STRING_MODE
|
||||
] };
|
||||
|
||||
const GENERIC_MODIFIER = {
|
||||
begin: "<",
|
||||
end: ">",
|
||||
contains: [
|
||||
{ beginKeywords: "in out" },
|
||||
TITLE_MODE
|
||||
]
|
||||
};
|
||||
const TYPE_IDENT_RE = hljs.IDENT_RE + '(<' + hljs.IDENT_RE + '(\\s*,\\s*' + hljs.IDENT_RE + ')*>)?(\\[\\])?';
|
||||
const AT_IDENTIFIER = {
|
||||
// prevents expressions like `@class` from incorrect flagging
|
||||
// `class` as a keyword
|
||||
begin: "@" + hljs.IDENT_RE,
|
||||
relevance: 0
|
||||
};
|
||||
|
||||
return {
|
||||
name: 'C#',
|
||||
aliases: [
|
||||
'cs',
|
||||
'c#'
|
||||
],
|
||||
keywords: KEYWORDS,
|
||||
illegal: /::/,
|
||||
contains: [
|
||||
hljs.COMMENT(
|
||||
'///',
|
||||
'$',
|
||||
{
|
||||
returnBegin: true,
|
||||
contains: [
|
||||
{
|
||||
className: 'doctag',
|
||||
variants: [
|
||||
{
|
||||
begin: '///',
|
||||
relevance: 0
|
||||
},
|
||||
{ begin: '<!--|-->' },
|
||||
{
|
||||
begin: '</?',
|
||||
end: '>'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
),
|
||||
hljs.C_LINE_COMMENT_MODE,
|
||||
hljs.C_BLOCK_COMMENT_MODE,
|
||||
{
|
||||
className: 'meta',
|
||||
begin: '#',
|
||||
end: '$',
|
||||
keywords: { keyword: 'if else elif endif define undef warning error line region endregion pragma checksum' }
|
||||
},
|
||||
STRING,
|
||||
NUMBERS,
|
||||
{
|
||||
beginKeywords: 'class interface',
|
||||
relevance: 0,
|
||||
end: /[{;=]/,
|
||||
illegal: /[^\s:,]/,
|
||||
contains: [
|
||||
{ beginKeywords: "where class" },
|
||||
TITLE_MODE,
|
||||
GENERIC_MODIFIER,
|
||||
hljs.C_LINE_COMMENT_MODE,
|
||||
hljs.C_BLOCK_COMMENT_MODE
|
||||
]
|
||||
},
|
||||
{
|
||||
beginKeywords: 'namespace',
|
||||
relevance: 0,
|
||||
end: /[{;=]/,
|
||||
illegal: /[^\s:]/,
|
||||
contains: [
|
||||
TITLE_MODE,
|
||||
hljs.C_LINE_COMMENT_MODE,
|
||||
hljs.C_BLOCK_COMMENT_MODE
|
||||
]
|
||||
},
|
||||
{
|
||||
beginKeywords: 'record',
|
||||
relevance: 0,
|
||||
end: /[{;=]/,
|
||||
illegal: /[^\s:]/,
|
||||
contains: [
|
||||
TITLE_MODE,
|
||||
GENERIC_MODIFIER,
|
||||
hljs.C_LINE_COMMENT_MODE,
|
||||
hljs.C_BLOCK_COMMENT_MODE
|
||||
]
|
||||
},
|
||||
{
|
||||
// [Attributes("")]
|
||||
className: 'meta',
|
||||
begin: '^\\s*\\[(?=[\\w])',
|
||||
excludeBegin: true,
|
||||
end: '\\]',
|
||||
excludeEnd: true,
|
||||
contains: [
|
||||
{
|
||||
className: 'string',
|
||||
begin: /"/,
|
||||
end: /"/
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
// Expression keywords prevent 'keyword Name(...)' from being
|
||||
// recognized as a function definition
|
||||
beginKeywords: 'new return throw await else',
|
||||
relevance: 0
|
||||
},
|
||||
{
|
||||
className: 'function',
|
||||
begin: '(' + TYPE_IDENT_RE + '\\s+)+' + hljs.IDENT_RE + '\\s*(<[^=]+>\\s*)?\\(',
|
||||
returnBegin: true,
|
||||
end: /\s*[{;=]/,
|
||||
excludeEnd: true,
|
||||
keywords: KEYWORDS,
|
||||
contains: [
|
||||
// prevents these from being highlighted `title`
|
||||
{
|
||||
beginKeywords: FUNCTION_MODIFIERS.join(" "),
|
||||
relevance: 0
|
||||
},
|
||||
{
|
||||
begin: hljs.IDENT_RE + '\\s*(<[^=]+>\\s*)?\\(',
|
||||
returnBegin: true,
|
||||
contains: [
|
||||
hljs.TITLE_MODE,
|
||||
GENERIC_MODIFIER
|
||||
],
|
||||
relevance: 0
|
||||
},
|
||||
{ match: /\(\)/ },
|
||||
{
|
||||
className: 'params',
|
||||
begin: /\(/,
|
||||
end: /\)/,
|
||||
excludeBegin: true,
|
||||
excludeEnd: true,
|
||||
keywords: KEYWORDS,
|
||||
relevance: 0,
|
||||
contains: [
|
||||
STRING,
|
||||
NUMBERS,
|
||||
hljs.C_BLOCK_COMMENT_MODE
|
||||
]
|
||||
},
|
||||
hljs.C_LINE_COMMENT_MODE,
|
||||
hljs.C_BLOCK_COMMENT_MODE
|
||||
]
|
||||
},
|
||||
AT_IDENTIFIER
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
export { csharp as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/csharp" instead of "highlight.js/lib/languages/csharp.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './csharp.js';
|
||||
export default lang;
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
Language: CSP
|
||||
Description: Content Security Policy definition highlighting
|
||||
Author: Taras <oxdef@oxdef.info>
|
||||
Website: https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP
|
||||
Category: web
|
||||
|
||||
vim: ts=2 sw=2 st=2
|
||||
*/
|
||||
|
||||
/** @type LanguageFn */
|
||||
function csp(hljs) {
|
||||
const KEYWORDS = [
|
||||
"base-uri",
|
||||
"child-src",
|
||||
"connect-src",
|
||||
"default-src",
|
||||
"font-src",
|
||||
"form-action",
|
||||
"frame-ancestors",
|
||||
"frame-src",
|
||||
"img-src",
|
||||
"manifest-src",
|
||||
"media-src",
|
||||
"object-src",
|
||||
"plugin-types",
|
||||
"report-uri",
|
||||
"sandbox",
|
||||
"script-src",
|
||||
"style-src",
|
||||
"trusted-types",
|
||||
"unsafe-hashes",
|
||||
"worker-src"
|
||||
];
|
||||
return {
|
||||
name: 'CSP',
|
||||
case_insensitive: false,
|
||||
keywords: {
|
||||
$pattern: '[a-zA-Z][a-zA-Z0-9_-]*',
|
||||
keyword: KEYWORDS
|
||||
},
|
||||
contains: [
|
||||
{
|
||||
className: 'string',
|
||||
begin: "'",
|
||||
end: "'"
|
||||
},
|
||||
{
|
||||
className: 'attribute',
|
||||
begin: '^Content',
|
||||
end: ':',
|
||||
excludeEnd: true
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
export { csp as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/csp" instead of "highlight.js/lib/languages/csp.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './csp.js';
|
||||
export default lang;
|
||||
+949
@@ -0,0 +1,949 @@
|
||||
const MODES = (hljs) => {
|
||||
return {
|
||||
IMPORTANT: {
|
||||
scope: 'meta',
|
||||
begin: '!important'
|
||||
},
|
||||
BLOCK_COMMENT: hljs.C_BLOCK_COMMENT_MODE,
|
||||
HEXCOLOR: {
|
||||
scope: 'number',
|
||||
begin: /#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/
|
||||
},
|
||||
FUNCTION_DISPATCH: {
|
||||
className: "built_in",
|
||||
begin: /[\w-]+(?=\()/
|
||||
},
|
||||
ATTRIBUTE_SELECTOR_MODE: {
|
||||
scope: 'selector-attr',
|
||||
begin: /\[/,
|
||||
end: /\]/,
|
||||
illegal: '$',
|
||||
contains: [
|
||||
hljs.APOS_STRING_MODE,
|
||||
hljs.QUOTE_STRING_MODE
|
||||
]
|
||||
},
|
||||
CSS_NUMBER_MODE: {
|
||||
scope: 'number',
|
||||
begin: hljs.NUMBER_RE + '(' +
|
||||
'%|em|ex|ch|rem' +
|
||||
'|vw|vh|vmin|vmax' +
|
||||
'|cm|mm|in|pt|pc|px' +
|
||||
'|deg|grad|rad|turn' +
|
||||
'|s|ms' +
|
||||
'|Hz|kHz' +
|
||||
'|dpi|dpcm|dppx' +
|
||||
')?',
|
||||
relevance: 0
|
||||
},
|
||||
CSS_VARIABLE: {
|
||||
className: "attr",
|
||||
begin: /--[A-Za-z_][A-Za-z0-9_-]*/
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
const HTML_TAGS = [
|
||||
'a',
|
||||
'abbr',
|
||||
'address',
|
||||
'article',
|
||||
'aside',
|
||||
'audio',
|
||||
'b',
|
||||
'blockquote',
|
||||
'body',
|
||||
'button',
|
||||
'canvas',
|
||||
'caption',
|
||||
'cite',
|
||||
'code',
|
||||
'dd',
|
||||
'del',
|
||||
'details',
|
||||
'dfn',
|
||||
'div',
|
||||
'dl',
|
||||
'dt',
|
||||
'em',
|
||||
'fieldset',
|
||||
'figcaption',
|
||||
'figure',
|
||||
'footer',
|
||||
'form',
|
||||
'h1',
|
||||
'h2',
|
||||
'h3',
|
||||
'h4',
|
||||
'h5',
|
||||
'h6',
|
||||
'header',
|
||||
'hgroup',
|
||||
'html',
|
||||
'i',
|
||||
'iframe',
|
||||
'img',
|
||||
'input',
|
||||
'ins',
|
||||
'kbd',
|
||||
'label',
|
||||
'legend',
|
||||
'li',
|
||||
'main',
|
||||
'mark',
|
||||
'menu',
|
||||
'nav',
|
||||
'object',
|
||||
'ol',
|
||||
'optgroup',
|
||||
'option',
|
||||
'p',
|
||||
'picture',
|
||||
'q',
|
||||
'quote',
|
||||
'samp',
|
||||
'section',
|
||||
'select',
|
||||
'source',
|
||||
'span',
|
||||
'strong',
|
||||
'summary',
|
||||
'sup',
|
||||
'table',
|
||||
'tbody',
|
||||
'td',
|
||||
'textarea',
|
||||
'tfoot',
|
||||
'th',
|
||||
'thead',
|
||||
'time',
|
||||
'tr',
|
||||
'ul',
|
||||
'var',
|
||||
'video'
|
||||
];
|
||||
|
||||
const SVG_TAGS = [
|
||||
'defs',
|
||||
'g',
|
||||
'marker',
|
||||
'mask',
|
||||
'pattern',
|
||||
'svg',
|
||||
'switch',
|
||||
'symbol',
|
||||
'feBlend',
|
||||
'feColorMatrix',
|
||||
'feComponentTransfer',
|
||||
'feComposite',
|
||||
'feConvolveMatrix',
|
||||
'feDiffuseLighting',
|
||||
'feDisplacementMap',
|
||||
'feFlood',
|
||||
'feGaussianBlur',
|
||||
'feImage',
|
||||
'feMerge',
|
||||
'feMorphology',
|
||||
'feOffset',
|
||||
'feSpecularLighting',
|
||||
'feTile',
|
||||
'feTurbulence',
|
||||
'linearGradient',
|
||||
'radialGradient',
|
||||
'stop',
|
||||
'circle',
|
||||
'ellipse',
|
||||
'image',
|
||||
'line',
|
||||
'path',
|
||||
'polygon',
|
||||
'polyline',
|
||||
'rect',
|
||||
'text',
|
||||
'use',
|
||||
'textPath',
|
||||
'tspan',
|
||||
'foreignObject',
|
||||
'clipPath'
|
||||
];
|
||||
|
||||
const TAGS = [
|
||||
...HTML_TAGS,
|
||||
...SVG_TAGS,
|
||||
];
|
||||
|
||||
// Sorting, then reversing makes sure longer attributes/elements like
|
||||
// `font-weight` are matched fully instead of getting false positives on say `font`
|
||||
|
||||
const MEDIA_FEATURES = [
|
||||
'any-hover',
|
||||
'any-pointer',
|
||||
'aspect-ratio',
|
||||
'color',
|
||||
'color-gamut',
|
||||
'color-index',
|
||||
'device-aspect-ratio',
|
||||
'device-height',
|
||||
'device-width',
|
||||
'display-mode',
|
||||
'forced-colors',
|
||||
'grid',
|
||||
'height',
|
||||
'hover',
|
||||
'inverted-colors',
|
||||
'monochrome',
|
||||
'orientation',
|
||||
'overflow-block',
|
||||
'overflow-inline',
|
||||
'pointer',
|
||||
'prefers-color-scheme',
|
||||
'prefers-contrast',
|
||||
'prefers-reduced-motion',
|
||||
'prefers-reduced-transparency',
|
||||
'resolution',
|
||||
'scan',
|
||||
'scripting',
|
||||
'update',
|
||||
'width',
|
||||
// TODO: find a better solution?
|
||||
'min-width',
|
||||
'max-width',
|
||||
'min-height',
|
||||
'max-height'
|
||||
].sort().reverse();
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes
|
||||
const PSEUDO_CLASSES = [
|
||||
'active',
|
||||
'any-link',
|
||||
'blank',
|
||||
'checked',
|
||||
'current',
|
||||
'default',
|
||||
'defined',
|
||||
'dir', // dir()
|
||||
'disabled',
|
||||
'drop',
|
||||
'empty',
|
||||
'enabled',
|
||||
'first',
|
||||
'first-child',
|
||||
'first-of-type',
|
||||
'fullscreen',
|
||||
'future',
|
||||
'focus',
|
||||
'focus-visible',
|
||||
'focus-within',
|
||||
'has', // has()
|
||||
'host', // host or host()
|
||||
'host-context', // host-context()
|
||||
'hover',
|
||||
'indeterminate',
|
||||
'in-range',
|
||||
'invalid',
|
||||
'is', // is()
|
||||
'lang', // lang()
|
||||
'last-child',
|
||||
'last-of-type',
|
||||
'left',
|
||||
'link',
|
||||
'local-link',
|
||||
'not', // not()
|
||||
'nth-child', // nth-child()
|
||||
'nth-col', // nth-col()
|
||||
'nth-last-child', // nth-last-child()
|
||||
'nth-last-col', // nth-last-col()
|
||||
'nth-last-of-type', //nth-last-of-type()
|
||||
'nth-of-type', //nth-of-type()
|
||||
'only-child',
|
||||
'only-of-type',
|
||||
'optional',
|
||||
'out-of-range',
|
||||
'past',
|
||||
'placeholder-shown',
|
||||
'read-only',
|
||||
'read-write',
|
||||
'required',
|
||||
'right',
|
||||
'root',
|
||||
'scope',
|
||||
'target',
|
||||
'target-within',
|
||||
'user-invalid',
|
||||
'valid',
|
||||
'visited',
|
||||
'where' // where()
|
||||
].sort().reverse();
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-elements
|
||||
const PSEUDO_ELEMENTS = [
|
||||
'after',
|
||||
'backdrop',
|
||||
'before',
|
||||
'cue',
|
||||
'cue-region',
|
||||
'first-letter',
|
||||
'first-line',
|
||||
'grammar-error',
|
||||
'marker',
|
||||
'part',
|
||||
'placeholder',
|
||||
'selection',
|
||||
'slotted',
|
||||
'spelling-error'
|
||||
].sort().reverse();
|
||||
|
||||
const ATTRIBUTES = [
|
||||
'accent-color',
|
||||
'align-content',
|
||||
'align-items',
|
||||
'align-self',
|
||||
'alignment-baseline',
|
||||
'all',
|
||||
'anchor-name',
|
||||
'animation',
|
||||
'animation-composition',
|
||||
'animation-delay',
|
||||
'animation-direction',
|
||||
'animation-duration',
|
||||
'animation-fill-mode',
|
||||
'animation-iteration-count',
|
||||
'animation-name',
|
||||
'animation-play-state',
|
||||
'animation-range',
|
||||
'animation-range-end',
|
||||
'animation-range-start',
|
||||
'animation-timeline',
|
||||
'animation-timing-function',
|
||||
'appearance',
|
||||
'aspect-ratio',
|
||||
'backdrop-filter',
|
||||
'backface-visibility',
|
||||
'background',
|
||||
'background-attachment',
|
||||
'background-blend-mode',
|
||||
'background-clip',
|
||||
'background-color',
|
||||
'background-image',
|
||||
'background-origin',
|
||||
'background-position',
|
||||
'background-position-x',
|
||||
'background-position-y',
|
||||
'background-repeat',
|
||||
'background-size',
|
||||
'baseline-shift',
|
||||
'block-size',
|
||||
'border',
|
||||
'border-block',
|
||||
'border-block-color',
|
||||
'border-block-end',
|
||||
'border-block-end-color',
|
||||
'border-block-end-style',
|
||||
'border-block-end-width',
|
||||
'border-block-start',
|
||||
'border-block-start-color',
|
||||
'border-block-start-style',
|
||||
'border-block-start-width',
|
||||
'border-block-style',
|
||||
'border-block-width',
|
||||
'border-bottom',
|
||||
'border-bottom-color',
|
||||
'border-bottom-left-radius',
|
||||
'border-bottom-right-radius',
|
||||
'border-bottom-style',
|
||||
'border-bottom-width',
|
||||
'border-collapse',
|
||||
'border-color',
|
||||
'border-end-end-radius',
|
||||
'border-end-start-radius',
|
||||
'border-image',
|
||||
'border-image-outset',
|
||||
'border-image-repeat',
|
||||
'border-image-slice',
|
||||
'border-image-source',
|
||||
'border-image-width',
|
||||
'border-inline',
|
||||
'border-inline-color',
|
||||
'border-inline-end',
|
||||
'border-inline-end-color',
|
||||
'border-inline-end-style',
|
||||
'border-inline-end-width',
|
||||
'border-inline-start',
|
||||
'border-inline-start-color',
|
||||
'border-inline-start-style',
|
||||
'border-inline-start-width',
|
||||
'border-inline-style',
|
||||
'border-inline-width',
|
||||
'border-left',
|
||||
'border-left-color',
|
||||
'border-left-style',
|
||||
'border-left-width',
|
||||
'border-radius',
|
||||
'border-right',
|
||||
'border-right-color',
|
||||
'border-right-style',
|
||||
'border-right-width',
|
||||
'border-spacing',
|
||||
'border-start-end-radius',
|
||||
'border-start-start-radius',
|
||||
'border-style',
|
||||
'border-top',
|
||||
'border-top-color',
|
||||
'border-top-left-radius',
|
||||
'border-top-right-radius',
|
||||
'border-top-style',
|
||||
'border-top-width',
|
||||
'border-width',
|
||||
'bottom',
|
||||
'box-align',
|
||||
'box-decoration-break',
|
||||
'box-direction',
|
||||
'box-flex',
|
||||
'box-flex-group',
|
||||
'box-lines',
|
||||
'box-ordinal-group',
|
||||
'box-orient',
|
||||
'box-pack',
|
||||
'box-shadow',
|
||||
'box-sizing',
|
||||
'break-after',
|
||||
'break-before',
|
||||
'break-inside',
|
||||
'caption-side',
|
||||
'caret-color',
|
||||
'clear',
|
||||
'clip',
|
||||
'clip-path',
|
||||
'clip-rule',
|
||||
'color',
|
||||
'color-interpolation',
|
||||
'color-interpolation-filters',
|
||||
'color-profile',
|
||||
'color-rendering',
|
||||
'color-scheme',
|
||||
'column-count',
|
||||
'column-fill',
|
||||
'column-gap',
|
||||
'column-rule',
|
||||
'column-rule-color',
|
||||
'column-rule-style',
|
||||
'column-rule-width',
|
||||
'column-span',
|
||||
'column-width',
|
||||
'columns',
|
||||
'contain',
|
||||
'contain-intrinsic-block-size',
|
||||
'contain-intrinsic-height',
|
||||
'contain-intrinsic-inline-size',
|
||||
'contain-intrinsic-size',
|
||||
'contain-intrinsic-width',
|
||||
'container',
|
||||
'container-name',
|
||||
'container-type',
|
||||
'content',
|
||||
'content-visibility',
|
||||
'counter-increment',
|
||||
'counter-reset',
|
||||
'counter-set',
|
||||
'cue',
|
||||
'cue-after',
|
||||
'cue-before',
|
||||
'cursor',
|
||||
'cx',
|
||||
'cy',
|
||||
'direction',
|
||||
'display',
|
||||
'dominant-baseline',
|
||||
'empty-cells',
|
||||
'enable-background',
|
||||
'field-sizing',
|
||||
'fill',
|
||||
'fill-opacity',
|
||||
'fill-rule',
|
||||
'filter',
|
||||
'flex',
|
||||
'flex-basis',
|
||||
'flex-direction',
|
||||
'flex-flow',
|
||||
'flex-grow',
|
||||
'flex-shrink',
|
||||
'flex-wrap',
|
||||
'float',
|
||||
'flood-color',
|
||||
'flood-opacity',
|
||||
'flow',
|
||||
'font',
|
||||
'font-display',
|
||||
'font-family',
|
||||
'font-feature-settings',
|
||||
'font-kerning',
|
||||
'font-language-override',
|
||||
'font-optical-sizing',
|
||||
'font-palette',
|
||||
'font-size',
|
||||
'font-size-adjust',
|
||||
'font-smooth',
|
||||
'font-smoothing',
|
||||
'font-stretch',
|
||||
'font-style',
|
||||
'font-synthesis',
|
||||
'font-synthesis-position',
|
||||
'font-synthesis-small-caps',
|
||||
'font-synthesis-style',
|
||||
'font-synthesis-weight',
|
||||
'font-variant',
|
||||
'font-variant-alternates',
|
||||
'font-variant-caps',
|
||||
'font-variant-east-asian',
|
||||
'font-variant-emoji',
|
||||
'font-variant-ligatures',
|
||||
'font-variant-numeric',
|
||||
'font-variant-position',
|
||||
'font-variation-settings',
|
||||
'font-weight',
|
||||
'forced-color-adjust',
|
||||
'gap',
|
||||
'glyph-orientation-horizontal',
|
||||
'glyph-orientation-vertical',
|
||||
'grid',
|
||||
'grid-area',
|
||||
'grid-auto-columns',
|
||||
'grid-auto-flow',
|
||||
'grid-auto-rows',
|
||||
'grid-column',
|
||||
'grid-column-end',
|
||||
'grid-column-start',
|
||||
'grid-gap',
|
||||
'grid-row',
|
||||
'grid-row-end',
|
||||
'grid-row-start',
|
||||
'grid-template',
|
||||
'grid-template-areas',
|
||||
'grid-template-columns',
|
||||
'grid-template-rows',
|
||||
'hanging-punctuation',
|
||||
'height',
|
||||
'hyphenate-character',
|
||||
'hyphenate-limit-chars',
|
||||
'hyphens',
|
||||
'icon',
|
||||
'image-orientation',
|
||||
'image-rendering',
|
||||
'image-resolution',
|
||||
'ime-mode',
|
||||
'initial-letter',
|
||||
'initial-letter-align',
|
||||
'inline-size',
|
||||
'inset',
|
||||
'inset-area',
|
||||
'inset-block',
|
||||
'inset-block-end',
|
||||
'inset-block-start',
|
||||
'inset-inline',
|
||||
'inset-inline-end',
|
||||
'inset-inline-start',
|
||||
'isolation',
|
||||
'justify-content',
|
||||
'justify-items',
|
||||
'justify-self',
|
||||
'kerning',
|
||||
'left',
|
||||
'letter-spacing',
|
||||
'lighting-color',
|
||||
'line-break',
|
||||
'line-height',
|
||||
'line-height-step',
|
||||
'list-style',
|
||||
'list-style-image',
|
||||
'list-style-position',
|
||||
'list-style-type',
|
||||
'margin',
|
||||
'margin-block',
|
||||
'margin-block-end',
|
||||
'margin-block-start',
|
||||
'margin-bottom',
|
||||
'margin-inline',
|
||||
'margin-inline-end',
|
||||
'margin-inline-start',
|
||||
'margin-left',
|
||||
'margin-right',
|
||||
'margin-top',
|
||||
'margin-trim',
|
||||
'marker',
|
||||
'marker-end',
|
||||
'marker-mid',
|
||||
'marker-start',
|
||||
'marks',
|
||||
'mask',
|
||||
'mask-border',
|
||||
'mask-border-mode',
|
||||
'mask-border-outset',
|
||||
'mask-border-repeat',
|
||||
'mask-border-slice',
|
||||
'mask-border-source',
|
||||
'mask-border-width',
|
||||
'mask-clip',
|
||||
'mask-composite',
|
||||
'mask-image',
|
||||
'mask-mode',
|
||||
'mask-origin',
|
||||
'mask-position',
|
||||
'mask-repeat',
|
||||
'mask-size',
|
||||
'mask-type',
|
||||
'masonry-auto-flow',
|
||||
'math-depth',
|
||||
'math-shift',
|
||||
'math-style',
|
||||
'max-block-size',
|
||||
'max-height',
|
||||
'max-inline-size',
|
||||
'max-width',
|
||||
'min-block-size',
|
||||
'min-height',
|
||||
'min-inline-size',
|
||||
'min-width',
|
||||
'mix-blend-mode',
|
||||
'nav-down',
|
||||
'nav-index',
|
||||
'nav-left',
|
||||
'nav-right',
|
||||
'nav-up',
|
||||
'none',
|
||||
'normal',
|
||||
'object-fit',
|
||||
'object-position',
|
||||
'offset',
|
||||
'offset-anchor',
|
||||
'offset-distance',
|
||||
'offset-path',
|
||||
'offset-position',
|
||||
'offset-rotate',
|
||||
'opacity',
|
||||
'order',
|
||||
'orphans',
|
||||
'outline',
|
||||
'outline-color',
|
||||
'outline-offset',
|
||||
'outline-style',
|
||||
'outline-width',
|
||||
'overflow',
|
||||
'overflow-anchor',
|
||||
'overflow-block',
|
||||
'overflow-clip-margin',
|
||||
'overflow-inline',
|
||||
'overflow-wrap',
|
||||
'overflow-x',
|
||||
'overflow-y',
|
||||
'overlay',
|
||||
'overscroll-behavior',
|
||||
'overscroll-behavior-block',
|
||||
'overscroll-behavior-inline',
|
||||
'overscroll-behavior-x',
|
||||
'overscroll-behavior-y',
|
||||
'padding',
|
||||
'padding-block',
|
||||
'padding-block-end',
|
||||
'padding-block-start',
|
||||
'padding-bottom',
|
||||
'padding-inline',
|
||||
'padding-inline-end',
|
||||
'padding-inline-start',
|
||||
'padding-left',
|
||||
'padding-right',
|
||||
'padding-top',
|
||||
'page',
|
||||
'page-break-after',
|
||||
'page-break-before',
|
||||
'page-break-inside',
|
||||
'paint-order',
|
||||
'pause',
|
||||
'pause-after',
|
||||
'pause-before',
|
||||
'perspective',
|
||||
'perspective-origin',
|
||||
'place-content',
|
||||
'place-items',
|
||||
'place-self',
|
||||
'pointer-events',
|
||||
'position',
|
||||
'position-anchor',
|
||||
'position-visibility',
|
||||
'print-color-adjust',
|
||||
'quotes',
|
||||
'r',
|
||||
'resize',
|
||||
'rest',
|
||||
'rest-after',
|
||||
'rest-before',
|
||||
'right',
|
||||
'rotate',
|
||||
'row-gap',
|
||||
'ruby-align',
|
||||
'ruby-position',
|
||||
'scale',
|
||||
'scroll-behavior',
|
||||
'scroll-margin',
|
||||
'scroll-margin-block',
|
||||
'scroll-margin-block-end',
|
||||
'scroll-margin-block-start',
|
||||
'scroll-margin-bottom',
|
||||
'scroll-margin-inline',
|
||||
'scroll-margin-inline-end',
|
||||
'scroll-margin-inline-start',
|
||||
'scroll-margin-left',
|
||||
'scroll-margin-right',
|
||||
'scroll-margin-top',
|
||||
'scroll-padding',
|
||||
'scroll-padding-block',
|
||||
'scroll-padding-block-end',
|
||||
'scroll-padding-block-start',
|
||||
'scroll-padding-bottom',
|
||||
'scroll-padding-inline',
|
||||
'scroll-padding-inline-end',
|
||||
'scroll-padding-inline-start',
|
||||
'scroll-padding-left',
|
||||
'scroll-padding-right',
|
||||
'scroll-padding-top',
|
||||
'scroll-snap-align',
|
||||
'scroll-snap-stop',
|
||||
'scroll-snap-type',
|
||||
'scroll-timeline',
|
||||
'scroll-timeline-axis',
|
||||
'scroll-timeline-name',
|
||||
'scrollbar-color',
|
||||
'scrollbar-gutter',
|
||||
'scrollbar-width',
|
||||
'shape-image-threshold',
|
||||
'shape-margin',
|
||||
'shape-outside',
|
||||
'shape-rendering',
|
||||
'speak',
|
||||
'speak-as',
|
||||
'src', // @font-face
|
||||
'stop-color',
|
||||
'stop-opacity',
|
||||
'stroke',
|
||||
'stroke-dasharray',
|
||||
'stroke-dashoffset',
|
||||
'stroke-linecap',
|
||||
'stroke-linejoin',
|
||||
'stroke-miterlimit',
|
||||
'stroke-opacity',
|
||||
'stroke-width',
|
||||
'tab-size',
|
||||
'table-layout',
|
||||
'text-align',
|
||||
'text-align-all',
|
||||
'text-align-last',
|
||||
'text-anchor',
|
||||
'text-combine-upright',
|
||||
'text-decoration',
|
||||
'text-decoration-color',
|
||||
'text-decoration-line',
|
||||
'text-decoration-skip',
|
||||
'text-decoration-skip-ink',
|
||||
'text-decoration-style',
|
||||
'text-decoration-thickness',
|
||||
'text-emphasis',
|
||||
'text-emphasis-color',
|
||||
'text-emphasis-position',
|
||||
'text-emphasis-style',
|
||||
'text-indent',
|
||||
'text-justify',
|
||||
'text-orientation',
|
||||
'text-overflow',
|
||||
'text-rendering',
|
||||
'text-shadow',
|
||||
'text-size-adjust',
|
||||
'text-transform',
|
||||
'text-underline-offset',
|
||||
'text-underline-position',
|
||||
'text-wrap',
|
||||
'text-wrap-mode',
|
||||
'text-wrap-style',
|
||||
'timeline-scope',
|
||||
'top',
|
||||
'touch-action',
|
||||
'transform',
|
||||
'transform-box',
|
||||
'transform-origin',
|
||||
'transform-style',
|
||||
'transition',
|
||||
'transition-behavior',
|
||||
'transition-delay',
|
||||
'transition-duration',
|
||||
'transition-property',
|
||||
'transition-timing-function',
|
||||
'translate',
|
||||
'unicode-bidi',
|
||||
'user-modify',
|
||||
'user-select',
|
||||
'vector-effect',
|
||||
'vertical-align',
|
||||
'view-timeline',
|
||||
'view-timeline-axis',
|
||||
'view-timeline-inset',
|
||||
'view-timeline-name',
|
||||
'view-transition-name',
|
||||
'visibility',
|
||||
'voice-balance',
|
||||
'voice-duration',
|
||||
'voice-family',
|
||||
'voice-pitch',
|
||||
'voice-range',
|
||||
'voice-rate',
|
||||
'voice-stress',
|
||||
'voice-volume',
|
||||
'white-space',
|
||||
'white-space-collapse',
|
||||
'widows',
|
||||
'width',
|
||||
'will-change',
|
||||
'word-break',
|
||||
'word-spacing',
|
||||
'word-wrap',
|
||||
'writing-mode',
|
||||
'x',
|
||||
'y',
|
||||
'z-index',
|
||||
'zoom'
|
||||
].sort().reverse();
|
||||
|
||||
/*
|
||||
Language: CSS
|
||||
Category: common, css, web
|
||||
Website: https://developer.mozilla.org/en-US/docs/Web/CSS
|
||||
*/
|
||||
|
||||
|
||||
/** @type LanguageFn */
|
||||
function css(hljs) {
|
||||
const regex = hljs.regex;
|
||||
const modes = MODES(hljs);
|
||||
const VENDOR_PREFIX = { begin: /-(webkit|moz|ms|o)-(?=[a-z])/ };
|
||||
const AT_MODIFIERS = "and or not only";
|
||||
const AT_PROPERTY_RE = /@-?\w[\w]*(-\w+)*/; // @-webkit-keyframes
|
||||
const IDENT_RE = '[a-zA-Z-][a-zA-Z0-9_-]*';
|
||||
const STRINGS = [
|
||||
hljs.APOS_STRING_MODE,
|
||||
hljs.QUOTE_STRING_MODE
|
||||
];
|
||||
|
||||
return {
|
||||
name: 'CSS',
|
||||
case_insensitive: true,
|
||||
illegal: /[=|'\$]/,
|
||||
keywords: { keyframePosition: "from to" },
|
||||
classNameAliases: {
|
||||
// for visual continuity with `tag {}` and because we
|
||||
// don't have a great class for this?
|
||||
keyframePosition: "selector-tag" },
|
||||
contains: [
|
||||
modes.BLOCK_COMMENT,
|
||||
VENDOR_PREFIX,
|
||||
// to recognize keyframe 40% etc which are outside the scope of our
|
||||
// attribute value mode
|
||||
modes.CSS_NUMBER_MODE,
|
||||
{
|
||||
className: 'selector-id',
|
||||
begin: /#[A-Za-z0-9_-]+/,
|
||||
relevance: 0
|
||||
},
|
||||
{
|
||||
className: 'selector-class',
|
||||
begin: '\\.' + IDENT_RE,
|
||||
relevance: 0
|
||||
},
|
||||
modes.ATTRIBUTE_SELECTOR_MODE,
|
||||
{
|
||||
className: 'selector-pseudo',
|
||||
variants: [
|
||||
{ begin: ':(' + PSEUDO_CLASSES.join('|') + ')' },
|
||||
{ begin: ':(:)?(' + PSEUDO_ELEMENTS.join('|') + ')' }
|
||||
]
|
||||
},
|
||||
// we may actually need this (12/2020)
|
||||
// { // pseudo-selector params
|
||||
// begin: /\(/,
|
||||
// end: /\)/,
|
||||
// contains: [ hljs.CSS_NUMBER_MODE ]
|
||||
// },
|
||||
modes.CSS_VARIABLE,
|
||||
{
|
||||
className: 'attribute',
|
||||
begin: '\\b(' + ATTRIBUTES.join('|') + ')\\b'
|
||||
},
|
||||
// attribute values
|
||||
{
|
||||
begin: /:/,
|
||||
end: /[;}{]/,
|
||||
contains: [
|
||||
modes.BLOCK_COMMENT,
|
||||
modes.HEXCOLOR,
|
||||
modes.IMPORTANT,
|
||||
modes.CSS_NUMBER_MODE,
|
||||
...STRINGS,
|
||||
// needed to highlight these as strings and to avoid issues with
|
||||
// illegal characters that might be inside urls that would tigger the
|
||||
// languages illegal stack
|
||||
{
|
||||
begin: /(url|data-uri)\(/,
|
||||
end: /\)/,
|
||||
relevance: 0, // from keywords
|
||||
keywords: { built_in: "url data-uri" },
|
||||
contains: [
|
||||
...STRINGS,
|
||||
{
|
||||
className: "string",
|
||||
// any character other than `)` as in `url()` will be the start
|
||||
// of a string, which ends with `)` (from the parent mode)
|
||||
begin: /[^)]/,
|
||||
endsWithParent: true,
|
||||
excludeEnd: true
|
||||
}
|
||||
]
|
||||
},
|
||||
modes.FUNCTION_DISPATCH
|
||||
]
|
||||
},
|
||||
{
|
||||
begin: regex.lookahead(/@/),
|
||||
end: '[{;]',
|
||||
relevance: 0,
|
||||
illegal: /:/, // break on Less variables @var: ...
|
||||
contains: [
|
||||
{
|
||||
className: 'keyword',
|
||||
begin: AT_PROPERTY_RE
|
||||
},
|
||||
{
|
||||
begin: /\s/,
|
||||
endsWithParent: true,
|
||||
excludeEnd: true,
|
||||
relevance: 0,
|
||||
keywords: {
|
||||
$pattern: /[a-z-]+/,
|
||||
keyword: AT_MODIFIERS,
|
||||
attribute: MEDIA_FEATURES.join(" ")
|
||||
},
|
||||
contains: [
|
||||
{
|
||||
begin: /[a-z-]+(?=:)/,
|
||||
className: "attribute"
|
||||
},
|
||||
...STRINGS,
|
||||
modes.CSS_NUMBER_MODE
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
className: 'selector-tag',
|
||||
begin: '\\b(' + TAGS.join('|') + ')\\b'
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
export { css as default };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function emitWarning() {
|
||||
if (!emitWarning.warned) {
|
||||
emitWarning.warned = true;
|
||||
console.log(
|
||||
'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/css" instead of "highlight.js/lib/languages/css.js"'
|
||||
);
|
||||
}
|
||||
}
|
||||
emitWarning();
|
||||
import lang from './css.js';
|
||||
export default lang;
|
||||
+272
@@ -0,0 +1,272 @@
|
||||
/*
|
||||
Language: D
|
||||
Author: Aleksandar Ruzicic <aleksandar@ruzicic.info>
|
||||
Description: D is a language with C-like syntax and static typing. It pragmatically combines efficiency, control, and modeling power, with safety and programmer productivity.
|
||||
Version: 1.0a
|
||||
Website: https://dlang.org
|
||||
Category: system
|
||||
Date: 2012-04-08
|
||||
*/
|
||||
|
||||
/**
|
||||
* Known issues:
|
||||
*
|
||||
* - invalid hex string literals will be recognized as a double quoted strings
|
||||
* but 'x' at the beginning of string will not be matched
|
||||
*
|
||||
* - delimited string literals are not checked for matching end delimiter
|
||||
* (not possible to do with js regexp)
|
||||
*
|
||||
* - content of token string is colored as a string (i.e. no keyword coloring inside a token string)
|
||||
* also, content of token string is not validated to contain only valid D tokens
|
||||
*
|
||||
* - special token sequence rule is not strictly following D grammar (anything following #line
|
||||
* up to the end of line is matched as special token sequence)
|
||||
*/
|
||||
|
||||
/** @type LanguageFn */
|
||||
function d(hljs) {
|
||||
/**
|
||||
* Language keywords
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
const D_KEYWORDS = {
|
||||
$pattern: hljs.UNDERSCORE_IDENT_RE,
|
||||
keyword:
|
||||
'abstract alias align asm assert auto body break byte case cast catch class '
|
||||
+ 'const continue debug default delete deprecated do else enum export extern final '
|
||||
+ 'finally for foreach foreach_reverse|10 goto if immutable import in inout int '
|
||||
+ 'interface invariant is lazy macro mixin module new nothrow out override package '
|
||||
+ 'pragma private protected public pure ref return scope shared static struct '
|
||||
+ 'super switch synchronized template this throw try typedef typeid typeof union '
|
||||
+ 'unittest version void volatile while with __FILE__ __LINE__ __gshared|10 '
|
||||
+ '__thread __traits __DATE__ __EOF__ __TIME__ __TIMESTAMP__ __VENDOR__ __VERSION__',
|
||||
built_in:
|
||||
'bool cdouble cent cfloat char creal dchar delegate double dstring float function '
|
||||
+ 'idouble ifloat ireal long real short string ubyte ucent uint ulong ushort wchar '
|
||||
+ 'wstring',
|
||||
literal:
|
||||
'false null true'
|
||||
};
|
||||
|
||||
/**
|
||||
* Number literal regexps
|
||||
*
|
||||
* @type {String}
|
||||
*/
|
||||
const decimal_integer_re = '(0|[1-9][\\d_]*)';
|
||||
const decimal_integer_nosus_re = '(0|[1-9][\\d_]*|\\d[\\d_]*|[\\d_]+?\\d)';
|
||||
const binary_integer_re = '0[bB][01_]+';
|
||||
const hexadecimal_digits_re = '([\\da-fA-F][\\da-fA-F_]*|_[\\da-fA-F][\\da-fA-F_]*)';
|
||||
const hexadecimal_integer_re = '0[xX]' + hexadecimal_digits_re;
|
||||
|
||||
const decimal_exponent_re = '([eE][+-]?' + decimal_integer_nosus_re + ')';
|
||||
const decimal_float_re = '(' + decimal_integer_nosus_re + '(\\.\\d*|' + decimal_exponent_re + ')|'
|
||||
+ '\\d+\\.' + decimal_integer_nosus_re + '|'
|
||||
+ '\\.' + decimal_integer_re + decimal_exponent_re + '?'
|
||||
+ ')';
|
||||
const hexadecimal_float_re = '(0[xX]('
|
||||
+ hexadecimal_digits_re + '\\.' + hexadecimal_digits_re + '|'
|
||||
+ '\\.?' + hexadecimal_digits_re
|
||||
+ ')[pP][+-]?' + decimal_integer_nosus_re + ')';
|
||||
|
||||
const integer_re = '('
|
||||
+ decimal_integer_re + '|'
|
||||
+ binary_integer_re + '|'
|
||||
+ hexadecimal_integer_re
|
||||
+ ')';
|
||||
|
||||
const float_re = '('
|
||||
+ hexadecimal_float_re + '|'
|
||||
+ decimal_float_re
|
||||
+ ')';
|
||||
|
||||
/**
|
||||
* Escape sequence supported in D string and character literals
|
||||
*
|
||||
* @type {String}
|
||||
*/
|
||||
const escape_sequence_re = '\\\\('
|
||||
+ '[\'"\\?\\\\abfnrtv]|' // common escapes
|
||||
+ 'u[\\dA-Fa-f]{4}|' // four hex digit unicode codepoint
|
||||
+ '[0-7]{1,3}|' // one to three octal digit ascii char code
|
||||
+ 'x[\\dA-Fa-f]{2}|' // two hex digit ascii char code
|
||||
+ 'U[\\dA-Fa-f]{8}' // eight hex digit unicode codepoint
|
||||
+ ')|'
|
||||
+ '&[a-zA-Z\\d]{2,};'; // named character entity
|
||||
|
||||
/**
|
||||
* D integer number literals
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
const D_INTEGER_MODE = {
|
||||
className: 'number',
|
||||
begin: '\\b' + integer_re + '(L|u|U|Lu|LU|uL|UL)?',
|
||||
relevance: 0
|
||||
};
|
||||
|
||||
/**
|
||||
* [D_FLOAT_MODE description]
|
||||
* @type {Object}
|
||||
*/
|
||||
const D_FLOAT_MODE = {
|
||||
className: 'number',
|
||||
begin: '\\b('
|
||||
+ float_re + '([fF]|L|i|[fF]i|Li)?|'
|
||||
+ integer_re + '(i|[fF]i|Li)'
|
||||
+ ')',
|
||||
relevance: 0
|
||||
};
|
||||
|
||||
/**
|
||||
* D character literal
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
const D_CHARACTER_MODE = {
|
||||
className: 'string',
|
||||
begin: '\'(' + escape_sequence_re + '|.)',
|
||||
end: '\'',
|
||||
illegal: '.'
|
||||
};
|
||||
|
||||
/**
|
||||
* D string escape sequence
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
const D_ESCAPE_SEQUENCE = {
|
||||
begin: escape_sequence_re,
|
||||
relevance: 0
|
||||
};
|
||||
|
||||
/**
|
||||
* D double quoted string literal
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
const D_STRING_MODE = {
|
||||
className: 'string',
|
||||
begin: '"',
|
||||
contains: [ D_ESCAPE_SEQUENCE ],
|
||||
end: '"[cwd]?'
|
||||
};
|
||||
|
||||
/**
|
||||
* D wysiwyg and delimited string literals
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
const D_WYSIWYG_DELIMITED_STRING_MODE = {
|
||||
className: 'string',
|
||||
begin: '[rq]"',
|
||||
end: '"[cwd]?',
|
||||
relevance: 5
|
||||
};
|
||||
|
||||
/**
|
||||
* D alternate wysiwyg string literal
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
const D_ALTERNATE_WYSIWYG_STRING_MODE = {
|
||||
className: 'string',
|
||||
begin: '`',
|
||||
end: '`[cwd]?'
|
||||
};
|
||||
|
||||
/**
|
||||
* D hexadecimal string literal
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
const D_HEX_STRING_MODE = {
|
||||
className: 'string',
|
||||
begin: 'x"[\\da-fA-F\\s\\n\\r]*"[cwd]?',
|
||||
relevance: 10
|
||||
};
|
||||
|
||||
/**
|
||||
* D delimited string literal
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
const D_TOKEN_STRING_MODE = {
|
||||
className: 'string',
|
||||
begin: 'q"\\{',
|
||||
end: '\\}"'
|
||||
};
|
||||
|
||||
/**
|
||||
* Hashbang support
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
const D_HASHBANG_MODE = {
|
||||
className: 'meta',
|
||||
begin: '^#!',
|
||||
end: '$',
|
||||
relevance: 5
|
||||
};
|
||||
|
||||
/**
|
||||
* D special token sequence
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
const D_SPECIAL_TOKEN_SEQUENCE_MODE = {
|
||||
className: 'meta',
|
||||
begin: '#(line)',
|
||||
end: '$',
|
||||
relevance: 5
|
||||
};
|
||||
|
||||
/**
|
||||
* D attributes
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
const D_ATTRIBUTE_MODE = {
|
||||
className: 'keyword',
|
||||
begin: '@[a-zA-Z_][a-zA-Z_\\d]*'
|
||||
};
|
||||
|
||||
/**
|
||||
* D nesting comment
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
const D_NESTING_COMMENT_MODE = hljs.COMMENT(
|
||||
'\\/\\+',
|
||||
'\\+\\/',
|
||||
{
|
||||
contains: [ 'self' ],
|
||||
relevance: 10
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
name: 'D',
|
||||
keywords: D_KEYWORDS,
|
||||
contains: [
|
||||
hljs.C_LINE_COMMENT_MODE,
|
||||
hljs.C_BLOCK_COMMENT_MODE,
|
||||
D_NESTING_COMMENT_MODE,
|
||||
D_HEX_STRING_MODE,
|
||||
D_STRING_MODE,
|
||||
D_WYSIWYG_DELIMITED_STRING_MODE,
|
||||
D_ALTERNATE_WYSIWYG_STRING_MODE,
|
||||
D_TOKEN_STRING_MODE,
|
||||
D_FLOAT_MODE,
|
||||
D_INTEGER_MODE,
|
||||
D_CHARACTER_MODE,
|
||||
D_HASHBANG_MODE,
|
||||
D_SPECIAL_TOKEN_SEQUENCE_MODE,
|
||||
D_ATTRIBUTE_MODE
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
export { d as default };
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user