S9etextformatter
A PHP and JavaScript text formatting library for converting BBCode, Markdown, and HTML with plugins and security features.
What it is
s9e\TextFormatter is an open-source text formatting library designed for developers working with user-generated content. It provides robust tools to parse and convert various markup languages like BBCode, Markdown, and HTML into safe, formatted output. The library includes built-in plugins for common needs such as auto-linking URLs, embedding media, and censoring words, while also allowing extensive customization through custom rules and templates.
Key features include a powerful system for defining parsing rules, filtering content to prevent security issues like XSS attacks, and supporting federated media embeds from popular platforms. It offers both a PHP backend for server-side processing and a JavaScript port for real-time client-side previews, making it ideal for forums, comment systems, or any application requiring rich text input.
The library is highly extensible, enabling developers to create their own BBCodes, add custom emoticons, or even build entirely new plugins. Its templating system allows for fine-grained control over the generated HTML, ensuring output is both secure and stylistically consistent with the rest of the application.
s9e\TextFormatter is notable for its focus on security and performance, providing whitelists, blacklists, and configurable options to restrict unwanted content. It is widely used in developer communities and open-source projects for its reliability and comprehensive documentation.
This description was generated by AI from the site's public content and may contain errors.
What you can do there
- Convert BBCode, Markdown, and HTML to formatted text
- Use predefined bundles for common formatting needs
- Create custom tags and plugins for extended functionality
- Configure security settings to whitelist or blacklist content
- Utilize JavaScript for client-side text preview
Who it's for
Developers building applications with user-generated content like forums or comment systems
Frequently asked questions about s9etextformatter.readthedocs.io
›What is s9e\TextFormatter?
It is a PHP library that formats text using BBCode, Markdown, or HTML through a plugin system, with a JavaScript version available for live previews.
›How does it handle security?
It includes features like content filtering, host whitelisting, and template normalization to prevent XSS attacks and ensure safe HTML output.
›Can I add custom BBCodes?
Yes, the library allows you to define custom BBCodes with specific syntax and templates to extend its formatting capabilities.
›Does it support media embeds?
Yes, via its MediaEmbed plugin, it supports embedding content from sites like YouTube and allows adding custom sites.
›Is there a way to preview formatted text?
The JavaScript port enables live preview of formatted text on the client side before submitting to the server.
›What markup languages does it support?
It supports BBCode, Markdown, HTML, and other markups through plugins, making it versatile for different use cases.
›How do I get started with the library?
Install it via Composer, set up autoloading, and refer to the provided documentation for examples and configuration guides.
