- How do I install pixel418/markdownify in a Laravel app?
- Install it with Composer using composer require pixel418/markdownify. The package is Composer-ready with PSR-4 autoloading and zero heavy dependencies. For fresh adoption, pin ^2.3.3 and consider building a thin adapter service before wiring it into product features. In Laravel you can use it directly or bind a converter service in the container.
- Does pixel418/markdownify support Laravel 10 and Laravel 11?
- The package is a framework-agnostic PHP library rather than a Laravel-specific package with a service provider. Laravel support therefore depends on whether the package PHP constraint matches the PHP version your Laravel release requires. Confirm the Composer constraints before rollout and pin versions in staging. It integrates easily into Laravel through Composer and can be wrapped in a Laravel service or singleton binding.
- How do I convert HTML to Markdown in Laravel using Markdownify?
- Create a converter instance and pass an HTML fragment or full document to its convert method to get Markdown text back. In Laravel, avoid calling the package directly from controllers, Blade templates, jobs, or model observers. Wrap it in an application-owned adapter or service so configuration, sanitization, caching, and output policy live in one place. This also keeps the package swappable if your conversion needs change.
- Can I customize how Markdownify converts specific HTML tags or attributes?
- Yes, Markdownify provides customizable converters for tags, attributes, and custom elements. You can configure handling for links, images, lists, tables, and code blocks, and you can keep or strip specific elements to control output. In a Laravel application, expose these options through application config rather than scattering converter calls throughout the codebase. Validate behavior anywhere you use ConverterExtra directly.
- Does Markdownify handle tables, lists, images, links, and code blocks?
- Markdownify handles common HTML elements including links, images, lists, tables, and code blocks. The v2.3.3 release includes fixes for list spacing, headerless-table conversion, multiline inline-code folding, unquoted HTML attribute parsing, and Word o:p handling. It is a pragmatic converter rather than a formal CommonMark or GFM compliance implementation. Test edge-case content against your downstream renderer and sanitizer.
- How do I stop Markdownify from adding CSS classes to output?
- Use ConverterExtra::setAddCssClass(false) to disable the added CSS classes. Treat this as an application-level output policy rather than a one-off call in a controller. The change is opt-in, so default behavior can remain unchanged until design and QA sign off. Also check whether any frontend tests or design systems depend on package-emitted Markdown Extra CSS classes.
- Is Markdownify a CommonMark or GFM compliant converter?
- No, pixel418/markdownify is pragmatic rather than a formal CommonMark or GFM compliance implementation. Do not position it as a spec-compliance guarantee. It converts common HTML elements and supports custom converters for application-specific needs. If strict spec semantics are required, validate output carefully or use a dedicated compliance-focused converter.
- How should I handle HTML sanitization when converting user-generated content with Markdownify?
- HTML sanitization remains the application responsibility before and after conversion. The v2.3.3 unquoted attribute parsing broadens accepted HTML input, and the headerless-table fix means more table markup may reach downstream sanitizers and renderers. Verify that your sanitizer allowlist covers expanded table and attribute output. Keep sanitization policy inside your Laravel adapter or service so it is enforced consistently.
- Can I use Markdownify in queued jobs for bulk HTML-to-Markdown conversion?
- Yes, Markdownify composes well with Laravel queues, storage, and pipeline jobs, which is where bulk HTML-to-Markdown conversion should run. Bind the converter as a singleton or configurable service in Laravel’s container and expose package options through application config. Avoid calling the package directly from controllers or Blade templates. This keeps bulk conversion efficient and makes output policy easier to enforce.
- Is pixel418/markdownify maintained and safe for production use?
- The package is maintained with an active release cadence and an MIT license, and v2.3.3 is additive and corrective with no indicated breaking changes. The Dependents: 0 signal suggests limited public ecosystem validation, so add fixture tests for the fixed issues and Word or unquoted-attribute behavior. Pin ^2.3.3, run composer update, and validate in staging before production rollout. Overall technical risk is low-to-moderate, with parser and output changes affecting edge-case content.