- How do I install n0sz/commonmark-marker-extension?
- Run composer require n0sz/commonmark-marker-extension, then register the extension in your League CommonMark Environment with addExtension(). Check the package composer.json constraints first to confirm it accepts the league/commonmark version your project already has locked. Because there has been no release since September 2022, review the source before putting it into production.
- Does this extension work with Laravel 11 and 12?
- Laravel renders Markdown through league/commonmark 2.x, and this package targets that same 2.x line, so it should install and run on Laravel 11 and 12. The version constraint is the deciding factor: a future CommonMark 3.x upgrade will break the extension whether or not you vendored it. Test the install against your actual locked PHP and CommonMark versions rather than assuming.
- What Markdown syntax does the marker extension add?
- It adds marker syntax so text wrapped in delimiters is rendered inside an HTML mark element for highlighting. The canonical form is ==text==, and the extension registers an inline parser plus a renderer instead of monkey-patching the core parser. Verify the exact delimiters and edge-case behavior in the source, since the grammar is implied by the implementation rather than documented.
- How do I register the extension in a CommonMark Environment?
- Build a League CommonMark Environment, call addExtension() with the package extension class, and construct a MarkdownConverter from that environment. In Laravel, bind the configured converter as a singleton in a service provider so Str::markdown(), the Blade markdown component, and Mail templates all share one instance. Avoid letting each call create a fresh default environment, which would silently drop the extension.
- Is n0sz/commonmark-marker-extension still maintained?
- No. The last release was 2022-09-27, the repository has around 3 stars and 0 dependents, and there is no visible CI or test suite. Treat it as unvetted code rather than a dependency with a community behind it. If you need the feature long term, plan to vendor or fork it under the MIT license.
- Does it work with Str::markdown() and the Blade markdown component?
- Only if those surfaces use an environment that includes the extension. Str::markdown() accepts an extensions option, and the Blade markdown component and Mail markdown templates funnel into the same CommonMark environment, so a shared singleton binding keeps output consistent. Passing the extension per call also works but risks divergence between API, Blade, and Mail rendering.
- Is it safe to use with untrusted user-generated Markdown?
- Be cautious. The extension executes in the parsing path of every document, including untrusted input, so read it line by line for regex backtracking and confirm the renderer escapes output correctly. Check whether raw HTML passthrough is permitted before enabling it on any endpoint that accepts user content, and run adversarial input through it first.
- Can I change the highlight element or add a CSS class?
- The renderer emits a mark element, and customization depends on whether the package exposes configuration, which the README does not document. If it does not, editing or subclassing the renderer to add a class is a small change. If you vendor the code, make the element tag and attributes configurable so your stylesheets can target the output reliably.
- Does the marker syntax conflict with strikethrough or emphasis?
- Delimiter processors share the inline parsing pipeline, so overlapping runs of =, ~, and * can misparse, especially with triple delimiters or nested emphasis inside a marker. The package ships no published tests proving these edge cases, so reproduce them yourself. Add regression tests for adjacent delimiters before relying on the extension.
- Should I require this package or fork it into my app?
- Given zero upstream maintenance and a roughly 150-line codebase, vendoring the source into app/Support/Markdown/ under your own namespace is usually the better trade. You get an auditable, testable extension at about the same integration cost and can harden escaping and regex behavior along the way. Require it only if you are comfortable pinning league/commonmark 2.x and reading the source anyway.