Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Text Formatter Laravel Package

s9e/text-formatter

PHP text formatting library with plugin support for BBCode, Markdown, HTML, and more. Includes predefined bundles, extensive documentation, and a JavaScript port for client-side preview and demos. Install via Composer and integrate customizable parsing/rendering.

View on GitHub
Deep Wiki
Context7

In addition to the default XSLT renderer, it is possible to compile templates to native PHP. You will need a writable directory to save the compiled template as a PHP file.

$configurator->rendering->engine = 'PHP';
$configurator->rendering->engine->cacheDir = '/path/to/dir';

A class name is automatically generated for the renderer class, based on its content. Alternatively, you can specify a class name by setting the className property. The class name and file name of the last generated renderer instance can be accessed via the renderer generator.

$configurator = new s9e\TextFormatter\Configurator;
$configurator->rendering->engine           = 'PHP';
$configurator->rendering->engine->cacheDir = '/tmp';

extract($configurator->finalize());
echo 'Default: ', get_class($renderer), "\n";

$configurator->rendering->engine->className = 'MyRenderer';
extract($configurator->finalize());
echo 'Custom:  ', get_class($renderer), "\n\n";

echo 'Last class: ', $configurator->rendering->engine->lastClassName, "\n";
echo 'Last file:  ', $configurator->rendering->engine->lastFilepath;
Default: Renderer_42d42900e1fe70a3dfadc1c19ebcd948e925d8ba
Custom:  MyRenderer

Last class: MyRenderer
Last file:  /tmp/MyRenderer.php

PHP renderer limitations

Not every XSL element and XPath function is supported by the PHP renderer. One way to detect unsupported templates early in the configuration is to enable the DisallowUncompilableXSL template check.

$configurator = new s9e\TextFormatter\Configurator;

// Add the DisallowUncompilableXSL check
$configurator->templateChecker->append('DisallowUncompilableXSL');

// Create a BBCode with an unsupported element
try
{
	$configurator->BBCodes->addCustom('[x]', '<xsl:processing-instruction name="foo"/>');
}
catch (RuntimeException $e)
{
	echo get_class($e), ': ', $e->getMessage();
}
RuntimeException: xsl:processing-instruction elements are not supported
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours