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

Dothiv Parsedown Bundle Laravel Package

dothiv/dothiv-parsedown-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation:

    composer require dothiv/dothiv-parsedown-bundle dev-master
    

    Add the bundle to AppKernel.php:

    new Dothiv\Bundle\ParsedownBundle\DothivParsedownBundle(),
    
  2. First Use Case: In a Twig template, convert Markdown to HTML using the |markdown filter:

    {{ 'This is **bold** text.'|markdown }}
    

    Outputs:

    <p>This is <strong>bold</strong> text.</p>
    
  3. Where to Look First:

    • Check the README.md for basic usage.
    • Inspect DothivParsedownBundle for service configuration (if available).
    • Use Symfony’s debug:container to verify the parsedown service is registered.

Implementation Patterns

Common Workflows

  1. Basic Markdown Conversion: Use the |markdown filter in Twig templates for inline conversion:

    {% set content = '# Heading\n\n- List item' %}
    {{ content|markdown }}
    
  2. Dynamic Content Handling: Pass variables from controllers to templates:

    // Controller
    return $this->render('template.html.twig', [
        'markdownContent' => $this->getMarkdownContent(),
    ]);
    
    {{ markdownContent|markdown }}
    
  3. Integration with Forms: Use the filter to render user-submitted Markdown in forms or profiles:

    <div class="bio">{{ user.bio|markdown }}</div>
    
  4. Custom Parsedown Extensions: If the bundle supports extensions (unlikely due to age), configure them via dependency injection:

    # config.yml (if supported)
    dothiv_parsedown:
        extensions:
            - Dothiv\Parsedown\Ext\CustomExtension
    

Twig Integration Tips

  • Cache Parsed Output: Store parsed HTML in the database or cache to avoid reprocessing:
    {% cache 'markdown_' content %}
        {{ content|markdown }}
    {% endcache %}
    
  • Fallback for Non-Markdown: Handle cases where input isn’t Markdown:
    {% set parsed = content|markdown if content is iterable else content %}
    

Gotchas and Tips

Pitfalls

  1. Deprecated Bundle:

    • Last updated in 2015 for Symfony2. May not work with Symfony 3+ or 4/5 without patches.
    • Workaround: Fork the repo and update dependencies (e.g., parsedown/parsedown to ^1.8).
  2. No Service Configuration:

    • The bundle likely registers Parsedown as a Twig filter without customization options.
    • Debugging: Use {{ dump(_context.getFilter('markdown')) }} to inspect the underlying service.
  3. Security Risks:

    • Markdown can execute arbitrary HTML/JS if not sanitized. Use a library like HTMLPurifier to sanitize output:
      {{ (content|markdown)|purify }}
      
  4. Performance:

    • Parsedown is fast, but parsing large Markdown blocks repeatedly (e.g., in loops) can slow down templates.
    • Tip: Pre-process Markdown in the controller and pass HTML to Twig.

Debugging

  • Filter Not Found: Ensure the bundle is loaded in AppKernel.php and Composer dependencies are installed.

    composer dump-autoload
    
  • Output Mismatches: Test with simple Markdown (e.g., # Test) to isolate issues. Compare output with Parsedown’s demo.

Extension Points

  1. Custom Parsedown Instance: If you need extensions, create a custom service:

    # services.yml
    app.parsedown:
        class: Parsedown
        calls:
            - [setBreaksEnabled, [true]]
    

    Override the Twig filter in a custom bundle or use a compiler pass.

  2. Alternative Packages: For modern Symfony, consider:

Configuration Quirks

  • No config.yml Support: The bundle likely lacks configuration options. Verify by checking Resources/config/services.xml or DependencyInjection/.
  • Symfony Flex Compatibility: The bundle predates Symfony Flex. Use composer require with dev-master explicitly.
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.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui