# Name

mkhigh - highlight code blocks

# Synopsis

```
[flags] [options]
```

# Options

+ `-o, --out=[VAL] {=html}` Set output format
+ `-s, --src=[LANG]` Source language (overrides info string)
+ `--alias-[NAME]=[VAL...]` Alias info strings to source languages
+ `-l, --lines` Number lines in output
+ `-p, --preserve` Keep code elements
+ `-h, --help` Display help and exit
+ `--version` Print the version and exit

# Description

For each code block in the stream with an info string attempt to convert the code to a highlighted version using source-highlight(1). If source-highlight(1) returns an exit status other than zero the code block is passed through untouched.

If the `--src` option is given all code blocks are converted using the source language specified (info strings are ignored) otherwise the source language is inferred from the code block info string.

When the `--src` option is given it is not required that a code block have an info string, all code blocks will be highlighted using the source language given.

The default output format is `html` which generates HTML suitable for a standalone page (no stylesheet required) otherwise you can use the `html-css` output format and supply a stylesheet for the highlighted markup.

When the output is `html` or `html-css` the HTML comment generated by source-highlight(1) is removed.

If you want the output to include a `<code>` element within the `<pre>` use the `--preserve` option in this instance the code element is given a class name including the info string language:

```html
<pre><code class="language-javascript"></code></pre>
```

To see the source languages available to the `--src` option:

```shell
source-highlight --lang-list
```

For output formats available to the `--out` option run:

```shell
source-highlight --outlang-list
```

# Alias

Sometimes you may have a document containing info strings that do not match an available language in which case you can pass an alias to create the mapping, for example if your info string were declared as `typescript` you could map if to the `javascript` source language with:

```shell
mkcat README.md | mkhigh --alias-typescript=javascript -o esc | mkout
```

Aliases have no effect when the `--src` option is given.

<? @include {=include} mkhighlight-example.md ?>

# See Also

mkpage(1), source-highlight(1)
