dothiv/dothiv-parsedown-bundle
Installation:
composer require dothiv/dothiv-parsedown-bundle dev-master
Add the bundle to AppKernel.php:
new Dothiv\Bundle\ParsedownBundle\DothivParsedownBundle(),
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>
Where to Look First:
README.md for basic usage.DothivParsedownBundle for service configuration (if available).debug:container to verify the parsedown service is registered.Basic Markdown Conversion:
Use the |markdown filter in Twig templates for inline conversion:
{% set content = '# Heading\n\n- List item' %}
{{ content|markdown }}
Dynamic Content Handling: Pass variables from controllers to templates:
// Controller
return $this->render('template.html.twig', [
'markdownContent' => $this->getMarkdownContent(),
]);
{{ markdownContent|markdown }}
Integration with Forms: Use the filter to render user-submitted Markdown in forms or profiles:
<div class="bio">{{ user.bio|markdown }}</div>
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
{% cache 'markdown_' content %}
{{ content|markdown }}
{% endcache %}
{% set parsed = content|markdown if content is iterable else content %}
Deprecated Bundle:
parsedown/parsedown to ^1.8).No Service Configuration:
{{ dump(_context.getFilter('markdown')) }} to inspect the underlying service.Security Risks:
HTMLPurifier to sanitize output:
{{ (content|markdown)|purify }}
Performance:
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.
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.
Alternative Packages: For modern Symfony, consider:
knplabs/knp-markdown-bundle (Symfony 3+).composer require erusev/parsedown.config.yml Support:
The bundle likely lacks configuration options. Verify by checking Resources/config/services.xml or DependencyInjection/.composer require with dev-master explicitly.How can I help you explore Laravel packages today?