Texy is a text-to-HTML engine for lightweight markup languages, written in PHP. It turns human-readable plain text into structurally valid HTML β complete with images, links, nested lists, and tables β no knowledge of HTML required.
Above all, Texy is an engine. It ships with its own rich, easy-to-read markup, but nothing about that syntax is set in stone: every rule can be switched on or off, redefined, or extended with your own. You can reshape Texy to speak a different dialect entirely β and one of them already exists, see Markdown below.
And Texy is a typographer at heart. It swaps straight quotes for typographically correct ones, hyphens for dashes, the letter x for the dimension sign, and applies many more refinements so your text reads like it was professionally typeset.
Install Texy via Composer:
composer require texy/texy
Texy requires PHP 8.4 or higher with the mbstring extension; generated IDs of headings need the intl extension too.
$texy = new Texy\Texy;
$html = $texy->toHtml($text);
For untrusted input, always enable safe mode, which restricts the output to a safe subset of HTML:
Texy\Configurator::safeMode($texy);
$html = $texy->toHtml($text);
texy/markdown is a companion package that parses CommonMark and GitHub Flavored Markdown β the whole specification, all five extensions β into this same AST:
composer require texy/markdown
$markdown = Texy\Markdown\Markdown::gfm(config: $texy->config, htmlOutput: $texy->htmlOutput);
$html = $markdown->toHtml($text);
Because the tree is the same one, a Markdown document goes out through the renderer above and gets everything Texy does to a Texy one: typography, HTML sanitization, well-forming, Latte integration. The package renders a Texy AST back to Markdown as well, so converting between the two languages is a matter of picking a parser and a renderer.
The full manual is on the homepage https://texy.deegee.dev. The docs/ directory holds the reference for using and extending Texy:
- Syntax reference β complete reference of the Texy markup language, including syntaxes that are disabled by default
- Configuration β all configuration options, the
Configuratorpresets, and security (safe mode) - Custom handlers β changing the behavior of existing constructs via renderer handlers and AST passes
- Custom syntax β adding brand-new markup constructs
- Upgrading β migration guide from Texy 3
The examples/ directory contains ready-to-run demos.
Do you like Texy? Are you looking forward to the new features?
Thank you!