Texy! is sexy!

Texy is a powerful and secure markup processor for PHP that converts simple text into valid HTML. Unlike other markup languages, Texy isn't just another Markdown variant – it's a fully configurable system that you can adapt to virtually any syntax.

Why Texy?

Security as a Priority

Texy is designed with security in mind. It automatically protects against XSS attacks, validates URLs, and filters dangerous HTML tags. The built-in safeMode() is ideal for processing user-generated content in comments or forums.

Texy\Configurator::safeMode($texy);
// Texy is now safe for user-generated content

Full Configurability

Want to use Markdown syntax? Or need completely custom markup? Texy can handle it. You can:

  • Disable or enable any parts of the syntax
  • Change default behavior using handlers
  • Add entirely custom syntax elements
  • Configure Texy to process Markdown or any other format
$texy = new Texy;
$texy->allowed['image'] = false; // disable images
$texy->allowed['phrase/strong'] = false; // disable bold text

Advanced Typography

Texy provides sophisticated typographic processing that can be tailored to different languages. Depending on the configured locale, it automatically:

  • Inserts non-breaking spaces after single-letter prepositions and conjunctions
  • Applies word hyphenation according to syllable rules
  • Uses proper typographic quotation marks based on language conventions
  • Applies proper dash and hyphen distinction: 10–15 (dash) vs. multi-word (hyphen)
  • Adds non-breaking spaces in phone numbers: +420 776 552 046

Valid and Well-Formed HTML

Texy always generates valid HTML5 code. It automatically corrects improperly nested tags, closes unclosed elements, and ensures proper document structure. The output is not only valid but also beautifully formatted with proper indentation.

What is Texy?

Texy is a general-purpose markup text processor. While it has its default syntax (similar to Markdown but much richer), you can completely change or extend it.

It's not just a parser – Texy is a comprehensive system with modular architecture, where each module processes a specific part of the syntax (headings, links, images, tables…). Thanks to the handler system, you can intervene at any point in the processing and modify the result according to your needs.

Texy vs. Markdown

The basic syntax is similar, but Texy offers much more:

Feature Markdown Texy
Bold text **text** **text**
Italic *text* or _text_ *text* or //text//
Headings # Heading # Heading or underline
Images ![alt](url) [* url *]
Tables limited full support including merging
Modifiers no yes – .{color:red}[class]
Typography no yes – quotes, dashes, spaces
Word hyphenation no yes – by syllables
Configurability limited complete – custom syntax
Security depends on impl. built-in (safeMode)

Example of differences:

Markdown:
![Image](image.jpg)

Texy:
[* image.jpg 300x200 .(Image caption)[photo] <]

Texy allows you to define dimensions, classes, alignment, and much more directly in the syntax.

When to Use Texy?

Texy is ideal for:

CMS systems Need to safely process content from editors? Texy offers granular control over what users can use.

Blogs and documentation Rich syntax for tables, images with captions, typography, and code with syntax highlighting.

Comments and discussion forums SafeMode ensures users cannot insert dangerous code while still having text formatting available.

Projects with custom requirements Need to embed YouTube videos? Special syntax for your macros? Custom markup language? With Texy, you can create it easily.

History

Texy was created by David Grudl 20 years ago in 2004 as one of the first markup processors for PHP. Originally developed for PHP 4, it has undergone many updates throughout its long history and today fully leverages all the capabilities of PHP 8.

Over two decades of active development mean a proven and stable library trusted by hundreds of projects. Texy is now a mature solution with extensive history, yet still actively maintained and modern.