diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000000..33deace552 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,132 @@ +name: Release + +on: + push: + tags: + - "*beta*" + - "*pre*" + # uncomment this later when we're ready for production releases + # - "1[0-9]+.[0-9]+.[0-9]+" + +jobs: + prerelease: + name: Pre-release + runs-on: ubuntu-latest + steps: + - name: Checkout highlight.js + uses: actions/checkout@v2 + + - name: Tag is ${{ github.ref }}. + # we have to repeat ourselves here since the environment is not actually updated + # until the next step executes, so we can't access $TAG_NAME yet + run: | + echo "TAG_NAME=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV + echo "MAJOR_VERSION=$(echo ${GITHUB_REF/refs\/tags\//} | cut -d'.' -f1)" >> $GITHUB_ENV + - name: Make sure we are pushing a tag... + if: ${{ !contains(github.ref,'refs/tags/') }} + run: false + # run: echo "TAG_NAME=0.0.0-test0" >> $GITHUB_ENV + + - if: contains(github.ref, 'beta') || contains(github.ref, 'pre') + run: | + echo "NPM_TAG=beta" >> $GITHUB_ENV + echo "RELEASING=beta" >> $GITHUB_ENV + + - if: ${{ !(contains(github.ref, 'beta') || contains(github.ref, 'pre')) }} + run: | + echo "NPM_TAG=latest" >> $GITHUB_ENV + echo "RELEASING=stable" >> $GITHUB_ENV + + - name: match-tag-to-package-version + uses: geritol/match-tag-to-package-version@0.0.2 + env: + TAG_PREFIX: refs/tags/ # Optional, default prefix refs/tags/ + + - name: Use Node.js 15.x + uses: actions/setup-node@v1 + with: + node-version: 15.x + - name: Build Node.js package + run: | + npm install + node ./tools/build.js -t node + npm test + + - name: Publish highlight.js to NPM + id: publish + uses: JS-DevTools/npm-publish@v1 + with: + check-version: true + token: ${{ secrets.NPM_TOKEN }} + package: ./build/package.json + tag: ${{ env.NPM_TAG }} + + - if: steps.publish.outputs.type != 'none' + run: | + echo "Version changed: ${{ steps.publish.outputs.old-version }} => ${{ steps.publish.outputs.version }}" + + # if stable release + - name: Stable Release + if: env.RELEASING == 'stable' + run: echo "BRANCH_NAME=${MAJOR_VERSION}-stable" >> $GITHUB_ENV + # else (beta) + - name: Beta Release + if: env.RELEASING == 'beta' + run: echo "BRANCH_NAME=master" >> $GITHUB_ENV + - name: Confirm release is either stable or beta + if: ${{ !(env.RELEASING == 'stable' || env.RELEASING == 'beta') }} + run: | + echo We seem to be releasing `${RELEASING}`. + false + + - name: Checkout cdn-release + uses: actions/checkout@v2 + with: + repository: 'highlightjs/cdn-release' + path: 'cdn-release' + token: ${{ secrets.CDN_REPO_TOKEN }} + ref: ${{ env.BRANCH_NAME }} + + - name: Build CDN package + run: node ./tools/build.js -t cdn :common + + - name: Commmit & Push cdn-release ${{ env.TAG_NAME }} + working-directory: ./cdn-release + run: | + rm -r ./build + mv ../build/ ./build/ + git config user.name github-actions + git config user.email github-actions@github.com + git add ./build/ + git commit -m'Update to version ${{ env.TAG_NAME }}' + git tag ${TAG_NAME} + git push -f --atomic origin ${BRANCH_NAME} ${TAG_NAME} + + - name: Publish cdn-assets to NPM + id: publish_cdn + uses: JS-DevTools/npm-publish@v1 + with: + check-version: true + token: ${{ secrets.NPM_TOKEN }} + package: ./cdn-release/build/package.json + tag: ${{ env.NPM_TAG }} + + # log.info('Updating CDN repo at %s' % settings.HLJS_CDN_SOURCE) + # run(['nodejs', 'tools/build.js', '--target', 'cdn', ':common']) + # os.chdir(settings.HLJS_CDN_SOURCE) + # run(['git', 'pull', '-f']) + # lines = run(['git', '--git-dir', os.path.join(settings.HLJS_CDN_SOURCE, '.git'), 'tag']) + # build_dir = os.path.join(settings.HLJS_CDN_SOURCE, 'build') + # if version in lines: + # log.info('Tag %s already exists in the local CDN repo' % version) + # else: + # if os.path.exists(build_dir): + # shutil.rmtree(build_dir) + # shutil.move(os.path.join(settings.HLJS_SOURCE, 'build'), build_dir) + # run(['git', 'add', '.']) + # run(['git', 'commit', '-m', 'Update to version %s' % version]) + # run(['git', 'tag', version]) + # run(['git', 'push']) + # run(['git', 'push', '--tags']) + # npm_publish(build_dir) + # os.chdir(settings.HLJS_SOURCE) diff --git a/.gitignore b/.gitignore index 52ed616381..c61bf80d10 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ extra/ # misc /work +/website diff --git a/AUTHORS.txt b/AUTHORS.txt index 1432d17ca0..68d7233d31 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -309,3 +309,4 @@ Contributors: - Patrick Scheibe - Kyle Brown - Marcus Ortiz +- Guillaume Grossetie diff --git a/CHANGES.md b/CHANGES.md index a10d111c42..afdeb16cd9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,8 @@ -## Version 10.4.0 (work in process) +## Version 10.4.0-beta1 + +Parser: + +- enh(parser) use negative look-ahead for `beginKeywords` support (#2813) [Josh Goebel][] Deprecations: @@ -14,10 +18,21 @@ Parser: New Languages: - Added 3rd party Chapel grammar to SUPPORTED_LANGUAGES (#2806) [Brad Chamberlain][] +- Added BBCode grammar to SUPPORTED_LANGUAGES (#2867) [Paul Reid][] - enh(javascript) Added `node-repl` for Node.js REPL sessions (#2792) [Marat Nagayev][] Language Improvements: +- enh(shell) Recognize prompts which contain tilde `~` (#2859) [Guillaume Grossetie][] +- enh(shell) Add support for multiline commands with line continuation `\` (#2861) [Guillaume Grossetie][] +- enh(autodetect) Over 30+ improvements to auto-detect (#2745) [Josh Goebel][] + - 4-5% improvement in auto-detect against large sample set + - properties, angelscript, lsl, javascript, n1ql, ocaml, ruby + - protobuf, hy, scheme, crystal, yaml, r, vbscript, groovy + - python, java, php, lisp, matlab, clojure, csharp, css +- fix(r) fixed keywords not properly spaced (#2852) [Josh Goebel][] +- fix(javascript) fix potential catastrophic backtracking (#2852) [Josh Goebel][] +- fix(livescript) fix potential catastrophic backtracking (#2852) [Josh Goebel][] - bug(xml) XML grammar was far too imprecise/fuzzy [Josh Goebel][] - enh(xml) Improve precision to prevent false auto-detect positives [Josh Goebel][] - fix(js/ts) Prevent for/while/if/switch from falsly matching as functions (#2803) [Josh Goebel][] @@ -30,6 +45,7 @@ Language Improvements: - enh(php) highlight variables (#2785) [Taufik Nurrohman][] - fix(python) Handle comments on decorators (#2804) [Jonathan Sharpe][] - enh(diff) improve highlighting of diff for git patches [Florian Bezdeka][] +- fix(llvm) lots of small improvements and fixes (#2830) [Josh Goebel][] - enh(mathematica) Rework entire implementation [Patrick Scheibe][] - Correct matching of the many variations of Mathematica's numbers - Matching of named-characters aka special symbols like `\[Gamma]` @@ -53,6 +69,8 @@ New themes: - *StackOverflow Dark* by [Jan Pilzer][] - *StackOverflow Light* by [Jan Pilzer][] +[Guillaume Grossetie]: https://github.com/mogztter +[Brad Chamberlain]: https://github.com/bradcray [Marat Nagayev]: https://github.com/nagayev [Fredrik Ekre]: https://github.com/fredrikekre [Richard Gibson]: https://github.com/gibson042 @@ -64,6 +82,7 @@ New themes: [Patrick Scheibe]: https://github.com/halirutan [Kyle Brown]: https://github.com/kylebrown9 [Marcus Ortiz]: https://github.com/mportiz08 +[Paul Reid]: https://github.com/RedGuy12 ## Version 10.3.1 diff --git a/README.md b/README.md index 014f73a657..3a1be89561 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Highlight.js [![latest version](https://badgen.net/npm/v/highlight.js?label=latest)](https://www.npmjs.com/package/highlight.js) +[![beta](https://badgen.net/npm/v/highlight.js/beta)](https://www.npmjs.com/package/highlight.js) [![license](https://badgen.net/github/license/highlightjs/highlight.js?color=cyan)](https://github.com/highlightjs/highlight.js/blob/master/LICENSE) [![install size](https://badgen.net/packagephobia/install/highlight.js?label=npm+install)](https://packagephobia.now.sh/result?p=highlight.js) ![minified](https://img.shields.io/github/size/highlightjs/cdn-release/build/highlight.min.js?label=minified) diff --git a/SUPPORTED_LANGUAGES.md b/SUPPORTED_LANGUAGES.md index 0fec40b51d..8c4661ac98 100644 --- a/SUPPORTED_LANGUAGES.md +++ b/SUPPORTED_LANGUAGES.md @@ -29,6 +29,7 @@ Languages that listed a **Package** below are 3rd party languages and are not bu | Awk | awk, mawk, nawk, gawk | | | Bash | bash, sh, zsh | | | Basic | basic | | +| BBCode | bbcode | [highlightjs-bbcode](https://github.com/RedGuy7/highlightjs-bbcode) | | BNF | bnf | | | Brainfuck | brainfuck, bf | | | C# | csharp, cs | | diff --git a/docs/conf.py b/docs/conf.py index 60dd5aa513..1094886b3f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -48,7 +48,7 @@ # built documents. # The full version, including alpha/beta/rc tags. -release = '10.3.1' +release = '10.4.0-beta1' # The short X.Y version. version = ".".join(release.split(".")[:2]) diff --git a/docs/language-contribution.rst b/docs/language-contribution.rst index f492becb4e..1e2de0a9f5 100644 --- a/docs/language-contribution.rst +++ b/docs/language-contribution.rst @@ -1,13 +1,37 @@ Language contributor checklist ============================== -1. Read ``extra/3RD_PARTY_QUICK_START.md`` ------------------------------------------- +1. Know that you are creating a 3rd party grammar +------------------------------------------------- -It contains rough high-level steps for creating a 3rd party language grammar for Highlight.js. +*Sadly, due to lack of maintainer time we no longer merge new languages grammars +into the core library.* Instead, the project works by encouraging 3rd party +language grammar development by willing contributors ready to help and maintain +them. We're also happy to host those 3rd party language grammars at the +``highlightjs`` GitHub organization. Or you're welcome to host yourself - we're +always happy to link to to new language grammars. +We also make it easy to build, maintain, and distribute 3rd party grammar +modules so that Highlight.js can always be easily extended with new languages. +Using a 3rd party language (for end users) is often as simple as just adding a +single line of code to their JavaScript or build system. -2. Create a language grammar definition file +We'd love to have your grammar as a 3rd party language module if you'd be +willing to maintain it over time. It's easy to develop and publish a 3rd party +language module. If you already started work in the main source tree - it's +trivial to convert your existing work into a 3rd party module. (you pretty much +just move your files into a new project folder) + + +2. Read extra/3RD_PARTY_QUICK_START.md +-------------------------------------- + +Next, read ``extra/3RD_PARTY_QUICK_START.md``. This should provide you with a +very high-level overview of the steps for creating a third-party language +grammar for Highlight.js. + + +3. Create a language grammar definition file -------------------------------------------- The file defines a function accepting a reference to the library and returning a language object. @@ -25,10 +49,12 @@ process and details differ for different build targets. } } -The name of the file is used as a short language identifier and should be usable as a class name in HTML and CSS. +The name of the file is used as a short language identifier and should be usable +as a class name in HTML and CSS. Typically you'll place this file in your +new grammar repository under ``my_new_grammar/src/languages/``. -3. Add language metadata +4. Add language metadata ---------------------------- At the top of the file there is a specially formatted comment with meta data processed by a build system. @@ -56,7 +82,7 @@ The build system just makes sure that they will be in the final package in The meaning of the other headers should be pretty obvious. -4. Create a code example +5. Create a code example ------------------------ The code example is used both to test language detection and for the demo page @@ -66,7 +92,7 @@ Take inspiration from other languages in ``test/detect/`` and read :ref:`testing instructions ` for more details. -5. Write a class reference if your class uses custom classes +6. Write a class reference if your class uses custom classes ------------------------------------------------------------ A class reference document should typically be placed at the root of your @@ -79,14 +105,14 @@ are not going to support your custom classes and you should likely also distribute your own custom theme. -6. Request a repository at the ``highlightjs`` organization +7. Request a repository at the ``highlightjs`` organization ---------------------------------------------------------- *This is optional.* Of course you are free to host your repository anywhere you would like. -7. Create a pull request +8. Create a pull request ------------------------ Submit a PR to add your language to `SUPPORTED_LANGUAGES.md`. diff --git a/package-lock.json b/package-lock.json index ca1d0b3cbf..e95bef2389 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "highlight.js", - "version": "10.3.99", + "version": "10.4.0-beta1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -95,6 +95,132 @@ "fastq": "^1.6.0" } }, + "@rollup/plugin-commonjs": { + "version": "16.0.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-16.0.0.tgz", + "integrity": "sha512-LuNyypCP3msCGVQJ7ki8PqYdpjfEkE/xtFa5DqlF+7IBD0JsfMZ87C58heSwIMint58sAUZbt3ITqOmdQv/dXw==", + "dev": true, + "requires": { + "@rollup/pluginutils": "^3.1.0", + "commondir": "^1.0.1", + "estree-walker": "^2.0.1", + "glob": "^7.1.6", + "is-reference": "^1.2.1", + "magic-string": "^0.25.7", + "resolve": "^1.17.0" + }, + "dependencies": { + "estree-walker": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.1.tgz", + "integrity": "sha512-tF0hv+Yi2Ot1cwj9eYHtxC0jB9bmjacjQs6ZBTj82H8JwUywFuc+7E83NWfNMwHXZc11mjfFcVXPe9gEP4B8dg==", + "dev": true + }, + "is-reference": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz", + "integrity": "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==", + "dev": true, + "requires": { + "@types/estree": "*" + } + }, + "magic-string": { + "version": "0.25.7", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.7.tgz", + "integrity": "sha512-4CrMT5DOHTDk4HYDlzmwu4FVCcIYI8gauveasrdCu2IKIFOJ3f0v/8MDGJCDL9oD2ppz/Av1b0Nj345H9M+XIA==", + "dev": true, + "requires": { + "sourcemap-codec": "^1.4.4" + } + }, + "resolve": { + "version": "1.18.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.18.1.tgz", + "integrity": "sha512-lDfCPaMKfOJXjy0dPayzPdF1phampNWr3qFCjAu+rw/qbQmr5jWH5xN2hwh9QKfw9E5v4hwV7A+jrCmL8yjjqA==", + "dev": true, + "requires": { + "is-core-module": "^2.0.0", + "path-parse": "^1.0.6" + } + } + } + }, + "@rollup/plugin-json": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-json/-/plugin-json-4.1.0.tgz", + "integrity": "sha512-yfLbTdNS6amI/2OpmbiBoW12vngr5NW2jCJVZSBEz+H5KfUJZ2M7sDjk0U6GOOdCWFVScShte29o9NezJ53TPw==", + "dev": true, + "requires": { + "@rollup/pluginutils": "^3.0.8" + } + }, + "@rollup/plugin-node-resolve": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-10.0.0.tgz", + "integrity": "sha512-sNijGta8fqzwA1VwUEtTvWCx2E7qC70NMsDh4ZG13byAXYigBNZMxALhKUSycBks5gupJdq0lFrKumFrRZ8H3A==", + "dev": true, + "requires": { + "@rollup/pluginutils": "^3.1.0", + "@types/resolve": "1.17.1", + "builtin-modules": "^3.1.0", + "deepmerge": "^4.2.2", + "is-module": "^1.0.0", + "resolve": "^1.17.0" + }, + "dependencies": { + "@types/resolve": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz", + "integrity": "sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, + "resolve": { + "version": "1.18.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.18.1.tgz", + "integrity": "sha512-lDfCPaMKfOJXjy0dPayzPdF1phampNWr3qFCjAu+rw/qbQmr5jWH5xN2hwh9QKfw9E5v4hwV7A+jrCmL8yjjqA==", + "dev": true, + "requires": { + "is-core-module": "^2.0.0", + "path-parse": "^1.0.6" + } + } + } + }, + "@rollup/pluginutils": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz", + "integrity": "sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==", + "dev": true, + "requires": { + "@types/estree": "0.0.39", + "estree-walker": "^1.0.1", + "picomatch": "^2.2.2" + }, + "dependencies": { + "estree-walker": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz", + "integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==", + "dev": true + }, + "picomatch": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz", + "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==", + "dev": true + } + } + }, + "@types/estree": { + "version": "0.0.39", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", + "integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==", + "dev": true + }, "@types/events": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/@types/events/-/events-3.0.0.tgz", @@ -475,6 +601,12 @@ "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", "dev": true }, + "builtin-modules": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.1.0.tgz", + "integrity": "sha512-k0KL0aWZuBt2lrxrcASWDfwOLMnodeQjodT/1SxEQAXsHANgo6ZC/VEaSEHCXt7aSTZ4/4H5LKa+tBXmW7Vtvw==", + "dev": true + }, "callsites": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", @@ -656,6 +788,12 @@ "integrity": "sha512-zP4jEKbe8SHzKJYQmq8Y9gYjtO/POJLgIdKgV7B9qNmABVFVc+ctqSX6iXh4mCpJfRBOabiZ2YKPg8ciDw6C+Q==", "dev": true }, + "commondir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", + "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=", + "dev": true + }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -759,12 +897,24 @@ "integrity": "sha512-KaL7+6Fw6i5A2XSnsbhm/6B+NuEA7TZ4vqxnd5tXz9sbKtrN9Srj8ab4vKVdK8YAqZO9P1kg45Y6YLoduPf+kw==", "dev": true }, + "deep-freeze-es6": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/deep-freeze-es6/-/deep-freeze-es6-1.3.1.tgz", + "integrity": "sha512-h3SrxRF46NCBuk5GLPUk7ceLQ+DgixZ60DzHMCgCcgC12xs7d6zAGa00FKpXrv5YC7Vi4oo0RHL9Q2Gthg77lg==", + "dev": true + }, "deep-is": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", "dev": true }, + "deepmerge": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.2.2.tgz", + "integrity": "sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==", + "dev": true + }, "define-properties": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", @@ -1341,12 +1491,6 @@ "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", "dev": true }, - "estree-walker": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.1.tgz", - "integrity": "sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==", - "dev": true - }, "esutils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", @@ -1799,6 +1943,15 @@ "integrity": "sha512-pyVD9AaGLxtg6srb2Ng6ynWJqkHU9bEM087AKck0w8QwDarTfNcpIYoU8x8Hv2Icm8u6kFJM18Dag8lyqGkviw==", "dev": true }, + "is-core-module": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.1.0.tgz", + "integrity": "sha512-YcV7BgVMRFRua2FqQzKtTDMz8iCuLEyGKjr70q8Zm1yy2qKcurbFEd79PAdHV77oL3NrAaOVQIbMmiHQCHB7ZA==", + "dev": true, + "requires": { + "has": "^1.0.3" + } + }, "is-date-object": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", @@ -1826,6 +1979,12 @@ "is-extglob": "^2.1.1" } }, + "is-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", + "integrity": "sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE=", + "dev": true + }, "is-number": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", @@ -1856,23 +2015,6 @@ "integrity": "sha1-DFLlS8yjkbssSUsh6GJtczbG45c=", "dev": true }, - "is-reference": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.1.4.tgz", - "integrity": "sha512-uJA/CDPO3Tao3GTrxYn6AwkM4nUPJiGGYu5+cB8qbC7WGFlrKZbiRo7SFKxUAEpFUfiHofWCXBUNhvYJMh+6zw==", - "dev": true, - "requires": { - "@types/estree": "0.0.39" - }, - "dependencies": { - "@types/estree": { - "version": "0.0.39", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", - "integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==", - "dev": true - } - } - }, "is-regex": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.0.tgz", @@ -2113,15 +2255,6 @@ "yallist": "^2.1.2" } }, - "magic-string": { - "version": "0.25.4", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.4.tgz", - "integrity": "sha512-oycWO9nEVAP2RVPbIoDoA4Y7LFIJ3xRYov93gAyJhZkET1tNuB0u7uWkZS2LpBWTJUWnmau/To8ECWRC+jKNfw==", - "dev": true, - "requires": { - "sourcemap-codec": "^1.4.4" - } - }, "merge2": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", @@ -2788,48 +2921,6 @@ "fsevents": "~2.1.2" } }, - "rollup-plugin-commonjs": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/rollup-plugin-commonjs/-/rollup-plugin-commonjs-10.1.0.tgz", - "integrity": "sha512-jlXbjZSQg8EIeAAvepNwhJj++qJWNJw1Cl0YnOqKtP5Djx+fFGkp3WRh+W0ASCaFG5w1jhmzDxgu3SJuVxPF4Q==", - "dev": true, - "requires": { - "estree-walker": "^0.6.1", - "is-reference": "^1.1.2", - "magic-string": "^0.25.2", - "resolve": "^1.11.0", - "rollup-pluginutils": "^2.8.1" - }, - "dependencies": { - "resolve": { - "version": "1.14.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.14.0.tgz", - "integrity": "sha512-uviWSi5N67j3t3UKFxej1loCH0VZn5XuqdNxoLShPcYPw6cUZn74K1VRj+9myynRX03bxIBEkwlkob/ujLsJVw==", - "dev": true, - "requires": { - "path-parse": "^1.0.6" - } - } - } - }, - "rollup-plugin-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/rollup-plugin-json/-/rollup-plugin-json-4.0.0.tgz", - "integrity": "sha512-hgb8N7Cgfw5SZAkb3jf0QXii6QX/FOkiIq2M7BAQIEydjHvTyxXHQiIzZaTFgx1GK0cRCHOCBHIyEkkLdWKxow==", - "dev": true, - "requires": { - "rollup-pluginutils": "^2.5.0" - } - }, - "rollup-pluginutils": { - "version": "2.8.2", - "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz", - "integrity": "sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==", - "dev": true, - "requires": { - "estree-walker": "^0.6.1" - } - }, "run-parallel": { "version": "1.1.9", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.1.9.tgz", diff --git a/package.json b/package.json index 1bb15f16f7..311b83c7b2 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "syntax" ], "homepage": "https://highlightjs.org/", - "version": "10.3.99", + "version": "10.4.0-beta1", "author": { "name": "Ivan Sagalaev", "email": "maniac@softwaremaniacs.org" @@ -39,12 +39,16 @@ "node": "*" }, "devDependencies": { + "@rollup/plugin-commonjs": "^16.0.0", + "@rollup/plugin-json": "^4.1.0", + "@rollup/plugin-node-resolve": "^10.0.0", "@typescript-eslint/eslint-plugin": "^4.6.1", "@typescript-eslint/parser": "^4.6.1", "clean-css": "^4.2.3", "cli-table": "^0.3.1", "colors": "^1.1.2", "commander": "^6.2.0", + "deep-freeze-es6": "^1.3.1", "del": "^6.0.0", "dependency-resolver": "^2.0.1", "eslint": "^7.12.1", @@ -61,8 +65,6 @@ "lodash": "^4.17.20", "mocha": "^8.2.1", "rollup": "^2.33.1", - "rollup-plugin-commonjs": "^10.1.0", - "rollup-plugin-json": "^4.0.0", "should": "^13.2.3", "terser": "^5.3.8", "tiny-worker": "^2.3.0", diff --git a/src/highlight.js b/src/highlight.js index c4e2f6ddb5..2182ace6cf 100644 --- a/src/highlight.js +++ b/src/highlight.js @@ -3,7 +3,8 @@ Syntax highlighting with language autodetection. https://highlightjs.org/ */ -import deepFreeze from './vendor/deep_freeze.js'; +// @ts-ignore +import deepFreeze from 'deep-freeze-es6'; import Response from './lib/response.js'; import TokenTreeEmitter from './lib/token_tree.js'; import * as regex from './lib/regex.js'; diff --git a/src/languages/1c.js b/src/languages/1c.js index d40f539ec5..595aaeca58 100644 --- a/src/languages/1c.js +++ b/src/languages/1c.js @@ -515,5 +515,5 @@ export default function(hljs) { STRINGS, DATE ] - } + }; } diff --git a/src/languages/angelscript.js b/src/languages/angelscript.js index 5f88af397a..8472ccb646 100644 --- a/src/languages/angelscript.js +++ b/src/languages/angelscript.js @@ -113,6 +113,7 @@ export default function(hljs) { { // numbers className: 'number', + relevance: 0, begin: '(-?)(\\b0[xXbBoOdD][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?f?|\\.\\d+f?)([eE][-+]?\\d+f?)?)' } ] diff --git a/src/languages/bash.js b/src/languages/bash.js index eb62efe04d..9dd90dd6bd 100644 --- a/src/languages/bash.js +++ b/src/languages/bash.js @@ -6,6 +6,8 @@ Website: https://www.gnu.org/software/bash/ Category: common */ +import * as regex from '../lib/regex.js'; + /** @type LanguageFn */ export default function(hljs) { const VAR = {}; @@ -23,7 +25,10 @@ export default function(hljs) { Object.assign(VAR,{ className: 'variable', variants: [ - {begin: /\$[\w\d#@][\w\d_]*/}, + {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 ] }); diff --git a/src/languages/c-like.js b/src/languages/c-like.js index 348e6f01e8..50bd0632ff 100644 --- a/src/languages/c-like.js +++ b/src/languages/c-like.js @@ -2,7 +2,6 @@ Language: C-like foundation grammar for C/C++ grammars Author: Ivan Sagalaev Contributors: Evgeny Stepanischev , Zaven Muradyan , Roel Deckers , Sam Wu , Jordi Petit , Pieter Vantorre , Google Inc. (David Benjamin) -Category: common, system */ /* In the future the intention is to split out the C/C++ grammars distinctly @@ -18,7 +17,7 @@ export default function(hljs) { function optional(s) { return '(?:' + s + ')?'; } - // added for historic reasons because `hljs.C_LINE_COMMENT_MODE` does + // 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 var C_LINE_COMMENT_MODE = hljs.COMMENT('//', '$', { diff --git a/src/languages/clojure.js b/src/languages/clojure.js index a243e5805f..22df9dd21e 100644 --- a/src/languages/clojure.js +++ b/src/languages/clojure.js @@ -16,7 +16,7 @@ export default function(hljs) { 'builtin-name': // Clojure keywords globals + ' ' + - 'cond apply if-not if-let if not not= = < > <= >= == + / * - rem ' + + '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? ' + @@ -88,7 +88,9 @@ export default function(hljs) { }; var NAME = { keywords: keywords, - className: 'name', begin: SYMBOL_RE, + className: 'name', + begin: SYMBOL_RE, + relevance: 0, starts: BODY }; var DEFAULT_CONTAINS = [LIST, STRING, HINT, HINT_COL, COMMENT, KEY, COLLECTION, NUMBER, LITERAL, SYMBOL]; diff --git a/src/languages/crystal.js b/src/languages/crystal.js index 3224886803..7f4c5b0834 100644 --- a/src/languages/crystal.js +++ b/src/languages/crystal.js @@ -158,7 +158,7 @@ export default function(hljs) { endsParent: true }) ], - relevance: 5 + relevance: 2 }, { className: 'symbol', diff --git a/src/languages/csharp.js b/src/languages/csharp.js index 5d90471271..7e002ee832 100644 --- a/src/languages/csharp.js +++ b/src/languages/csharp.js @@ -139,7 +139,7 @@ export default function(hljs) { 'select', 'set', 'unmanaged', - 'value', + 'value|0', 'var', 'when', 'where', @@ -274,7 +274,9 @@ export default function(hljs) { STRING, NUMBERS, { - beginKeywords: 'class interface', end: /[{;=]/, + beginKeywords: 'class interface', + relevance: 0, + end: /[{;=]/, illegal: /[^\s:,]/, contains: [ { beginKeywords: "where class" }, @@ -285,7 +287,9 @@ export default function(hljs) { ] }, { - beginKeywords: 'namespace', end: /[{;=]/, + beginKeywords: 'namespace', + relevance: 0, + end: /[{;=]/, illegal: /[^\s:]/, contains: [ TITLE_MODE, @@ -294,7 +298,9 @@ export default function(hljs) { ] }, { - beginKeywords: 'record', end: /[{;=]/, + beginKeywords: 'record', + relevance: 0, + end: /[{;=]/, illegal: /[^\s:]/, contains: [ TITLE_MODE, @@ -324,7 +330,10 @@ export default function(hljs) { keywords: KEYWORDS, contains: [ // prevents these from being highlighted `title` - { beginKeywords: FUNCTION_MODIFIERS.join(" ")}, + { + beginKeywords: FUNCTION_MODIFIERS.join(" "), + relevance: 0 + }, { begin: hljs.IDENT_RE + '\\s*(<.+>)?\\s*\\(', returnBegin: true, contains: [ diff --git a/src/languages/css.js b/src/languages/css.js index 2ef3976c1b..50ef1982f1 100644 --- a/src/languages/css.js +++ b/src/languages/css.js @@ -49,7 +49,7 @@ export default function(hljs) { var AT_PROPERTY_RE = /@-?\w[\w]*(-\w+)*/ // @-webkit-keyframes var IDENT_RE = '[a-zA-Z-][a-zA-Z0-9_-]*'; var RULE = { - begin: /(?:[A-Z_.-]+|--[a-zA-Z0-9_-]+)\s*:/, returnBegin: true, end: ';', endsWithParent: true, + begin: /([*]\s?)?(?:[A-Z_.\-\\]+|--[a-zA-Z0-9_-]+)\s*(\/\*\*\/)?:/, returnBegin: true, end: ';', endsWithParent: true, contains: [ ATTRIBUTE ] @@ -58,14 +58,14 @@ export default function(hljs) { return { name: 'CSS', case_insensitive: true, - illegal: /[=\/|'\$]/, + illegal: /[=|'\$]/, contains: [ hljs.C_BLOCK_COMMENT_MODE, { className: 'selector-id', begin: /#[A-Za-z0-9_-]+/ }, { - className: 'selector-class', begin: /\.[A-Za-z0-9_-]+/ + className: 'selector-class', begin: '\\.' + IDENT_RE }, { className: 'selector-attr', @@ -125,6 +125,7 @@ export default function(hljs) { illegal: /\S/, contains: [ hljs.C_BLOCK_COMMENT_MODE, + { begin: /;/ }, // empty ; rule RULE, ] } diff --git a/src/languages/groovy.js b/src/languages/groovy.js index 898f258e28..4e3c63a6ce 100644 --- a/src/languages/groovy.js +++ b/src/languages/groovy.js @@ -78,7 +78,10 @@ export default function(hljs) { 'throw throws try catch finally implements extends new import package return instanceof' }, contains: [ - hljs.SHEBANG(), + hljs.SHEBANG({ + binary: "groovy", + relevance: 10 + }), COMMENT, STRING, REGEXP, @@ -93,7 +96,9 @@ export default function(hljs) { ] }, { - className: 'meta', begin: '@[A-Za-z]+' + className: 'meta', + begin: '@[A-Za-z]+', + relevance: 0 }, { // highlight map keys and named parameters as attrs @@ -104,6 +109,7 @@ export default function(hljs) { // to avoid highlight it as a label, named parameter, or map key begin: /\?/, end: /:/, + relevance: 0, contains: [ COMMENT, STRING, diff --git a/src/languages/hy.js b/src/languages/hy.js index b86d6f787f..d603b23d62 100644 --- a/src/languages/hy.js +++ b/src/languages/hy.js @@ -86,8 +86,10 @@ export default function(hljs) { relevance: 0 }; var NAME = { + className: 'name', + relevance: 0, keywords: keywords, - className: 'name', begin: SYMBOL_RE, + begin: SYMBOL_RE, starts: BODY }; var DEFAULT_CONTAINS = [LIST, STRING, HINT, HINT_COL, COMMENT, KEY, COLLECTION, NUMBER, LITERAL, SYMBOL]; @@ -101,5 +103,5 @@ export default function(hljs) { aliases: ['hylang'], illegal: /\S/, contains: [hljs.SHEBANG(), LIST, STRING, HINT, HINT_COL, COMMENT, KEY, COLLECTION, NUMBER, LITERAL] - } + }; } diff --git a/src/languages/java.js b/src/languages/java.js index 9c949f726c..9b7c83fb7a 100644 --- a/src/languages/java.js +++ b/src/languages/java.js @@ -5,8 +5,6 @@ Category: common, enterprise Website: https://www.java.com/ */ -import * as regex from '../lib/regex.js'; - export default function(hljs) { var JAVA_IDENT_RE = '[\u00C0-\u02B8a-zA-Z_$][\u00C0-\u02B8a-zA-Z_$0-9]*'; var GENERIC_IDENT_RE = JAVA_IDENT_RE + '(<' + JAVA_IDENT_RE + '(\\s*,\\s*' + JAVA_IDENT_RE + ')*>)?'; @@ -86,6 +84,12 @@ export default function(hljs) { ] } ), + // relevance boost + { + begin: /import java\.[a-z]+\./, + keywords: "import", + relevance: 2 + }, hljs.C_LINE_COMMENT_MODE, hljs.C_BLOCK_COMMENT_MODE, hljs.APOS_STRING_MODE, diff --git a/src/languages/javascript.js b/src/languages/javascript.js index bb077d6138..3372b917bf 100644 --- a/src/languages/javascript.js +++ b/src/languages/javascript.js @@ -18,7 +18,7 @@ export default function(hljs) { * @param {{after:number}} param1 */ const hasClosingTag = (match, { after }) => { - const tag = match[0].replace("<", " Description: language used as intermediate representation in the LLVM compiler framework Website: https://llvm.org/docs/LangRef.html Category: assembler +Audit: 2020 */ +import * as regex from '../lib/regex.js'; + +/** @type LanguageFn */ export default function(hljs) { - var identifier = '([-a-zA-Z$._][\\w\\-$.]*)'; + const IDENT_RE = /([-a-zA-Z$._][\w$.-]*)/; + const TYPE = { + className: 'type', + begin: /\bi\d+(?=\s|\b)/ + }; + const OPERATOR = { + className: 'operator', + relevance: 0, + begin: /=/ + }; + const PUNCTUATION = { + className: 'punctuation', + relevance: 0, + begin: /,/ + }; + const NUMBER = { + className: 'number', + variants: [ + { begin: /0[xX][a-fA-F0-9]+/ }, + { begin: /-?\d+(?:[.]\d+)?(?:[eE][-+]?\d+(?:[.]\d+)?)?/ } + ], + relevance: 0 + }; + const LABEL = { + className: 'symbol', + variants: [ + { begin: /^\s*[a-z]+:/ }, // labels + ], + relevance: 0 + }; + const VARIABLE = { + className: 'variable', + variants: [ + { begin: regex.concat(/%/, IDENT_RE) }, + { begin: /%\d+/ }, + { begin: /#\d+/ }, + ] + }; + const FUNCTION = { + className: 'title', + variants: [ + { begin: regex.concat(/@/, IDENT_RE) }, + { begin: /@\d+/ }, + { begin: regex.concat(/!/, IDENT_RE) }, + { begin: regex.concat(/!\d+/, IDENT_RE) }, + // https://llvm.org/docs/LangRef.html#namedmetadatastructure + // obviously a single digit can also be used in this fashion + { begin: /!\d+/ } + ] + }; + return { name: 'LLVM IR', + // TODO: split into different categories of keywords keywords: 'begin end true false declare define global ' + 'constant private linker_private internal ' + @@ -49,48 +104,26 @@ export default function(hljs) { 'extractvalue insertvalue atomicrmw cmpxchg fence ' + 'argmemonly double', contains: [ - { - className: 'keyword', - begin: 'i\\d+' - }, - hljs.COMMENT( - ';', '\\n', {relevance: 0} - ), - // Double quote string + TYPE, + // this matches "empty comments"... + // ...because it's far more likely this is a statement terminator in + // another language than an actual comment + hljs.COMMENT(/;\s*$/, null, { relevance: 0 }), + hljs.COMMENT(/;/, /$/), hljs.QUOTE_STRING_MODE, { className: 'string', variants: [ // Double-quoted string - { begin: '"', end: '[^\\\\]"' }, - ], - relevance: 0 - }, - { - className: 'title', - variants: [ - { begin: '@' + identifier }, - { begin: '@\\d+' }, - { begin: '!' + identifier }, - { begin: '!\\d+' + identifier } + { begin: /"/, end: /[^\\]"/ }, ] }, - { - className: 'symbol', - variants: [ - { begin: '%' + identifier }, - { begin: '%\\d+' }, - { begin: '#\\d+' }, - ] - }, - { - className: 'number', - variants: [ - { begin: '0[xX][a-fA-F0-9]+' }, - { begin: '-?\\d+(?:[.]\\d+)?(?:[eE][-+]?\\d+(?:[.]\\d+)?)?' } - ], - relevance: 0 - }, + FUNCTION, + PUNCTUATION, + OPERATOR, + VARIABLE, + LABEL, + NUMBER ] }; } diff --git a/src/languages/lsl.js b/src/languages/lsl.js index 08f57d782c..c998894611 100644 --- a/src/languages/lsl.js +++ b/src/languages/lsl.js @@ -24,6 +24,7 @@ export default function(hljs) { var LSL_NUMBERS = { className: 'number', + relevance:0, begin: hljs.C_NUMBER_RE }; diff --git a/src/languages/matlab.js b/src/languages/matlab.js index b89a5de22e..06f99fe23e 100644 --- a/src/languages/matlab.js +++ b/src/languages/matlab.js @@ -38,8 +38,8 @@ export default function(hljs) { 'eye repmat rand randn linspace logspace freqspace meshgrid accumarray size length ' + 'ndims numel disp isempty isequal isequalwithequalnans cat reshape diag blkdiag tril ' + 'triu fliplr flipud flipdim rot90 find sub2ind ind2sub bsxfun ndgrid permute ipermute ' + - 'shiftdim circshift squeeze isscalar isvector ans eps realmax realmin pi i inf nan ' + - 'isnan isinf isfinite j why compan gallery hadamard hankel hilb invhilb magic pascal ' + + 'shiftdim circshift squeeze isscalar isvector ans eps realmax realmin pi i|0 inf nan ' + + 'isnan isinf isfinite j|0 why compan gallery hadamard hankel hilb invhilb magic pascal ' + 'rosser toeplitz vander wilkinson max min nanmax nanmin mean nanmean type table ' + 'readtable writetable sortrows sort figure plot plot3 scatter scatter3 cellfun ' + 'legend intersect ismember procrustes hold num2cell ' diff --git a/src/languages/mercury.js b/src/languages/mercury.js index eeab89f5e6..ece8023bd4 100644 --- a/src/languages/mercury.js +++ b/src/languages/mercury.js @@ -49,7 +49,7 @@ export default function(hljs) { begin: '\\\\[abfnrtv]\\|\\\\x[0-9a-fA-F]*\\\\\\|%[-+# *.0-9]*[dioxXucsfeEgGp]', relevance: 0 }; - STRING.contains = STRING.contains.slice() // we need our own copy of contains + STRING.contains = STRING.contains.slice(); // we need our own copy of contains STRING.contains.push(STRING_FMT); var IMPLICATION = { diff --git a/src/languages/n1ql.js b/src/languages/n1ql.js index 3e8bc716a5..d631ea901e 100644 --- a/src/languages/n1ql.js +++ b/src/languages/n1ql.js @@ -52,14 +52,12 @@ export default function(hljs) { { className: 'string', begin: '\'', end: '\'', - contains: [hljs.BACKSLASH_ESCAPE], - relevance: 0 + contains: [hljs.BACKSLASH_ESCAPE] }, { className: 'string', begin: '"', end: '"', - contains: [hljs.BACKSLASH_ESCAPE], - relevance: 0 + contains: [hljs.BACKSLASH_ESCAPE] }, { className: 'symbol', diff --git a/src/languages/ocaml.js b/src/languages/ocaml.js index ff4a918fac..04cc7e7852 100644 --- a/src/languages/ocaml.js +++ b/src/languages/ocaml.js @@ -73,7 +73,7 @@ export default function(hljs) { relevance: 0 }, { - begin: /[-=]>/ // relevance booster + begin: /->/ // relevance booster } ] } diff --git a/src/languages/parser3.js b/src/languages/parser3.js index 18ee3634ae..e300fc4109 100644 --- a/src/languages/parser3.js +++ b/src/languages/parser3.js @@ -20,7 +20,7 @@ export default function(hljs) { contains: [ hljs.COMMENT('^#', '$'), hljs.COMMENT( - /\\^rem\{/, + /\^rem\{/, /\}/, { relevance: 10, diff --git a/src/languages/perl.js b/src/languages/perl.js index 9ea76bef87..881e5fbcd1 100644 --- a/src/languages/perl.js +++ b/src/languages/perl.js @@ -5,6 +5,9 @@ Website: https://www.perl.org Category: common */ +import * as regex from '../lib/regex.js'; + +/** @type LanguageFn */ export default function(hljs) { var PERL_KEYWORDS = { $pattern: /[\w.]+/, @@ -40,7 +43,12 @@ export default function(hljs) { var VAR = { variants: [ {begin: /\$\d/}, - {begin: /[$%@](\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/}, + {begin: regex.concat( + /[$%@](\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/, + // negative look-ahead tries to avoid matching patterns that are not + // Perl at all like $ident$, @ident@, etc. + `(?![A-Za-z])(?![@$%])` + )}, {begin: /[$%@][^\s\w{]/, relevance: 0} ] }; diff --git a/src/languages/php.js b/src/languages/php.js index ef35c47f6c..203f579c60 100644 --- a/src/languages/php.js +++ b/src/languages/php.js @@ -13,7 +13,10 @@ Category: common export default function(hljs) { const VARIABLE = { className: 'variable', - begin: '\\$+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*' + begin: '\\$+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*' + + // negative look-ahead tries to avoid matching patterns that are not + // Perl at all like $ident$, @ident@, etc. + `(?![A-Za-z0-9])(?![$])` }; const PREPROCESSOR = { className: 'meta', @@ -71,7 +74,11 @@ export default function(hljs) { // Other keywords: // // - 'array abstract and as binary bool boolean break callable case catch class clone const continue declare default do double else elseif empty enddeclare endfor endforeach endif endswitch endwhile eval extends final finally float for foreach from global goto if implements instanceof insteadof int integer interface isset iterable list match new object or private protected public real return string switch throw trait try unset use var void while xor yield', + 'array abstract and as binary bool boolean break callable case catch class clone const continue declare ' + + 'default do double else elseif empty enddeclare endfor endforeach endif endswitch endwhile eval extends ' + + 'final finally float for foreach from global goto if implements instanceof insteadof int integer interface ' + + 'isset iterable list match|0 new object or private protected public real return string switch throw trait ' + + 'try unset use var void while xor yield', literal: 'false null true', built_in: // Standard PHP library: @@ -123,10 +130,14 @@ export default function(hljs) { }, { className: 'function', + relevance: 0, beginKeywords: 'fn function', end: /[;{]/, excludeEnd: true, illegal: '[$%\\[]', contains: [ hljs.UNDERSCORE_TITLE_MODE, + { + begin: '=>' // No markup, just a relevance booster + }, { className: 'params', begin: '\\(', end: '\\)', @@ -145,7 +156,10 @@ export default function(hljs) { }, { className: 'class', - beginKeywords: 'class interface', end: /\{/, excludeEnd: true, + beginKeywords: 'class interface', + relevance: 0, + end: /\{/, + excludeEnd: true, illegal: /[:($"]/, contains: [ {beginKeywords: 'extends implements'}, @@ -153,17 +167,18 @@ export default function(hljs) { ] }, { - beginKeywords: 'namespace', end: ';', + beginKeywords: 'namespace', + relevance: 0, + end: ';', illegal: /[.']/, contains: [hljs.UNDERSCORE_TITLE_MODE] }, { - beginKeywords: 'use', end: ';', + beginKeywords: 'use', + relevance: 0, + end: ';', contains: [hljs.UNDERSCORE_TITLE_MODE] }, - { - begin: '=>' // No markup, just a relevance booster - }, STRING, NUMBER ] diff --git a/src/languages/powershell.js b/src/languages/powershell.js index 5e80f4714d..98523c0d82 100644 --- a/src/languages/powershell.js +++ b/src/languages/powershell.js @@ -242,7 +242,7 @@ export default function(hljs) { ) }; - PS_METHODS.contains.unshift(PS_TYPE) + PS_METHODS.contains.unshift(PS_TYPE); return { name: 'PowerShell', diff --git a/src/languages/properties.js b/src/languages/properties.js index 5fcc92d00e..64cd341f69 100644 --- a/src/languages/properties.js +++ b/src/languages/properties.js @@ -11,7 +11,9 @@ export default function(hljs) { var WS0 = '[ \\t\\f]*'; var WS1 = '[ \\t\\f]+'; // delimiter - var DELIM = '(' + WS0+'[:=]'+WS0+ '|' + WS1 + ')'; + var EQUAL_DELIM = WS0+'[:=]'+WS0; + var WS_DELIM = WS1; + var DELIM = '(' + EQUAL_DELIM + '|' + WS_DELIM + ')'; var KEY_ALPHANUM = '([^\\\\\\W:= \\t\\f\\n]|\\\\.)+'; var KEY_OTHER = '([^\\\\:= \\t\\f\\n]|\\\\.)+'; @@ -39,8 +41,11 @@ export default function(hljs) { // key: everything until whitespace or = or : (taking into account backslashes) // case of a "normal" key { - begin: KEY_ALPHANUM + DELIM, returnBegin: true, + variants: [ + { begin: KEY_ALPHANUM + EQUAL_DELIM, relevance: 1 }, + { begin: KEY_ALPHANUM + WS_DELIM, relevance: 0 } + ], contains: [ { className: 'attr', diff --git a/src/languages/protobuf.js b/src/languages/protobuf.js index d4bf4e1353..13c88426ee 100644 --- a/src/languages/protobuf.js +++ b/src/languages/protobuf.js @@ -36,9 +36,9 @@ export default function(hljs) { end: /[{;]/, excludeEnd: true, keywords: 'rpc returns' }, - { - begin: /^\s*[A-Z_]+/, - end: /\s*=/, excludeEnd: true + { // match enum items (relevance) + // BLAH = ...; + begin: /^\s*[A-Z_]+(?=\s*=[^\n]+;$)/ } ] }; diff --git a/src/languages/python.js b/src/languages/python.js index 3840c57b62..3b7ef5ef98 100644 --- a/src/languages/python.js +++ b/src/languages/python.js @@ -254,6 +254,7 @@ export default function(hljs) { NUMBER, // eat "if" prior to string so that it won't accidentally be // labeled as an f-string as in: + { begin: /\bself\b/, }, // very common convention { beginKeywords: "if", relevance: 0 }, STRING, hljs.HASH_COMMENT_MODE, diff --git a/src/languages/r.js b/src/languages/r.js index b095333004..1c22f62ba4 100644 --- a/src/languages/r.js +++ b/src/languages/r.js @@ -7,6 +7,8 @@ Website: https://www.r-project.org Category: scientific */ +import * as regex from '../lib/regex.js'; + export default function(hljs) { // Identifiers in R cannot start with `_`, but they can start with `.` if it // is not immediately followed by a digit. @@ -15,10 +17,13 @@ export default function(hljs) { // handled in a separate mode. See `test/markup/r/names.txt` for examples. // FIXME: Support Unicode identifiers. const IDENT_RE = /(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/; + const SIMPLE_IDENT = /[a-zA-Z][a-zA-Z_0-9]*/; return { name: 'R', + // only in Haskell, not R + illegal: /->/, keywords: { $pattern: IDENT_RE, keyword: @@ -32,22 +37,22 @@ export default function(hljs) { // Primitive functions // These are all the functions in `base` that are implemented as a // `.Primitive`, minus those functions that are also keywords. - 'abs acos acosh all any anyNA Arg as.call as.character' + - 'as.complex as.double as.environment as.integer as.logical' + - 'as.null.default as.numeric as.raw asin asinh atan atanh attr' + - 'attributes baseenv browser c call ceiling class Conj cos cosh' + - 'cospi cummax cummin cumprod cumsum digamma dim dimnames' + - 'emptyenv exp expression floor forceAndCall gamma gc.time' + - 'globalenv Im interactive invisible is.array is.atomic is.call' + - 'is.character is.complex is.double is.environment is.expression' + - 'is.finite is.function is.infinite is.integer is.language' + - 'is.list is.logical is.matrix is.na is.name is.nan is.null' + - 'is.numeric is.object is.pairlist is.raw is.recursive is.single' + - 'is.symbol lazyLoadDBfetch length lgamma list log max min' + - 'missing Mod names nargs nzchar oldClass on.exit pos.to.env' + - 'proc.time prod quote range Re rep retracemem return round' + - 'seq_along seq_len seq.int sign signif sin sinh sinpi sqrt' + - 'standardGeneric substitute sum switch tan tanh tanpi tracemem' + + 'abs acos acosh all any anyNA Arg as.call as.character ' + + 'as.complex as.double as.environment as.integer as.logical ' + + 'as.null.default as.numeric as.raw asin asinh atan atanh attr ' + + 'attributes baseenv browser c call ceiling class Conj cos cosh ' + + 'cospi cummax cummin cumprod cumsum digamma dim dimnames ' + + 'emptyenv exp expression floor forceAndCall gamma gc.time ' + + 'globalenv Im interactive invisible is.array is.atomic is.call ' + + 'is.character is.complex is.double is.environment is.expression ' + + 'is.finite is.function is.infinite is.integer is.language ' + + 'is.list is.logical is.matrix is.na is.name is.nan is.null ' + + 'is.numeric is.object is.pairlist is.raw is.recursive is.single ' + + 'is.symbol lazyLoadDBfetch length lgamma list log max min ' + + 'missing Mod names nargs nzchar oldClass on.exit pos.to.env ' + + 'proc.time prod quote range Re rep retracemem return round ' + + 'seq_along seq_len seq.int sign signif sin sinh sinpi sqrt ' + + 'standardGeneric substitute sum switch tan tanh tanpi tracemem ' + 'trigamma trunc unclass untracemem UseMethod xtfrm', }, @@ -168,7 +173,10 @@ export default function(hljs) { begin: '%', end: '%' }, - + // relevance boost for assignment + { + begin: regex.concat(SIMPLE_IDENT, "\\s+<-\\s+") + }, { // escaped identifier begin: '`', diff --git a/src/languages/ruby.js b/src/languages/ruby.js index 818063e955..47763bf9e3 100644 --- a/src/languages/ruby.js +++ b/src/languages/ruby.js @@ -7,13 +7,17 @@ Contributors: Peter Leonov , Vasily Polovnyov > + // ?> var SIMPLE_PROMPT = "[>?]>"; + // irb(main):001:0> var DEFAULT_PROMPT = "[\\w#]+\\(\\w+\\):\\d+:\\d+>"; var RVM_PROMPT = "(\\w+-)?\\d+\\.\\d+\\.\\d(p\\d+)?[^>]+>"; @@ -197,18 +212,25 @@ export default function(hljs) { }, { className: 'meta', - begin: '^('+SIMPLE_PROMPT+"|"+DEFAULT_PROMPT+'|'+RVM_PROMPT+')', + begin: '^('+SIMPLE_PROMPT+"|"+DEFAULT_PROMPT+'|'+RVM_PROMPT+')(?=[ ])', starts: { end: '$', contains: RUBY_DEFAULT_CONTAINS } } ]; + COMMENT_MODES.unshift(IRB_OBJECT); + return { name: 'Ruby', aliases: ['rb', 'gemspec', 'podspec', 'thor', 'irb'], keywords: RUBY_KEYWORDS, illegal: /\/\*/, - contains: COMMENT_MODES.concat(IRB_DEFAULT).concat(RUBY_DEFAULT_CONTAINS) + contains: [ + hljs.SHEBANG({binary:"ruby"}), + ] + .concat(IRB_DEFAULT) + .concat(COMMENT_MODES) + .concat(RUBY_DEFAULT_CONTAINS) }; } diff --git a/src/languages/scheme.js b/src/languages/scheme.js index 715ac60608..f90c90f45b 100644 --- a/src/languages/scheme.js +++ b/src/languages/scheme.js @@ -116,6 +116,7 @@ export default function(hljs) { var NAME = { className: 'name', + relevance: 0, begin: SCHEME_IDENT_RE, keywords: KEYWORDS }; diff --git a/src/languages/shell.js b/src/languages/shell.js index 3a1bc033ad..2c713da19d 100644 --- a/src/languages/shell.js +++ b/src/languages/shell.js @@ -3,8 +3,10 @@ Language: Shell Session Requires: bash.js Author: TSUYUSATO Kitsune Category: common +Audit: 2020 */ +/** @type LanguageFn */ export default function(hljs) { return { name: 'Shell Session', @@ -12,9 +14,13 @@ export default function(hljs) { contains: [ { className: 'meta', - begin: '^\\s{0,3}[/\\w\\d\\[\\]()@-]*[>%$#]', + // We cannot add \s (spaces) in the regular expression otherwise it will be too broad and produce unexpected result. + // For instance, in the following example, it would match "echo /path/to/home >" as a prompt: + // echo /path/to/home > t.exe + begin: /^\s{0,3}[/~\w\d[\]()@-]*[>%$#]/, starts: { - end: '$', subLanguage: 'bash' + end: /[^\\](?=\s*$)/, + subLanguage: 'bash' } } ] diff --git a/src/languages/swift.js b/src/languages/swift.js index 7034f24f45..1b829584ee 100644 --- a/src/languages/swift.js +++ b/src/languages/swift.js @@ -50,7 +50,7 @@ export default function(hljs) { var OPTIONAL_USING_TYPE = { className: 'type', begin: '\\b[A-Z][\\w\u00C0-\u02B8\']*[!?]' - } + }; var BLOCK_COMMENT = hljs.COMMENT( '/\\*', '\\*/', @@ -156,7 +156,8 @@ export default function(hljs) { }, { beginKeywords: 'import', end: /$/, - contains: [hljs.C_LINE_COMMENT_MODE, BLOCK_COMMENT] + contains: [hljs.C_LINE_COMMENT_MODE, BLOCK_COMMENT], + relevance: 0 } ] }; diff --git a/src/languages/vbscript.js b/src/languages/vbscript.js index 8e5ab8ff92..a43f4e2c89 100644 --- a/src/languages/vbscript.js +++ b/src/languages/vbscript.js @@ -7,7 +7,40 @@ Website: https://en.wikipedia.org/wiki/VBScript Category: scripting */ +import * as regex from '../lib/regex.js'; + +/** @type LanguageFn */ export default function(hljs) { + const BUILT_IN_FUNCTIONS = ('lcase month vartype instrrev ubound setlocale getobject rgb getref string ' + + 'weekdayname rnd dateadd monthname now day minute isarray cbool round formatcurrency ' + + 'conversions csng timevalue second year space abs clng timeserial fixs len asc ' + + 'isempty maths dateserial atn timer isobject filter weekday datevalue ccur isdate ' + + 'instr datediff formatdatetime replace isnull right sgn array snumeric log cdbl hex ' + + 'chr lbound msgbox ucase getlocale cos cdate cbyte rtrim join hour oct typename trim ' + + 'strcomp int createobject loadpicture tan formatnumber mid ' + + 'split cint sin datepart ltrim sqr ' + + 'time derived eval date formatpercent exp inputbox left ascw ' + + 'chrw regexp cstr err').split(" "); + const BUILT_IN_OBJECTS = [ + "server", + "response", + "request", + // take no arguments so can be called without () + "scriptengine", + "scriptenginebuildversion", + "scriptengineminorversion", + "scriptenginemajorversion" + ]; + + const BUILT_IN_CALL = { + begin: regex.concat(regex.either(...BUILT_IN_FUNCTIONS), "\\s*\\("), + // relevance 0 because this is acting as a beginKeywords really + relevance:0, + keywords: { + built_in: BUILT_IN_FUNCTIONS.join(" ") + } + }; + return { name: 'VBScript', aliases: ['vbs'], @@ -18,22 +51,13 @@ export default function(hljs) { 'if then else on error option explicit new private property let get public randomize ' + 'redim rem select case set stop sub while wend with end to elseif is or xor and not ' + 'class_initialize class_terminate default preserve in me byval byref step resume goto', - built_in: - 'lcase month vartype instrrev ubound setlocale getobject rgb getref string ' + - 'weekdayname rnd dateadd monthname now day minute isarray cbool round formatcurrency ' + - 'conversions csng timevalue second year space abs clng timeserial fixs len asc ' + - 'isempty maths dateserial atn timer isobject filter weekday datevalue ccur isdate ' + - 'instr datediff formatdatetime replace isnull right sgn array snumeric log cdbl hex ' + - 'chr lbound msgbox ucase getlocale cos cdate cbyte rtrim join hour oct typename trim ' + - 'strcomp int createobject loadpicture tan formatnumber mid scriptenginebuildversion ' + - 'scriptengine split scriptengineminorversion cint sin datepart ltrim sqr ' + - 'scriptenginemajorversion time derived eval date formatpercent exp inputbox left ascw ' + - 'chrw regexp server response request cstr err', + built_in: BUILT_IN_OBJECTS.join(" "), literal: 'true false null nothing empty' }, illegal: '//', contains: [ + BUILT_IN_CALL, hljs.inherit(hljs.QUOTE_STRING_MODE, {contains: [{begin: '""'}]}), hljs.COMMENT( /'/, diff --git a/src/languages/yaml.js b/src/languages/yaml.js index f4257be176..35f9105670 100644 --- a/src/languages/yaml.js +++ b/src/languages/yaml.js @@ -153,7 +153,8 @@ export default function(hljs) { // sit isolated from other words { className: 'number', - begin: hljs.C_NUMBER_RE + '\\b' + begin: hljs.C_NUMBER_RE + '\\b', + relevance: 0 }, OBJECT, ARRAY, diff --git a/src/lib/mode_compiler.js b/src/lib/mode_compiler.js index d5012d1093..b8202d664d 100644 --- a/src/lib/mode_compiler.js +++ b/src/lib/mode_compiler.js @@ -2,7 +2,19 @@ import * as regex from './regex.js'; import { inherit } from './utils.js'; // keywords that should have no default relevance value -const COMMON_KEYWORDS = 'of and for in not or if then'.split(' '); +const COMMON_KEYWORDS = [ + 'of', + 'and', + 'for', + 'in', + 'not', + 'or', + 'if', + 'then', + 'parent', // common variable name + 'list', // common variable name + 'value' // common variable name +]; // compilation @@ -240,7 +252,7 @@ export function compileLanguage(language) { // TODO: We need negative look-behind support to do this properly /** - * Skip a match if it has a preceding or trailing dot + * Skip a match if it has a preceding dot * * This is used for `beginKeywords` to prevent matching expressions such as * `bob.keyword.do()`. The mode compiler automatically wires this up as a @@ -248,10 +260,9 @@ export function compileLanguage(language) { * @param {RegExpMatchArray} match * @param {CallbackResponse} response */ - function skipIfhasPrecedingOrTrailingDot(match, response) { + function skipIfhasPrecedingDot(match, response) { const before = match.input[match.index - 1]; - const after = match.input[match.index + match[0].length]; - if (before === "." || after === ".") { + if (before === ".") { response.ignoreMatch(); } } @@ -331,8 +342,8 @@ export function compileLanguage(language) { // or whitespace - this does no harm in any case since our keyword engine // doesn't allow spaces in keywords anyways and we still check for the boundary // first - mode.begin = '\\b(' + mode.beginKeywords.split(' ').join('|') + ')(?=\\b|\\s)'; - mode.__beforeBegin = skipIfhasPrecedingOrTrailingDot; + mode.begin = '\\b(' + mode.beginKeywords.split(' ').join('|') + ')(?!\\.)(?=\\b|\\s)'; + mode.__beforeBegin = skipIfhasPrecedingDot; } if (!mode.begin) mode.begin = /\B|\b/; cmode.beginRe = langRe(mode.begin); diff --git a/src/vendor/deep_freeze.js b/src/vendor/deep_freeze.js deleted file mode 100644 index c5ce3eb560..0000000000 --- a/src/vendor/deep_freeze.js +++ /dev/null @@ -1,21 +0,0 @@ -// https://github.com/substack/deep-freeze/blob/master/index.js -/** @param {any} obj */ -export default function deepFreeze(obj) { - Object.freeze(obj); - - var objIsFunction = typeof obj === 'function'; - - Object.getOwnPropertyNames(obj).forEach(function(prop) { - if (Object.hasOwnProperty.call(obj, prop) - && obj[prop] !== null - && (typeof obj[prop] === "object" || typeof obj[prop] === "function") - // IE11 fix: https://github.com/highlightjs/highlight.js/issues/2318 - // TODO: remove in the future - && (objIsFunction ? prop !== 'caller' && prop !== 'callee' && prop !== 'arguments' : true) - && !Object.isFrozen(obj[prop])) { - deepFreeze(obj[prop]); - } - }); - - return obj; -} diff --git a/test/api/index.js b/test/api/index.js index 0e4b596dcb..223fbc0e30 100644 --- a/test/api/index.js +++ b/test/api/index.js @@ -1,16 +1,17 @@ 'use strict'; describe('hljs', function() { - require('./ident'); - require('./underscoreIdent'); - require('./number'); - require('./cNumber'); + require('./autoDetection'); + require('./beginKeywords'); require('./binaryNumber'); - require('./starters'); + require('./cNumber'); + require('./fixmarkup'); require('./getLanguage'); - require('./autoDetection'); require('./highlight'); - require('./fixmarkup'); + require('./ident'); require('./keywords'); + require('./number'); require('./registerAlias'); + require('./starters'); + require('./underscoreIdent'); }); diff --git a/test/builds/rollup_import_via_commonjs.js b/test/builds/rollup_import_via_commonjs.js index ae5ead20a7..1399d0b514 100644 --- a/test/builds/rollup_import_via_commonjs.js +++ b/test/builds/rollup_import_via_commonjs.js @@ -1,5 +1,5 @@ // rollup.config.js -import commonjs from 'rollup-plugin-commonjs'; +import commonjs from '@rollup/plugin-commonjs'; export default { input: 'test/builds/package.js', diff --git a/test/detect/csharp/default.txt b/test/detect/csharp/default.txt index 14c36769c2..5302057983 100644 --- a/test/detect/csharp/default.txt +++ b/test/detect/csharp/default.txt @@ -9,6 +9,7 @@ namespace MyApplication { public static List JustDoIt(int count) { + Span numbers = stackalloc int[length]; Console.WriteLine($"Hello {Name}!"); return new List(new int[] { 1, 2, 3 }) } diff --git a/test/markup/llvm/simple.expect.txt b/test/markup/llvm/simple.expect.txt new file mode 100644 index 0000000000..71bc91b959 --- /dev/null +++ b/test/markup/llvm/simple.expect.txt @@ -0,0 +1,19 @@ +;; foooo +define i32 @mul_add(i32 %x, i32 %y, i32 %z) { + entry: + %tmp = mul i32 %x, %y + %tmp2 = add i32 %tmp, %z + %tmp3 = add i32 %tmp, 0 + ret i32 %tmp3 +} + +; Named metadata +!0 = !{i32 42, null, !"string"} +!foo = !{!0} + +; Some unnamed metadata nodes, which are referenced by the named metadata. +!0 = !{!"zero"} +!1 = !{!"one"} +!2 = !{!"two"} +; A named metadata. +!name = !{!0, !1, !2} diff --git a/test/markup/llvm/simple.txt b/test/markup/llvm/simple.txt new file mode 100644 index 0000000000..4e757192b7 --- /dev/null +++ b/test/markup/llvm/simple.txt @@ -0,0 +1,19 @@ +;; foooo +define i32 @mul_add(i32 %x, i32 %y, i32 %z) { + entry: + %tmp = mul i32 %x, %y + %tmp2 = add i32 %tmp, %z + %tmp3 = add i32 %tmp, 0 + ret i32 %tmp3 +} + +; Named metadata +!0 = !{i32 42, null, !"string"} +!foo = !{!0} + +; Some unnamed metadata nodes, which are referenced by the named metadata. +!0 = !{!"zero"} +!1 = !{!"one"} +!2 = !{!"two"} +; A named metadata. +!name = !{!0, !1, !2} diff --git a/test/markup/pgsql/dollar_strings.expect.txt b/test/markup/pgsql/dollar_strings.expect.txt index 52f584761a..978866a3a5 100644 --- a/test/markup/pgsql/dollar_strings.expect.txt +++ b/test/markup/pgsql/dollar_strings.expect.txt @@ -1,9 +1,9 @@ CREATE OR REPLACE FUNCTION hello_world(param_your_name text) RETURNS text AS -$$ -SELECT 'Hello world. My name is ' || param_your_name || '.'; +$$ +SELECT 'Hello world. My name is ' || param_your_name || '.'; $$ language sql STRICT; -SELECT sql_expression($sql$SELECT hello_world($phrase$Regina's elephant's dog$phrase$) - || $phrase$ I made a cat's meow today.$phrase$ $sql$); +SELECT sql_expression($sql$SELECT hello_world($phrase$Regina's elephant's dog$phrase$) + || $phrase$ I made a cat's meow today.$phrase$ $sql$); diff --git a/test/markup/shell/command-continuation.expect.txt b/test/markup/shell/command-continuation.expect.txt new file mode 100644 index 0000000000..83a2637b16 --- /dev/null +++ b/test/markup/shell/command-continuation.expect.txt @@ -0,0 +1,14 @@ +$ docker run \ + --publish=7474:7474 --publish=7687:7687 \ + --volume=/neo4j/data:/data \ + --volume=/neo4j/plugins:/plugins \ + --volume=/neo4j/conf:/conf \ + --volume=/logs/neo4j:/logs \ + --user="$(id -u neo4j):$(id -g neo4j)" \ + --group-add=$groups \ + neo4j:3.4 +> /bin/cat \.travis.yml\ + -b | head -n1 + 1 language: node_js +> echo 'hello' +hello diff --git a/test/markup/shell/command-continuation.txt b/test/markup/shell/command-continuation.txt new file mode 100644 index 0000000000..1c3a443c2e --- /dev/null +++ b/test/markup/shell/command-continuation.txt @@ -0,0 +1,14 @@ +$ docker run \ + --publish=7474:7474 --publish=7687:7687 \ + --volume=/neo4j/data:/data \ + --volume=/neo4j/plugins:/plugins \ + --volume=/neo4j/conf:/conf \ + --volume=/logs/neo4j:/logs \ + --user="$(id -u neo4j):$(id -g neo4j)" \ + --group-add=$groups \ + neo4j:3.4 +> /bin/cat \.travis.yml\ + -b | head -n1 + 1 language: node_js +> echo 'hello' +hello diff --git a/test/markup/shell/prompt-with-tilde.expected.txt b/test/markup/shell/prompt-with-tilde.expected.txt new file mode 100644 index 0000000000..57af2ff5de --- /dev/null +++ b/test/markup/shell/prompt-with-tilde.expected.txt @@ -0,0 +1,4 @@ +~/docs> cat readme.adoc += Highlight.js + +Highlight.js is a syntax highlighter written in JavaScript. diff --git a/test/markup/shell/prompt-with-tilde.txt b/test/markup/shell/prompt-with-tilde.txt new file mode 100644 index 0000000000..ddbfcf84e3 --- /dev/null +++ b/test/markup/shell/prompt-with-tilde.txt @@ -0,0 +1,4 @@ +~/docs> cat readme.adoc += Highlight.js + +Highlight.js is a syntax highlighter written in JavaScript. diff --git a/test/markup/shell/simple.expect.txt b/test/markup/shell/simple.expect.txt new file mode 100644 index 0000000000..8aa9c49e6f --- /dev/null +++ b/test/markup/shell/simple.expect.txt @@ -0,0 +1 @@ +> /bin/sh diff --git a/test/markup/shell/simple.txt b/test/markup/shell/simple.txt new file mode 100644 index 0000000000..8297a69a5c --- /dev/null +++ b/test/markup/shell/simple.txt @@ -0,0 +1 @@ +> /bin/sh diff --git a/test/markup/shell/single.expect.txt b/test/markup/shell/single.expect.txt new file mode 100644 index 0000000000..093bdaa908 --- /dev/null +++ b/test/markup/shell/single.expect.txt @@ -0,0 +1 @@ +$ echo "$HOME" -n diff --git a/test/markup/shell/single.txt b/test/markup/shell/single.txt new file mode 100644 index 0000000000..b05aae75fd --- /dev/null +++ b/test/markup/shell/single.txt @@ -0,0 +1 @@ +$ echo "$HOME" -n diff --git a/tools/build_config.js b/tools/build_config.js index a635762f64..9cb9cd2697 100644 --- a/tools/build_config.js +++ b/tools/build_config.js @@ -1,5 +1,6 @@ -const cjsPlugin = require('rollup-plugin-commonjs'); -const jsonPlugin = require('rollup-plugin-json'); +const cjsPlugin = require('@rollup/plugin-commonjs'); +const jsonPlugin = require('@rollup/plugin-json'); +const { nodeResolve } = require('@rollup/plugin-node-resolve'); module.exports = { build_dir: "build", @@ -12,6 +13,7 @@ module.exports = { plugins: [ cjsPlugin(), jsonPlugin(), + nodeResolve(), { transform: (x) => { if (/var module/.exec(x)) { @@ -25,7 +27,11 @@ module.exports = { }, browser_core: { input: { - plugins: [jsonPlugin()] + plugins: [ + jsonPlugin(), + cjsPlugin(), + nodeResolve() + ] }, output: { name: "hljs", @@ -54,6 +60,8 @@ module.exports = { ascii_only: true }, compress: { + ecma: 2015, + unsafe_arrows: true, passes: 2, unsafe: true, warnings: true, diff --git a/tools/developer.html b/tools/developer.html index 3ef72618a5..6a53a8abfd 100644 --- a/tools/developer.html +++ b/tools/developer.html @@ -57,7 +57,7 @@ } - +

Code

@@ -295,7 +295,7 @@

Markup

this.refreshKlass(); } } - }) + });