# Arx Syntax

A lightweight jQuery syntax highlighter for code blocks. Auto-detects language or set it explicitly.

## Installation

```html
<link rel="stylesheet" href="css/syntax.css">
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script src="js/syntax.js"></script>
```

## Basic Usage

```js
$('pre code').syntax();
```

```html
<pre><code class="language-js">
function greet(name) {
    return `Hello, ${name}!`;
}
</code></pre>
```

## Auto-Detection

If no language is specified, the plugin detects from:
- `class="language-js"` or `class="lang-css"` on the `<code>` or `<pre>`
- `data-lang="bash"` attribute
- Content heuristics (JSON starts with `{`, bash starts with `#!`, etc.)

## Explicit Language

```html
<pre><code data-lang="bash">
npm install && npm run build
</code></pre>
```

```js
$('pre code').syntax({ language: 'js' });
```

## Supported Languages

| Language | Key | Tokens highlighted |
|----------|-----|--------------------|
| HTML | `html` | Tags, attributes, values, comments, entities, doctype |
| CSS | `css` | Selectors, properties, values, units, at-rules, pseudo-classes, `var()` |
| JavaScript | `js` | Keywords, built-ins, strings, numbers, regex, comments |
| JSON | `json` | Strings, numbers, booleans, null, punctuation |
| Bash | `bash` | Commands, keywords, flags, variables, strings, comments |

## Options

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `language` | `string` | `null` | Force language. `null` = auto-detect |
| `lineNumbers` | `boolean` | `false` | Show line numbers (excluded from copy-paste via `user-select: none`) |
| `showLang` | `boolean` | `false` | Add `data-lang` to highlighted blocks |
| `copyButton` | `boolean` | `false` | Add a Copy button to the code block |

## API

```js
ArxSyntax.highlight(el, 'js');    // Highlight a single element
ArxSyntax.languages();            // ["html", "css", "js", "json", "bash"]
```

## Files

- `css/syntax.css` — Code block wrapper and token color styles
- `js/syntax.js` — jQuery plugin with tokenizer engine and language definitions
