dg / texy
📜 Texy: a text-to-HTML engine with its own easy-to-read markup, which you can change or extend, and real typography with proper quotes, dashes and non-breaking spaces. Always valid, sanitized HTML.
Requires
- php: 8.1 - 8.6
Requires (Dev)
- latte/latte: ^3.0.14
- nette/phpstan-rules: ^1.0
- nette/tester: ^2.5
- phpstan/extension-installer: ^1.4@stable
- phpstan/phpstan: ^2.3@stable
- tracy/tracy: ^2.9
Suggests
None
Provides
None
Conflicts
- latte/latte: >=3.0.0 <3.0.14
Replaces
- dg/texy: *
- dev-master / 4.0.x-dev
- v3.2.x-dev
- v3.2.10
- v3.2.9
- v3.2.8
- v3.2.7
- v3.2.6
- v3.2.5
- v3.2.4
- v3.2.3
- v3.2.2
- v3.2.1
- v3.2.0
- v3.1.x-dev
- v3.1.8
- v3.1.7
- v3.1.6
- v3.1.5
- v3.1.4
- v3.1.3
- v3.1.2
- v3.1.1
- v3.1.0
- v3.0.1
- v3.0.0
- v2.x-dev
- v2.9.3
- v2.9.2
- v2.9.1
- v2.9.0
- v2.8.2
- v2.8.1
- v2.8
- v2.7.1
- v2.7
- v2.6
- v2.5.1
- v2.5
- v2.4
- v2.3
- v2.2
- dev-wip3
This package is auto-updated.
Last update: 2026-11-12 02:59:13 UTC
README
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.
Usage
$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);
Markdown
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.
Documentation and Examples
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.
Support Me
Do you like Texy? Are you looking forward to the new features?
Thank you!