https://github.com/parallax/filament-syntax-entry
Add a Filament infolist entry for themeable syntax highlighting using highlight.js
https://github.com/parallax/filament-syntax-entry
Last synced: 7 months ago
JSON representation
Add a Filament infolist entry for themeable syntax highlighting using highlight.js
- Host: GitHub
- URL: https://github.com/parallax/filament-syntax-entry
- Owner: parallax
- License: mit
- Created: 2024-02-02T11:24:34.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-27T11:20:52.000Z (10 months ago)
- Last Synced: 2025-06-30T00:11:20.840Z (7 months ago)
- Language: PHP
- Size: 1.83 MB
- Stars: 18
- Watchers: 3
- Forks: 6
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Filament Syntax Entry
[](https://packagist.org/packages/parallax/filament-syntax-entry)
[](LICENSE.md)
[](https://packagist.org/packages/parallax/filament-syntax-entry)

Add a Filament [infolist entry](https://filamentphp.com/docs/3.x/infolists/entries/getting-started) for themeable server-side syntax highlighting using [tempestphp/highlight](https://github.com/tempestphp/highlight).

## Installation
Install the package via composer:
```bash
composer require parallax/filament-syntax-entry
```
Optionally, you can publish the views using
```bash
php artisan vendor:publish --tag="filament-syntax-entry-views"
```
## Upgrading from 1.x
There are a couple of important changes to be aware of when upgrading to version 2.x:
- PHP 8.3 is required for server-side syntax highlighting
- Highlight.js is no longer supported
- Theme selection has been replaced with the ability to create custom themes
## Quickstart
### Add the [Infolist entry](https://filamentphp.com/docs/3.x/infolists/entries/getting-started)
Add the `SyntaxEntry` to the `$infolist->schema()` method.
```php
schema([
SyntaxEntry::make('metadata'),
]);
}
}
```
### Setting the language
The default language value is set to `json`. To override this value you may use the `language()` method:
```php
SyntaxEntry::make('metadata')
->language('json');
```
The following languages are currently available:
- `blade`
- `css`
- `gdscript`
- `html`
- `javascript`
- `json`
- `php`
- `sql`
- `twig`
- `xml`
- `yaml`
### Creating a custom theme
You may override the default theme by using the `theme()` method:
```php
SyntaxEntry::make('metadata')
->theme('smudge');
```
This will wrap the syntax component with a custom class like so:
```
syntax-entry-theme-smudge
```
The final step is to follow the [tempestphp/highlight](https://github.com/tempestphp/highlight) documentation on how to create your own theme, and use this in combination with [Filament themes](https://filamentphp.com/docs/3.x/panels/themes#creating-a-custom-theme).
## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Credits
- [Parallax](https://parall.ax)
- [Contributors](https://github.com/parallax/filament-syntax-entry/graphs/contributors)
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.