PHPackages                             mozex/commonmark-routes - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. mozex/commonmark-routes

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

mozex/commonmark-routes
=======================

A CommonMark extension that lets you use Laravel's route(), url(), and asset() helpers in Markdown links and images.

1.7.0(2mo ago)18.5k↓15.7%1[1 PRs](https://github.com/mozex/commonmark-routes/pulls)MITPHPPHP ^8.2.0CI passing

Since Jun 28Pushed 3w ago1 watchersCompare

[ Source](https://github.com/mozex/commonmark-routes)[ Packagist](https://packagist.org/packages/mozex/commonmark-routes)[ Docs](https://github.com/mozex/commonmark-routes)[ GitHub Sponsors](https://github.com/mozex)[ RSS](/packages/mozex-commonmark-routes/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (10)Dependencies (27)Versions (16)Used By (0)

Use Laravel URL Helpers inside Markdown
=======================================

[](#use-laravel-url-helpers-inside-markdown)

[![Latest Version on Packagist](https://camo.githubusercontent.com/8b9e23f2cf63f62ed178e616bcbd484d8b08174c9b8a70ec24d832a71c0615f8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6f7a65782f636f6d6d6f6e6d61726b2d726f757465732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mozex/commonmark-routes)[![GitHub Checks Workflow Status](https://camo.githubusercontent.com/ac44417837323a80ebcbbc3c3db4f7c26e9a8e1ae87272c5e4f012cf6fa4159f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d6f7a65782f636f6d6d6f6e6d61726b2d726f757465732f636865636b732e796d6c3f6272616e63683d6d61696e266c6162656c3d636865636b73267374796c653d666c61742d737175617265)](https://github.com/mozex/commonmark-routes/actions/workflows/checks.yml)[![Docs](https://camo.githubusercontent.com/6bae6cab4895bc9b3768db4e7f44e2640da7b03da9635f43f34a1ea306f23e0e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f63732d6d6f7a65782e6465762d3130423938313f7374796c653d666c61742d737175617265)](https://mozex.dev/docs/commonmark-routes/v1)[![License](https://camo.githubusercontent.com/7065c1558e543a05374b0f194fab90ddc12697f29c3f68034d3b7b68f87e6b1a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d6f7a65782f636f6d6d6f6e6d61726b2d726f757465732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mozex/commonmark-routes)[![Total Downloads](https://camo.githubusercontent.com/00f38cb92eb31e8b0180f8ef49a6eaad4494bf12ae47957016c102b15bc6e043/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6f7a65782f636f6d6d6f6e6d61726b2d726f757465732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mozex/commonmark-routes)

A [league/commonmark](https://github.com/thephpleague/commonmark) extension that lets you use `route()`, `url()`, and `asset()` inside your Markdown content. Write links and images using the same Laravel helpers you already use in Blade, and they'll resolve to real URLs when the Markdown is converted.

> **[Read the full documentation at mozex.dev](https://mozex.dev/docs/commonmark-routes/v1)**: searchable docs, version requirements, detailed changelog, and more.

> **Warning:** This extension evaluates helper calls from the Markdown source. Only use it with trusted content that you control. Don't process user-submitted Markdown with this extension.

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Usage](#usage)
    - [Links](#links)
    - [Images](#images)
    - [Spatie Laravel Markdown](#spatie-laravel-markdown)

Support This Project
--------------------

[](#support-this-project)

I maintain this package along with [several other open-source PHP packages](https://mozex.dev/docs) used by thousands of developers every day.

If my packages save you time or help your business, consider [**sponsoring my work on GitHub Sponsors**](https://github.com/sponsors/mozex). Your support lets me keep these packages updated, respond to issues quickly, and ship new features.

Business sponsors get logo placement in package READMEs. [**See sponsorship tiers →**](https://github.com/sponsors/mozex)

Installation
------------

[](#installation)

> **Requires [PHP 8.2+](https://php.net/releases/)** - see [all version requirements](https://mozex.dev/docs/commonmark-routes/v1/requirements)

Install the package via Composer:

```
composer require mozex/commonmark-routes
```

Usage
-----

[](#usage)

Register the extension with your CommonMark environment, then use `route()`, `url()`, or `asset()` in place of URLs in your Markdown.

```
use League\CommonMark\CommonMarkConverter;
use Mozex\CommonMarkRoutes\RoutesExtension;

$converter = new CommonMarkConverter();
$converter->getEnvironment()->addExtension(new RoutesExtension());
```

### Links

[](#links)

The `route()` helper works exactly the way it does in your PHP code. Named routes, parameters, query strings, relative URLs:

```
echo $converter->convert("[Home](route('home'))");
// Home

echo $converter->convert("[Product](route('product', 3))");
// Product

echo $converter->convert("[Features](route('home', ['id' => 'features']))");
// Features

echo $converter->convert("[Home](route('home', absolute: false))");
// Home
```

The `url()` helper generates URLs from plain paths:

```
echo $converter->convert("[About](url('about'))");
// About

echo $converter->convert("[Docs](url('docs/getting-started'))");
// Docs
```

The `asset()` helper resolves static file paths through Laravel's asset pipeline. This is especially useful in environments like [Laravel Vapor](https://vapor.laravel.com) where assets are served from S3 or CloudFront and relative paths won't work:

```
echo $converter->convert("[Download PDF](asset('files/doc.pdf'))");
// Download PDF
```

When the helper is used as both the link text and the URL, the resolved URL appears in both places:

```
echo $converter->convert("[route('home')](route('home'))");
// https://domain.com
```

Angle brackets work too, which can help with complex arguments:

```
echo $converter->convert("[Home]()");
// Home
```

You can freely mix helpers with regular Markdown links in the same document:

```
echo $converter->convert("[Home](route('home')) | [Docs](url('docs')) | [Google](https://google.com)");
// Home | Docs | Google
```

### Images

[](#images)

Image syntax works the same way. Put a helper inside `![alt](...)` and it resolves just like links do:

```
echo $converter->convert("![Logo](asset('images/logo.png'))");
//

echo $converter->convert("![Banner](url('images/banner.jpg'))");
//

echo $converter->convert("![Product](route('product', 3))");
//
```

The `asset()` helper is the most common choice for images. If you're on Vapor or any setup that serves assets from a CDN, `asset()` gives you the correct absolute URL instead of a broken relative path.

Regular images without helpers pass through untouched:

```
echo $converter->convert("![Photo](https://example.com/photo.jpg)");
//
```

For more details on CommonMark extensions and environments, check the [CommonMark documentation](https://commonmark.thephpleague.com/2.4/basic-usage/).

### Spatie Laravel Markdown

[](#spatie-laravel-markdown)

If you're using the [Laravel Markdown](https://github.com/spatie/laravel-markdown/) package by Spatie, register the extension in `config/markdown.php`:

```
/*
 * These extensions should be added to the markdown environment. A valid
 * extension implements League\CommonMark\Extension\ExtensionInterface
 *
 * More info: https://commonmark.thephpleague.com/2.4/extensions/overview/
 */
'extensions' => [
    Mozex\CommonMarkRoutes\RoutesExtension::class,
],
```

Resources
---------

[](#resources)

Visit the [documentation site](https://mozex.dev/docs/commonmark-routes/v1) for searchable docs, auto-updated from this repository.

- **[AI Integration](https://mozex.dev/docs/commonmark-routes/v1/ai-integration)**: Use this package with AI coding assistants via Context7 and Laravel Boost
- **[Requirements](https://mozex.dev/docs/commonmark-routes/v1/requirements)**: PHP, Laravel, and dependency versions
- **[Changelog](https://mozex.dev/docs/commonmark-routes/v1/changelog)**: Release history with linked pull requests and diffs
- **[Contributing](https://mozex.dev/docs/commonmark-routes/v1/contributing)**: Development setup, code quality, and PR guidelines
- **[Questions &amp; Issues](https://mozex.dev/docs/commonmark-routes/v1/questions-and-issues)**: Bug reports, feature requests, and help
- **[Security](mailto:hello@mozex.dev)**: Report vulnerabilities directly via email

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

51

—

FairBetter than 95% of packages

Maintenance90

Actively maintained with recent releases

Popularity27

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 84% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~72 days

Recently: every ~9 days

Total

10

Last Release

85d ago

PHP version history (3 changes)1.0.0PHP ^8.1

1.2.0PHP ^8.1.0

1.4.0PHP ^8.2.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/f4d33a9cb8263eab6fa251e57fc763c5c6977701e5cafa0edc538c4651bb9780?d=identicon)[mozex](/maintainers/mozex)

---

Top Contributors

[![mozex](https://avatars.githubusercontent.com/u/18025667?v=4)](https://github.com/mozex "mozex (63 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (7 commits)")[![Bloafer](https://avatars.githubusercontent.com/u/317470?v=4)](https://github.com/Bloafer "Bloafer (3 commits)")[![claude](https://avatars.githubusercontent.com/u/81847?v=4)](https://github.com/claude "claude (2 commits)")

---

Tags

asset-helpercommonmarkcommonmark-extensionlaravellaravel-routeslaravel-vaporleague-commonmarkmarkdownmarkdown-imagesphpurl-helperurlphplaravelroutesdocumentationmarkdowncontentimagescmscommonmarkextensionassetstatic pagesmarkdown-pagesleague-commonmark

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/mozex-commonmark-routes/health.svg)

```
[![Health](https://phpackages.com/badges/mozex-commonmark-routes/health.svg)](https://phpackages.com/packages/mozex-commonmark-routes)
```

###  Alternatives

[statamic/cms

The Statamic CMS Core Package

4.8k3.6M984](/packages/statamic-cms)[helsingborg-stad/municipio

A bootstrap theme for creating municipality sites.

4028.5k10](/packages/helsingborg-stad-municipio)[cartalyst/interpret

A driver-based content rendering package, with support for HTML, Markdown &amp; plain text. You can register custom drivers for custom content types.

1917.3k](/packages/cartalyst-interpret)[grazulex/laravel-atlas

Laravel Atlas scans your Laravel project to generate a complete, structured map of its internal components — models, controllers, routes, jobs, observers, events, commands, and more — and exports visual or machine-readable representations in formats like Mermaid, Markdown, JSON, or PDF.

212.4k](/packages/grazulex-laravel-atlas)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
