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
Markdown Extra

Markdown Extra Laravel Package

twig/markdown-extra

Twig extension adding Markdown conversion filters: markdown_to_html to render Markdown as HTML, and html_to_markdown to convert HTML back to Markdown. Useful for templating content workflows where Markdown and HTML need to interoperate.

View on GitHub
Deep Wiki
Context7

twig/markdown-extra is a Twig extension that adds seamless Markdown ↔ HTML conversion to your templates. It’s ideal for rendering user-generated content or transforming existing HTML into editable Markdown without leaving the Twig ecosystem.

Use built-in filters to keep presentation logic simple while supporting common content workflows.

  • markdown_to_html filter to render Markdown blocks as HTML
  • html_to_markdown filter to convert HTML back into Markdown
  • Works directly inside Twig templates with minimal setup
  • Helpful for CMS-like content pipelines and preview/edit flows
Frequently asked questions about Markdown Extra
Can I use twig/markdown-extra in Laravel without Twig?
No, this package requires Twig as a dependency. Laravel projects using Blade will need a Twig bridge like `tightenco/jigsaw`, but alternatives like `cebe/markdown` or Laravel’s native `Str::markdown()` are simpler and Blade-compatible.
Is twig/markdown-extra safe for user-generated Markdown content?
No, it lacks built-in sanitization, exposing XSS risks when converting Markdown to HTML. Always sanitize output (e.g., with `html-sanitizer`) and validate input. Consider alternatives like `league/commonmark` for stricter security.
How do I install twig/markdown-extra in a Laravel project?
Run `composer require twig/markdown-extra` and register the extension in your Twig environment (e.g., via a service provider). For Laravel, ensure Twig is properly configured first, as this package isn’t Blade-native.
Does twig/markdown-extra support Laravel 10+?
Officially, no—it’s designed for Twig/Symfony ecosystems. Laravel 10+ may face compatibility issues due to Twig v3.x changes. Test thoroughly or use a fork if critical. For Laravel, `cebe/markdown` is a more reliable choice.
What’s the difference between markdown_to_html and html_to_markdown?
`markdown_to_html` converts Markdown to HTML (e.g., for rendering user content), while `html_to_markdown` reverses the process (e.g., for editing workflows). The latter may lose complex HTML structures like tables or scripts.
Is twig/markdown-extra actively maintained?
No, the package has no recent updates, zero dependents, and a suspicious 2026 release date. Forking may be necessary, but long-term support is uncertain. Evaluate alternatives like `league/commonmark` for stability.
Will twig/markdown-extra work with Laravel’s Blade templates?
No, this package is Twig-only. For Blade, use `Str::markdown()` (built-in) or `cebe/markdown` (lightweight). If you *must* use Twig in Laravel, consider `tightenco/jigsaw` but expect architectural trade-offs.
How do I cache Markdown-to-HTML conversions for performance?
Cache the filtered output in Twig (e.g., `{% cache %}` blocks) or pre-render Markdown in your controller. Avoid per-request parsing for high-traffic sites, as this package adds latency without built-in caching.
Are there better alternatives for Laravel Markdown support?
Yes. For Blade: `cebe/markdown` (simple) or `league/commonmark` (full CommonMark). For Twig: `twig/markdown-extra` is fine, but evaluate its unmaintained risks. Laravel’s `Str::markdown()` is sufficient for basic use cases.
How do I handle bidirectional Markdown workflows in Laravel?
If you need both directions, `twig/markdown-extra` works in Twig but isn’t Laravel-native. For Blade, combine `cebe/markdown` (Markdown→HTML) with a custom HTML→Markdown solution (e.g., `league/html-to-markdown`). Test edge cases like nested tables or scripts.
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport