Skip to main content

Build Syntaxhighlighter on Windows 10


When I built the Syntaxhightlighter 4.0.1 on Windows 10 last week, I got errors.

After I read the discuss chain (link), I followed the post from MayaLekova to install "Windows Subsystem for Linux". And it really worked. The build results were same as those from my Mac mini.

Bash on ubuntu on Windows

Please follow Jack Hammons's "Installation guide" of "Bash on ubuntu on Windows".

Here I took a short note about what I had done:


1. Make sure the system is a 64-bit Windows 10.
2. From "Start" (開始按鈕) > "Settings" (設定) > "Update and Security" (更新與安全性)
We can turn the "Developer Mode" on.

(2.1) If there is a step asking you to reboot the computer, please wait until to the last step in this description.

After the "Developer Mode" is enabled and some software has been downloaded.

3. From "Start" (開始按鈕), search "Windows Features" (開啟或關閉 Windows 功能)

4. Select "Windows Subsystem for Linux (beta)" (適用於 Linux 的 Windows 子系統 (搶鮮版 (Beta))).
5. Click "OK" to install the "Windows Subsystem for Linux (beta)".

After the software is installed.
6. Open a PowerShell command window as administrator and execute the following command:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

7. Reboot the system, when the PowerShell command finished and prompted.

After the system has been rebooted.

8. Open a command line window and run "bash".

9. Please accept the license, and the Ubuntu user-mode image will be downloaded. A "Bash on Ubuntu on Windows" shortcut will be also added to the start menu.

10. You will be prompted to create a UNIX username and password, at the first time the Bash is installed. Please prepare your username and password.

11. Installation of "Windows Subsystem for Linux (beta)" is done.

Note:

  • How to launch Bash on Windows again: Run "bash" at a command line window or a PowerShell command line window, or just use the shortcut of "Bash on Ubuntu on Windows" on the start menu.


Node.js

Use bash to install Node 6.x. (I have tried the 8.x, it didn't work with Syntaxhighlighter)

1. Run the following commands on a bash command line window:


curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -

sudo apt-get install -y nodejs

Please refer to the web page: "Debian and Ubuntu based Linux distributions".


Syntaxhighlighter

To install and build Syntaxhighlighter, please refer to the web page: "Building".

The steps in the web page "Building" are listed here:

1. Open a bash command line window as administrator.

2. Make a directory for downloading the git source.

3. from the folder (just created), run the following commands to download and install Syntaxhighlighter:

git clone https://github.com/syntaxhighlighter/syntaxhighlighter.git

cd syntaxhighlighter

npm install


4. After the installation, run the following command to setup the project:

./node_modules/gulp/bin/gulp.js setup-project

5. Run the following command to build the "syntaxhighlighter.js" and "theme.css".

./node_modules/gulp/bin/gulp.js build --brushes=all --theme=default

Please refer to "Building syntaxhighlighter.js" for the parameters of "--brushes" and "--theme".

6. The output files can be found in the folder "./dist".

7. Done!


Adding a new brush

Please follow the web page "Making a Brush" to create a new brush.

To build Syntaxhighlighter with the new brush, you may run the following command.

./node_modules/gulp/bin/gulp.js build --brushes=base,cpp,javascript,./repos/brush-latex/brush.js,php,plain,python,xml --theme=default

This example "brush-latex" is installed/created in the folder of "syntaxhighlighter/repos". Please notice that, the parameter of the brush-latex: "./repos/brush-latex/brush.js". In this example there are some other brushes built together with brush-latex.

Above are my steps to build the Syntaxhighlighter on Windows 10.

Have fun!

Comments