Installation Add the bundle via Composer:
composer require avtonom/creole-bundle
Enable it in config/bundles.php:
return [
// ...
Avtonom\CreoleBundle\AvtonomCreoleBundle::class => ['all' => true],
];
First Use Case Parse and render Creole markup in a Twig template:
{{ creole('== Headline ==\nThis is *bold* and //italic// text.')|raw }}
Requires Twig integration (included by default).
Avtonom\CreoleBundle\Parser\Parser – Core logic for converting Creole to a tree structure.Avtonom\CreoleBundle\Renderer\XhtmlRenderer (default, outputs HTML).Avtonom\CreoleBundle\Renderer\LatexRenderer (experimental, outputs LaTeX).Avtonom\CreoleBundle\Twig\CreoleExtension – Bridge for Twig templates./tests/ – Reference implementations and edge cases.Parse Markup
$parser = $container->get('avtonom_creole.parser');
$tree = $parser->parse('== Headline ==\n* List item');
Creole\Tree\Node object (serializable via Serializable).Render Output
$renderer = $container->get('avtonom_creole.xhtml_renderer');
$html = $renderer->render($tree);
Object field).Twig Integration
{% set creoleContent = creole('== Headline ==') %}
<div>{{ creoleContent|raw }}</div>
|raw to avoid HTML escaping.Custom Renderers
Extend Avtonom\CreoleBundle\Renderer\AbstractRenderer:
class MarkdownRenderer extends AbstractRenderer {
public function renderNode(Node $node) { ... }
}
Register as a service:
services:
app.creole.markdown_renderer:
class: App\Renderer\MarkdownRenderer
tags: ['avtonom_creole.renderer']
Caching Parsed Trees Store serialized trees in Doctrine:
$serialized = serialize($tree);
$entity->setCreoleContent($serialized); // Doctrine `Object` field
Retrieve and render later:
$tree = unserialize($entity->getCreoleContent());
$renderer->render($tree);
Validation Use the parser’s exception handling:
try {
$tree = $parser->parse($markup);
} catch (\RuntimeException $e) {
// Handle invalid Creole
}
Unmaintained Status
LaTeX Renderer Limitations
pdflatex issues.Serialization Caveats
Serializable, but ensure the Doctrine Object field is large enough.Twig Auto-escaping
Always use |raw in Twig to prevent HTML escaping:
{{ creole('*bold*')|raw }}
Inspect Tree Structure Dump the parsed tree to verify nodes:
var_dump($tree->getChildren());
Validate Markup Test with the Creole 1.0 spec. Example edge cases:
// Nested lists
* Item 1
** Subitem
* Item 2
// Mixed formatting
== Heading with //italic// and *bold* ==
Performance
Add New Markup Rules
Extend the lexer (Avtonom\CreoleBundle\Lexer\Lexer) or parser to support custom syntax.
Integrate with Forms Use the parser in Symfony forms for rich-text input:
$builder->add('content', TextType::class, [
'attr' => ['class' => 'creole-editor'],
]);
API Endpoints Expose parsing/rendering via a controller:
$tree = $parser->parse($request->request->get('markup'));
return new Response($renderer->render($tree));
How can I help you explore Laravel packages today?