FSHL is a free, open source, universal, fast syntax highlighter written in PHP.

Maintainers

Details

github.com/oschildt/fshl

Source

Installs: 4

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 8

Language:HTML

pkg:composer/smartfactory/fshl

1.0.0 2025-11-25 15:58 UTC

This package is auto-updated.

Last update: 2025-11-25 16:16:52 UTC


README

FSHL is a free, open source, universal, fast syntax highlighter written in PHP. A very fast parser performs syntax highlighting for few languages and produces a HTML output.

FSHL library is a simple, easy to use syntax highlighter. Its API provides only one method that is really need to highlight sources and three auxiliary methods to sets lexer and output mode.

FSHL core is very flexible and it is very easy to add new languages. Feel free to do so and do not forget to share them with the rest of the world.

Installation

composer require "smartfactory/fshl"

Example

	<?php
	$highlighter = new \FSHL\Highlighter(new \FSHL\Output\Html());
	$highlighter->setLexer(new \FSHL\Lexer\Php());
	echo '<pre>';
	echo $highlighter->highlight('<?php echo "Hello world!"; ?>');
	echo '</pre>';
	?>

Or

	<?php
	$highlighter = new \FSHL\Highlighter(new \FSHL\Output\Html(), \FSHL\Highlighter::OPTION_TAB_INDENT | \FSHL\Highlighter::OPTION_LINE_COUNTER);
	echo '<pre>';
	echo $highlighter->highlight('<?php echo "Hello world!"; ?>', new \FSHL\Lexer\Php());
	echo '</pre>';
	?>

Stylesheet

A nice default stylesheet is located in the style.css file.

Requirements

FSHL22 requires PHP 8.4 or later.

Authors