Files
gerrit/lib/highlightjs/building.md
Paladox none 873c8b25af Update highlight.js to head of master (10.0.2)
This fixes an issue where things were incorrectly highlighted after
the '/' symbol in javascript [1].

This also includes other fixes to the java language, c language
and php language.

[1] https://github.com/highlightjs/highlight.js/issues/2530

Bug: Issue 12726
Change-Id: I7fe08646e2698fc3f4e6025cf7a4201565a84635
2020-05-11 03:38:57 +00:00

1.7 KiB

Building Highlight.js for Gerrit

Highlight JS needs to be built with specific language support. Here are the steps to build the minified file that appears here.

NOTE: If you are adding support for a language to Highlight.js make sure to add it to the list of languages in the build command below.

Prerequisites

You will need:

  • nodejs
  • closure-compiler
  • git

Steps to Create the Pack File

The packed version of Highlight.js is an un-minified JS file with all of the languages included. Build it with the following:

$>  # start in some temp directory
$>  git clone https://github.com/highlightjs/highlight.js
$>  cd highlight.js
$>  git clone https://github.com/highlightjs/highlightjs-closure-templates
$>  ln -s ../../highlightjs-closure-templates/soy.js src/languages/soy.js
$>  mkdir test/detect/soy && ln -s ../../../highlightjs-closure-templates/test/detect/soy/default.txt test/detect/soy/default.txt
$>  npm install
$>  node tools/build.js -n

The resulting JS file will appear in the "build" directory of the Highlight.js repo under the name "highlight.pack.js".

Minification

Minify the file using closure-compiler using the command below.

$> wget https://dl.google.com/closure-compiler/compiler-latest.zip

$> unzip compiler-latest.zip

$> mv closure-compiler-*.jar closure-compiler.jar

$>  java -jar ./closure-compiler.jar \
        --js build/highlight.js \
        --js_output_file build/highlight.min.js

Copy the header comment that appears on the first line of build/highlight.pack.js and add it to the start of build/highlight.min.js.

Finish

Copy the resulting build/highlight.min.js file to lib/highlightjs