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

twig/markdown-extra

Twig extension adding Markdown support: convert Markdown to HTML with the markdown_to_html filter, and convert HTML back to Markdown with html_to_markdown. Ideal for rendering user content and round-tripping between formats in Twig templates.

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 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 now 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.
    • 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).
  • 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).

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.
  • 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).
    • 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 + markdown-extra) 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. 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.
  • 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? The fix is non-breaking, requires minimal effort, and has 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."*

For Engineering (Technical)

*"This release patches CVE-2026-46637 in twig/markdown-extra, addressing an XSS vulnerability in Markdown-to-HTML rendering. Here’s how it impacts our Laravel stack:

  • Critical Fix: The package now 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.
  • Non-Breaking: Existing Twig filters (markdown_to_html, html_to_markdown) work as before but are now safer. No API changes required.
  • Performance: Negligible overhead. Escaping happens during parsing, not at runtime.
  • Caching: Safe for cached outputs (e.g., blog posts), as the package handles escaping internally.

Action Items:

  1. Update immediately to twig/markdown-extra:^3.26.0 in all environments.
  2. Audit high-risk areas:
    • User-generated Markdown (forums, wikis, comments).
    • Bidirectional pipelines (HTML ↔ Markdown migrations).
  3. Test edge cases:
    • Verify custom Twig filters or extensions using raw Markdown input.
    • Check if legacy content (e.g., migrated HTML) renders correctly.
  4. Document the change: Note that input is now pre-escaped, so manual escaping in templates is redundant and may break formatting.

Key Considerations:

  • Custom Filters: If you’ve created filters that bypass escaping (e.g., for trusted content
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.
calmfox/watch-sylius
damienfern/grpc-symfony-bundle
atoolo/index-bundle
atoolo/genai-bundle
coprotoai/laravel-ticket
davidjln/llm-carbon-bundle
cryonighter/valid-request-bundle
coolms/taxonomy-bundle
coolms/field-bundle
articulate-orm/symfony
aaix/laravel-tall-architect
ephoto/akeneo-connector
emmanuelballery/eb-plantumlbundle
emielburgman/symfony-visitor-beacon
emielburgman/symfony-visit-storage
emielburgman/symfony-security-headers
emielburgman/symfony-log-viewer
emarref/xdebug-bundle
emarref/pubnub-bundle
elriseio/finance-money-bundle