From 6e7e81f58afe134b8c6e342b4adb81372d5c9f9b Mon Sep 17 00:00:00 2001 From: FJMax Date: Sun, 3 Oct 2021 17:03:16 +0800 Subject: [PATCH 1/2] How to add unsupported language. --- README.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/README.md b/README.md index 0d2d763..a143cf1 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,57 @@ Syntax highlighting for Dart and Flutter, which supports lots of languages and t - [All available languages](https://github.com/pd4d10/highlight/tree/master/highlight/lib/languages) - [All available themes](https://github.com/pd4d10/highlight/blob/master/flutter_highlight/lib/themes) +## How to add unsupported language + +1. Install nodejs and gulp. +Highlight.dart uses [nodejs](https://nodejs.org/en/) and [gulp](https://gulpjs.com/) from command line to generate language definition files, so please install nodejs and gulp-cli. + +2. make sure your language is [supported by highlight.js](https://github.com/highlightjs/highlight.js/blob/main/SUPPORTED_LANGUAGES.md). +3. add your supported language repository as git submodule under `vendor` folder + **Note:** if the `[language].js` file are not in root directory, please move it to root directory of your `vendor/highlightjs-[language]`. +4. edit `tool/highlight.js` function allModes`: +for exmaple, given I'm trying to add support for GDScript: +```javascript +export function allModes(){ +... + const items = [ + ...dirs.map(file => ({ + name: path.basename(file, path.extname(file)), + factory: require(path.resolve(dir, file)), + community: false + })), + { + name: "vue", + factory: require("../vendor/highlightjs-vue/vue").definer, + community: true + }, + { + name: "graphql", + factory: require("../vendor/highlightjs-graphql").definer, + community: true + }, + { + name: "gn", + factory: require("../vendor/highlightjs-GN").definer, + community: true + }, + { + name: "solidity", + factory: require("../vendor/highlightjs-solidity").definer, + community: true + }, // <- don't forget the comma! + /* Below are appended lines*/ + { + name: "gdscript", + factory: require("../vendor/highlightjs-gdscript").definer, + community: true + } + /* append end */ + ]; + ... +``` +5. change your working directory to `tool` and run gulp in command line. + ## License MIT From 951f754fd997ce439f85ab018608fc60aedf2618 Mon Sep 17 00:00:00 2001 From: FJMax Date: Mon, 4 Oct 2021 16:54:11 +0800 Subject: [PATCH 2/2] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a143cf1..fd1a1bd 100644 --- a/README.md +++ b/README.md @@ -18,11 +18,11 @@ Syntax highlighting for Dart and Flutter, which supports lots of languages and t ## How to add unsupported language 1. Install nodejs and gulp. -Highlight.dart uses [nodejs](https://nodejs.org/en/) and [gulp](https://gulpjs.com/) from command line to generate language definition files, so please install nodejs and gulp-cli. +Highlight.dart uses [nodejs](https://nodejs.org/en/) and [gulp](https://gulpjs.com/) from command line to generate language syntax definition files, so please install nodejs and gulp-cli. 2. make sure your language is [supported by highlight.js](https://github.com/highlightjs/highlight.js/blob/main/SUPPORTED_LANGUAGES.md). 3. add your supported language repository as git submodule under `vendor` folder - **Note:** if the `[language].js` file are not in root directory, please move it to root directory of your `vendor/highlightjs-[language]`. + **Note:** if the `main` key's value of `pacakge.json` in your language repository does not exists, please correct it(and then create a PR to the repository) or the syntax definition file won't be generated. 4. edit `tool/highlight.js` function allModes`: for exmaple, given I'm trying to add support for GDScript: ```javascript @@ -64,7 +64,7 @@ export function allModes(){ ]; ... ``` -5. change your working directory to `tool` and run gulp in command line. +5. change your working directory to `tool` and run gulp in command line, and then use `dart format [your directory]` command to format generated dart files. ## License