Torchlight.dev — The VS Code Compatible Syntax Highlighting API.

Highlighting Lines

The highlight annotation will pull the line highlight background color from your chosen theme, and apply it to the background of the line, drawing focus to that specific line:

1return [
2 'extensions' => [
3 // Add attributes straight from markdown. [tl! highlight:1]
4 AttributesExtension::class,
5
6 // Add Torchlight syntax highlighting.
7 TorchlightExtension::class,
8 ]
9]
1return [
2 'extensions' => [
3 // Add attributes straight from markdown.
4 AttributesExtension::class,
5 
6 // Add Torchlight syntax highlighting.
7 TorchlightExtension::class,
8 ]
9]

It also applies a line-highlight class to the line.

If you have any lines highlighted, Torchlight will add a has-highlight-lines class to your code tag.

Every theme is different in the way that it chooses to represent highlighted lines, so be sure to try a few out.

Ranges

The highlight annotation supports the entire set of range modifiers to help you quickly annotate a whole set of lines.

Check out the range docs for more details, but here is a quick cheat sheet.

1highlight -- This line only
2
3highlight:start -- The start of an open ended range
4highlight:end -- The end of an open ended range
5
6highlight:10 -- This line, and the 10 following lines
7highlight:-10 -- This line, and the 10 preceding lines
8
9highlight:1,10 -- Start one line down, highlight 10 lines total
10highlight:-1,10 -- Start one line up, highlight 10 lines total

Alternative

If you don't like the highlight color that your theme uses, you can apply a custom class instead, e.g. .highlight or .foobar:

1return [
2 'extensions' => [
3 // Add attributes straight from markdown. [tl! .highlight]
4 AttributesExtension::class,
5
6 // Add Torchlight syntax highlighting. [tl! .foobar.bazbuz]
7 TorchlightExtension::class,
8 ]
9]

Shorthand

If you find typing highlight prohibitively slow (who has the time?), you can use ~~ as a shorthand.

1return [
2 'extensions' => [
3 // Add attributes straight from markdown. [tl! ~~:1]
4 AttributesExtension::class,
5
6 // Add Torchlight syntax highlighting.
7 TorchlightExtension::class,
8 ]
9]
1return [
2 'extensions' => [
3 // Add attributes straight from markdown.
4 AttributesExtension::class,
5 
6 // Add Torchlight syntax highlighting.
7 TorchlightExtension::class,
8 ]
9]
A Hammerstone, LLC Product.
Built with Love & Care by Aaron in Dallas, Texas.