PHPackages                             mbolli/tempest-highlight-datastar - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. mbolli/tempest-highlight-datastar

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mbolli/tempest-highlight-datastar
=================================

Datastar language support for tempest/highlight — highlights data-\* attributes, $signals, @actions, and expressions.

v1.0.0(1w ago)02↓100%MITPHPPHP ^8.4

Since Mar 16Pushed 1w agoCompare

[ Source](https://github.com/mbolli/tempest-highlight-datastar)[ Packagist](https://packagist.org/packages/mbolli/tempest-highlight-datastar)[ RSS](/packages/mbolli-tempest-highlight-datastar/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (3)Versions (2)Used By (0)

Datastar Language Support for tempest/highlight
===============================================

[](#datastar-language-support-for-tempesthighlight)

[![Latest Version on Packagist](https://camo.githubusercontent.com/fdbba4e425587a0f9362428702a22df4514325eccae4986f24f0a5656ee3da05/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d626f6c6c692f74656d706573742d686967686c696768742d64617461737461722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mbolli/tempest-highlight-datastar)[![PHP Version](https://camo.githubusercontent.com/d577b6e61e1897285eee1bb964dc80f42cf1f22e3143c364470503eecc8f80a7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d626f6c6c692f74656d706573742d686967686c696768742d64617461737461722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mbolli/tempest-highlight-datastar)[![PHPStan Level 10](https://camo.githubusercontent.com/65c9bbcae389e4ca189f0239aa80ea655e986c4d7d4d586a15927056765c173f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c25323031302d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://phpstan.org/)[![License](https://camo.githubusercontent.com/376ef9fbd939ea9a17f2f6fbdbfc87419d0ebdc33822aff4740ee6bb419cfdc7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d626f6c6c692f74656d706573742d686967686c696768742d64617461737461722e7376673f7374796c653d666c61742d737175617265)](LICENSE)

[Datastar](https://data-star.dev/) syntax highlighting for [tempest/highlight](https://github.com/tempestphp/highlight) — highlights `data-*` attributes, `$signals`, `@actions`, and expressions in HTML code blocks.

Installation
------------

[](#installation)

```
composer require mbolli/tempest-highlight-datastar
```

Usage
-----

[](#usage)

### Register by name

[](#register-by-name)

Register the language once on your `Highlighter` instance, then use it by name:

```
use Mbolli\TempestHighlightDatastar\Html\DatastarHtmlLanguage;
use Tempest\Highlight\Highlighter;

$highlighter = new Highlighter();
$highlighter->addLanguage(new DatastarHtmlLanguage());

// Use by name or alias
$html = $highlighter->parse($code, 'datastar-html');
$html = $highlighter->parse($code, 'datastar');
```

Registering the language also overrides the built-in `html` language (via alias), so `parse($code, 'datastar-twig');
```

This also overrides the built-in `twig` language, so any code already highlighted as `'twig'` will gain Datastar support.

### PHP templates

[](#php-templates)

Since `DatastarHtmlLanguage` overrides the built-in `html` language, just highlight your PHP files as `'php'`. The `PhpHeredocInjection` resolves `
