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

Parsedown Extra Laravel Package

parsedown/parsedown-extra

Parsedown Extra adds Markdown Extra support to Parsedown, enabling features like tables, footnotes, definition lists, and other extended syntax. Useful when you need richer Markdown parsing in PHP with minimal setup and fast rendering.

Deep Wiki
Context7

Getting Started

Begin by installing via Composer: composer require parsedown/parsedown-extra. Instantiate ParsedownExtra directly—it’s a drop-in extension of Parsedown, so replace new Parsedown() with new ParsedownExtra(). Your first use case is rendering rich content like technical docs or blog posts using Markdown Extra syntax: tables, footnotes, or definition lists. For example:

$Parsedown = new ParsedownExtra();
echo $Parsedown->text('| A | B |');

Check the output HTML immediately in a Tinker session or a quick route closure to verify rendering.

Implementation Patterns

  • Singleton Service Binding: In AppServiceProvider, bind ParsedownExtra as a singleton for reuse across requests:
    $this->app->singleton(\ParsedownExtra::class);
    
    Inject it into controllers or jobs handling user-generated content.
  • View composers: Use it in a view composer to auto-render Blade templates containing markdown (e.g., @markdown stubs or custom directives).
  • Fenced code blocks: Write ```php with language hints—ensure client-side highlighters (e.g., highlight.js) pick up class="language-php" for styling.
  • Definition lists: Use strict formatting: Term\n: Definition (note the space after :). Ideal for glossaries in help centers.
  • Extensibility: Extend ParsedownExtra to add project-specific tokens (e.g., :::note::: blocks) by overriding blockDefinitions() or inlineDefinitions().

Gotchas and Tips

  • No security hardening out-of-the-box: User-submitted markdown is not sanitized by default. Always call $parsedown->setSafeMode(true) or use Laravel’s e() + raw() pattern cautiously.
  • Whitespace is unforgiving: Definition lists fail silently with extra leading spaces or missing space after :; triple-check indents.
  • Fenced code blocks ≠ syntax highlighting: The parser only adds language classes—browser-side tools are required for visual highlighting.
  • Legacy compatibility risk: This package’s obscurity (1 star, unknown repo) suggests it’s not the official erusev/parsedown-extra (1.2k+ stars). Confirm compatibility with erusev/parsedown v1.x before integration—breaking changes may occur.
  • Debug tip: Use dd($Parsedown->elementData) or inspect raw HTML to catch malformed tables or nested block errors—common failures stem from unexpected line breaks or tabs.
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
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
twbs/bootstrap4
php-http/client-implementation
phpcr/phpcr-implementation
cucumber/gherkin-monorepo
haydenpierce/class-finder
psr/simple-cache-implementation
uri-template/tests