Search by

vrana / jush

vrana

JUSH - JavaScript Syntax Highlighter

Package info

github.com/vrana/jush

Homepage

pkg:composer/vrana/jush

Statistics

Installs: 2 765 038

Dependents: 10

Suggesters: 0

Stars: 28

Open Issues: 0

v3.2.1 2026-09-07 21:00 UTC

This package is auto-updated.

Last update: 2026-10-23 13:34:04 UTC


README

Highlights the full stack of PHP application starting with HTML, PHP, SQL and JavaScript code and ending with HTTP headers, php.ini settings or database variables.

Features

  • Highlights and links documentation in spaghetti code like nothing else: <?php mysql_query("SELECT 1"); ?>
  • Supported languages: everything related to PHP: HTML5, JS, JSON, CSS 3, SQL including variables (multiple dialects), php.ini directives, HTTP and e-mail headers, Apache config. Anything could be embedded into each other, e.g. header("Content-Type: text/html") or color: expression(parentNode.style.color).
  • Allows using HTML tags in source code (could be used for pointing out important parts): echo "This part is <b>important</b>.". Produces overlapping HTML tags in this case though.
  • Performance is a priority.
  • <textarea> syntax highlight.

Installation instructions

  1. Copy jush.css and jush.js into your directory.

  2. Add following snippet before the </body> tag in HTML file:

    <script src="jush.js"></script>
    <script>
    jush.style('jush.css');
    jush.highlight_tag('code');
    </script>

    All <code class="jush"> tags will be highlighted. Language is determined by the class name beginning with "jush-" (e.g. <code class="jush-js">). Default language is htm. It is also possible to use <code class="language-*">.

  3. If you want to enable dark mode, call jush.style('jush-dark.css'). To enable it only based on user preferences, call jush.style('jush-dark.css', '(prefers-color-scheme: dark)').

Alternatively call jush.highlight(language, text) to syntax highlight single text.

jush.textarea(textarea, autocompleter, options) replaces a <textarea> by a highlighted editor which keeps the <textarea> value updated. Enter keeps the indentation of the line, { indent: false } in options turns it off. { tab: true } makes Tab insert a tab or indent the selected lines (Shift+Tab unindents, Escape and Tab moves the focus).

jush.mark_line(el, line) marks a line (counted from 1) of the highlighted code in el, e.g. a <pre> or the editor returned by jush.textarea(), which removes the mark when its text changes. If the line is scrolled out of el, it scrolls el (not the page) to it. jush.mark_line(el) removes it. The color is --mark-bg-color in jush.css.

Command-line help reference

It is also possible to use JUSH for opening the appropriate documentation in a browser:

Syntax: node jush-help.js filename line column [tabsize] [word]
Example: node jush-help.js demo.html 2 2

The example should open a browser with documentation of the <html> tag which is at position 2:2 of demo.html.

Updating language references

The update/ directory holds scripts which sync a language module's list of keywords, functions and classes from an upstream reference file. For example, update/php.php rebuilds the class and function lists in modules/jush-php.js from a php.api file (from scite-files):

php update/php.php path/to/php.api

update/sql.php rebuilds the MySQL/MariaDB lists in modules/jush-sql.js from the MySQL online manual (the index pages are cached in the given directory) and a checkout of mariadb-docs:

php update/sql.php path/to/mysql-cache path/to/mariadb-docs