Weave 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 Laravel Package

twig/markdown-extra

Twig extension that adds markdown_to_html and html_to_markdown filters for converting Markdown blocks to HTML and HTML back to Markdown directly in your Twig templates, with configurable parsers.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Secure Content Moderation Systems:

    • Enables real-time Markdown rendering in Laravel-based platforms (e.g., Discourse-like forums, Slack/Teams integrations) with built-in XSS protection, reducing reliance on third-party sanitizers like HTML Purifier. The CVE-2026-46637 fix (shipped pre-v3.28.0) directly addresses OWASP A03:2021 Injection risks in user-generated content.
    • Roadmap Tie-In: Accelerates migration to Markdown-as-a-primary-input for internal tools (e.g., Jira alternatives, Confluence replacements) by eliminating security friction. Example: A dev portal can use Markdown for docs without custom sanitization layers.
  • Build vs. Buy Tradeoffs:

    • Buy for Core Use Cases: Replace ad-hoc Markdown parsers (e.g., parsedown/parsedown, michelf/php-markdown) with a maintained, Symfony-backed solution. Avoids technical debt from forks or abandoned packages.
    • New in v3.29.0 — Renderer Optionality: markdown-extra now supports tempest/markdown alongside its existing engine(s) (#4890). This is a strategic de-risking signal: rendering backends are pluggable, so we are not hard-locked to a single parser supply chain. Useful when a team already standardizes on Tempest components, or when we want a lighter-weight engine for high-volume, low-complexity rendering paths (e.g., comment streams) while keeping the heavier engine for docs.
    • Extend for Niche Needs: Use as a foundation for custom Twig filters (e.g., LaTeX support, shortcode parsing) via Laravel’s Service Provider integration. Example: A scientific journal platform could extend markdown_to_html to support MathJax via a wrapper filter.
    • Avoid Rebuilding: Skip reinventing Markdown ↔ HTML pipelines (e.g., for email templating or PDF generation) when this package handles 80% of use cases securely.
  • Use Cases by Laravel Domain:

    • CMS/Forums: Replace CKEditor/TinyMCE for Markdown editing in Laravel Nova or Filament, with real-time preview via markdown_to_html in Blade.
    • APIs/Headless CMS: Serve Markdown-rendered content via Laravel’s API routes (e.g., GET /posts/{id}/rendered) with XSS-proof HTML.
    • Legacy Migration: Convert old HTML emails (e.g., from Mailchimp) to Markdown for version control, then re-render with this package for consistency.
    • Multi-Tenant SaaS: Isolate tenant-specific Markdown rendering to prevent cross-tenant XSS via shared infrastructure (e.g., Laravel Horizon queues).
    • Engine-Selective Pipelines (New): With tempest/markdown support, we can A/B or tier rendering by content class — e.g., Tempest engine for volume-heavy short-form (comments, chat transcripts) and CommonMark for long-form docs — without adopting a second rendering stack.
  • Developer Productivity Gains:

    • Reduces Boilerplate: Eliminates manual escaping in Blade (e.g., {{ $comment|e }}) for Markdown content. Example: A support ticket system can render user comments directly without sanitization steps.
    • Standardizes Security: Enforces consistent escaping across all Markdown-to-HTML conversions, reducing human error in security-critical paths (e.g., Laravel Echo event payloads).
    • Enables Caching: Safe for cached Markdown outputs (e.g., blog posts) since the package pre-escapes content during parsing. Integrates with Laravel’s cache drivers (Redis, file, database).
    • Lower Switching Cost: New engine support means changing renderers later is a config-level decision, not a rewrite — a direct reduction in future migration cost for the roadmap.

When to Consider This Package

  • Adopt when:

    • Your Laravel app processes untrusted Markdown (e.g., comments, wiki edits, forum posts) and requires XSS protection. The CVE-2026-46637 fix is a hard requirement for these use cases.
    • You’re migrating from HTML to Markdown (e.g., legacy CMS, static sites) and need a secure, bidirectional conversion tool. Example: A news site converting old HTML articles to Markdown for Git workflows.
    • Your team uses Twig in Laravel (e.g., for dynamic templates, API responses, or microservices) and wants to leverage Markdown without security trade-offs.
    • You prioritize maintainability over custom solutions. The package is actively maintained (Symfony-backed) and integrates cleanly with Laravel’s ecosystem (e.g., Laravel Echo, Livewire).
    • You need to comply with security standards (e.g., ISO 27001, GDPR) for content rendering. The fix aligns with OWASP ASVS and CWE-79 mitigation strategies.
    • (New, v3.29.0) You want renderer flexibility or already use Tempest components — tempest/markdown is now a supported backend, so this is a low-friction fit for teams standardizing on that ecosystem.
  • Look elsewhere if:

    • Your app only renders static Markdown (e.g., internal docs, marketing pages) with no user input. The risk is low, but the package is still recommended for consistency.
    • You require advanced Markdown features (e.g., mermaid.js diagrams, custom syntax) beyond markdown-extra’s scope. Consider:
      • League/CommonMark for extensibility (e.g., GitBook-like plugins).
      • Parsedown Extra for lightweight alternatives (e.g., Laravel Nova custom fields).
      • Note (v3.29.0): the new tempest/markdown backend expands choices but does not add extensions — evaluate it on parsing behavior/performance, not feature breadth.
    • Your team lacks Markdown proficiency and relies on WYSIWYG editors (e.g., TinyMCE, CKEditor). Use this package only for rendering, not editing.
    • You’re using a custom Markdown parser or fork that hasn’t applied the CVE-2026-46637 patch. Upgrade immediately to avoid vulnerabilities.
    • Your performance requirements demand a zero-dependency solution. This package adds ~1MB (Twig + engine) to your vendor directory, though the impact is negligible for most Laravel apps.

How to Pitch It (Stakeholders)

For Executives (Business/Strategy)

*"This update closes a critical security gap in how our platform handles user-generated Markdown—directly impacting customer trust, compliance, and operational risk—and the newest release adds rendering-engine flexibility, which lowers our long-term vendor lock-in. Here’s why it’s a top priority:

  • Risk Elimination: Blocks XSS attacks in high-impact areas (e.g., public forums, API documentation, support tickets), reducing liability and support costs.
  • Compliance Alignment: Meets OWASP Top 10, PCI DSS, and GDPR requirements for untrusted input handling, critical for industries like finance, healthcare, or SaaS.
  • Cost Savings: Avoids custom security patches or third-party tools (e.g., HTML Purifier), saving $X/year in engineering overhead.
  • Reduced Lock-In (v3.29.0): Support for an additional Markdown engine (tempest/markdown) means we can swap rendering backends without a rewrite — a direct hedge against future cost or supply-chain risk.
  • Competitive Differentiation: Enables secure Markdown workflows (e.g., Git-based docs, collaborative editing) without sacrificing safety—a gap many competitors overlook.

Ask: Should we prioritize this update for [specific high-risk areas, e.g., our public forum or API docs] in the next sprint? Both the security fix and v3.29.0 are non-breaking, require minimal effort, and have high ROI in security and scalability.

Business Impact:

  • Forums/Support: Reduces moderation overhead and security incidents from malicious scripts in user posts.
  • APIs/Docs: Safeguards technical documentation, critical for enterprise adoption and developer trust.
  • Multi-Tenant SaaS: Prevents cross-tenant XSS attacks, protecting SLA compliance and customer data.
  • Platform Strategy: Pluggable engines preserve architectural optionality as we scale content volume."*

For Engineering (Technical)

*"This release track patches CVE-2026-46637 in twig/markdown-extra (an XSS vulnerability in Markdown-to-HTML rendering), and v3.29.0 adds a new renderer backend: tempest/markdown (#4890). Here’s how it impacts our Laravel stack:

  • Critical Fix (already in): The package auto-escapes untrusted input by default, preventing XSS in user-generated Markdown (e.g., forum posts, comments). This is enabled for all markdown_to_html calls without configuration changes.
  • New in v3.29.0: tempest/markdown is now a supported engine in markdown-extra. It is an additive capability — no change to default behavior, no new required dependency unless we opt in. Treat it as an alternative renderer, not a replacement.
  • Non-Breaking: Existing Twig filters (markdown_to_html, html_to_markdown) work as before but are now safer. No API changes required in v3.28.0 → v3.29.0.
  • Performance: Negligible overhead from the security fix. Engine selection may shift per-request cost — benchmark if we adopt tempest/markdown for high-volume paths.
  • Caching: Safe for cached outputs (e.g., blog posts), as the package handles escaping internally. Pin the engine in cache keys if we ever run more than one backend, since output can differ byte-for-byte between engines.

Action Items:

  1. Update immediately to twig/markdown-extra:^3.29.0 in all environments (supersedes ^3.26.0).
  2. Audit high-risk areas:
    • User-generated Markdown (forums, wikis, comments).
    • Bidirectional pipelines (HTML ↔ Markdown migrations).
  3. Evaluate (optional, low priority): Spike tempest/markdown on one low-risk surface (e.g., comment rendering) to compare output parity, performance, and extension coverage before any adoption decision.
  4. Test edge cases:
    • Verify custom Twig filters or extensions using raw Markdown input.
    • Check if legacy content (e.g., migrated HTML) renders correctly.
    • If switching engines anywhere, diff rendered output against the current baseline.
  5. Document the change: Note that input is now pre-escaped, so manual escaping in templates is redundant and may break formatting. Also record which engine each surface uses.

Key Considerations:

  • Custom Filters: If you’ve created filters that bypass escaping (e.g., for trusted content), re-verify them against the patched version — and confirm they behave identically on any engine you enable.
  • Engine Parity: Do not assume tempest/markdown and the existing engine produce identical HTML; treat any switch as a formatting-change event requiring visual regression checks.
  • Dependency Hygiene: tempest/markdown is opt-in — keep it out of composer.json until a spike justifies it, so we don't grow the vendor footprint without a decision."*
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.
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator
equipc/laravel-email-database-log
adedsec/nova-translated-labels
wazza/laravel-db-encryption
hokny/laravel-generator
vonsogt/backup
jengo/queues
jeremykenedy/laravel-observability
coleus/frame
thtg88/journalism
filagora/filagora-ai-forums