Search by

phil / svg-blocks-bundle

phil

Math, Mermaid, chart and QR code blocks in Symfony: drawn once and signed, rendered in documents, with a live preview and diagrams drawn in the background.

Package info

github.com/parler-haut-interagir-librement/svg-blocks-bundle

Homepage

Type:symfony-bundle

pkg:composer/phil/svg-blocks-bundle

Statistics

Installs: 0

Dependents: 0

Suggesters: 1

Stars: 0

Open Issues: 0

0.1.1-alpha 2026-12-01 22:00 UTC

This package is auto-updated.

Last update: 2026-12-02 03:16:16 UTC


README

Formulas, diagrams, charts and QR codes in Symfony block documents, drawn once on the server and shown everywhere.

phil/svg-blocks-bundle integrates phil/svg-blocks into Symfony. Every UJO (Universal JSON Output) document a form field receives — phil/ujo-bundle's UjoType, or the block editor's field — has its math, mermaid, chart and qrCode blocks drawn after it is checked, and each drawing is kept, signed, with its block. The HtmlRenderer of phil/ujo-bundle is decorated to write those drawings, so pages, EPUB files and PDFs show MathML and SVG without a script. A preview endpoint and its Stimulus controller show authors the drawing as they type.

Diagrams are drawn by a Mermaid service in a container, shipped in docker/mermaid — Node.js, Chromium and Mermaid behind a small HTTP server, as Gotenberg runs beside an application —, confined as its written security review requires. By default they are drawn in the background: the save lists them as pending, and a Messenger message that carries only the document's subject asks a handler to draw them through the application's MarkupDocuments port.

It is a Symfony bundle on phil/svg-blocks. Every service is the library's own class, declared under its class name.

Status

Part State
Configuration: secret, QR code level, chart size, formula limits and macro budget, Mermaid service, preview Implemented and tested
Formulas: every construction of phil/latex-mathml, macros, colours, links, numbers and chemistry among them Implemented and tested
StoredMarkupTypeExtension: the blocks of UjoType and the block editor's field drawn when submitted Implemented and tested
HtmlRenderer of phil/ujo-bundle decorated to write trusted drawings Implemented and tested
Preview endpoint, stateless CSRF, and its Stimulus controller, fetched lazily and mapped in AssetMapperBundle Implemented and tested; pure modules under Node
Background pass: RenderDeferredMarkup, its handler, MarkupScheduler, the MarkupDocuments port Implemented and tested
Mermaid service: security review, confined Dockerfile and compose file, HTTP server with queue, deadlines and size limits Implemented and tested under Node; image not built

Documentation

Document What it covers
Installation Requirements, enabling the bundle, the route, the controller, the service.
Configuration Every option, and the services it declares.
Forms and rendering What a field does to a submitted document, and how pages, EPUB and PDF show it.
Preview The endpoint, its checks, and the Stimulus controller.
Diagrams The Mermaid service, its image, and the background pass.
Extension points What an application may replace or add, and when it is stable.
Testing The PHP and Node tests, and testing an application that uses the bundle.
Reference Every class and module of the bundle, with its role.

Quick start

composer require phil/svg-blocks-bundle
# config/packages/phil_svg_blocks.yaml
phil_svg_blocks:
    mermaid:
        url: '%env(MERMAID_URL)%'
        documents: App\Content\ArticleDocuments
$builder->add('body', UjoType::class);     // math, chart and qrCode blocks drawn when submitted
// after the flush:
$scheduler->schedule('article:'.$article->getId());   // diagrams drawn in the background

Requirements

PHP 8.5 or later, Symfony 8.2, phil/svg-blocks. phil/ujo-bundle for the UJO fields and the renderer; Symfony HttpClient for the Mermaid service; Symfony Messenger for the background pass; Symfony's CSRF component for the preview; AssetMapper and the Stimulus bundle for the preview controller. Docker, or any container runtime, for the Mermaid service.

Contributing

Contributions are welcome on the PHIL monorepo: read the contribution guide and the code of conduct. Report a vulnerability privately, as the security policy explains, never in a public issue.

License

MIT, © Philippe Gamache, doing business as Le Gnome Archiviste; a Parler Haut Interagir Librement project. See LICENSE.