### Install the package
Source: https://github.com/mozex/commonmark-routes/blob/main/README.md
Use Composer to add the package to your project.
```bash
composer require mozex/commonmark-routes
```
--------------------------------
### Install dependencies
Source: https://github.com/mozex/commonmark-routes/blob/main/CONTRIBUTING.md
Install development dependencies after cloning the repository.
```bash
composer install
```
--------------------------------
### Advanced helper usage
Source: https://github.com/mozex/commonmark-routes/blob/main/README.md
Examples of using helpers as link text, using angle brackets for complex arguments, and mixing helpers with standard links.
```php
echo $converter->convert("[route('home')](route('home'))");
//
https://domain.com
echo $converter->convert("[Home]()");
// Home
echo $converter->convert("[Home](route('home')) | [Docs](url('docs')) | [Google](https://google.com)");
// Home | Docs | Google
```
--------------------------------
### Register RoutesExtension with CommonMark Converter
Source: https://context7.com/mozex/commonmark-routes/llms.txt
Register the RoutesExtension with your CommonMark environment to enable Laravel URL helper resolution. This setup is required before converting Markdown content.
```php
use League\CommonMark\CommonMarkConverter;
use Mozex\CommonMarkRoutes\RoutesExtension;
// Create the CommonMark converter
$converter = new CommonMarkConverter();
// Register the RoutesExtension
$converter->getEnvironment()->addExtension(new RoutesExtension());
// Now you can convert Markdown with Laravel helpers
$html = $converter->convert("[Home](route('home'))")->getContent();
// Output: Home
```
--------------------------------
### Use route() helper in links
Source: https://github.com/mozex/commonmark-routes/blob/main/README.md
Demonstrates using named routes, parameters, and absolute/relative URL configurations.
```php
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
```
--------------------------------
### Mix Helpers with Regular Markdown Links
Source: https://context7.com/mozex/commonmark-routes/llms.txt
Demonstrates how to combine dynamic helper function calls with standard Markdown links and images.
```php
use League\CommonMark\CommonMarkConverter;
use Mozex\CommonMarkRoutes\RoutesExtension;
$converter = new CommonMarkConverter();
$converter->getEnvironment()->addExtension(new RoutesExtension());
// Mix helpers with regular relative links
echo $converter->convert("[Home](route('home')) | [About](/about)")->getContent();
// Home | About
// Mix helpers with external absolute links
echo $converter->convert("[Home](route('home')) | [Docs](url('docs')) | [Google](https://google.com)")->getContent();
// Home | Docs | Google
// Regular images pass through untouched
echo $converter->convert("")->getContent();
// 
// Mix dynamic and regular images
echo $converter->convert(") ")->getContent();
//

```
--------------------------------
### Use url() helper in links
Source: https://github.com/mozex/commonmark-routes/blob/main/README.md
Generates URLs from plain paths.
```php
echo $converter->convert("[About](url('about'))");
// About
echo $converter->convert("[Docs](url('docs/getting-started'))");
// Docs
```
--------------------------------
### Run tests
Source: https://github.com/mozex/commonmark-routes/blob/main/CONTRIBUTING.md
Execute various test suites and type checks.
```bash
composer test
```
```bash
composer test:types
```
```bash
composer test:unit
```
--------------------------------
### Register the extension
Source: https://github.com/mozex/commonmark-routes/blob/main/README.md
Add the RoutesExtension to your CommonMark environment to enable helper resolution.
```php
use League\CommonMark\CommonMarkConverter;
use Mozex\CommonMarkRoutes\RoutesExtension;
$converter = new CommonMarkConverter();
$converter->getEnvironment()->addExtension(new RoutesExtension());
```
--------------------------------
### Resolve static file paths with asset()
Source: https://context7.com/mozex/commonmark-routes/llms.txt
Use the asset() helper to resolve paths for static files, which is particularly useful for environments like Laravel Vapor.
```php
use League\CommonMark\CommonMarkConverter;
use Mozex\CommonMarkRoutes\RoutesExtension;
$converter = new CommonMarkConverter();
$converter->getEnvironment()->addExtension(new RoutesExtension());
// Link to a downloadable file
echo $converter->convert("[Download PDF](asset('files/doc.pdf'))")->getContent();
// Download PDF
// Use asset() in both link text and URL
echo $converter->convert("[asset('files/doc.pdf')](asset('files/doc.pdf'))")->getContent();
// https://domain.com/files/doc.pdf
// Mix all three helpers in one document
echo $converter->convert("[PDF](asset('files/doc.pdf')) | [About](url('about')) | [Home](route('home'))")->getContent();
// PDF | About | Home
```
--------------------------------
### Mixing Helpers and Standard Links
Source: https://github.com/mozex/commonmark-routes/blob/main/resources/boost/skills/commonmark-routes-development/SKILL.md
Demonstrates that standard Markdown links and helper-based links can coexist in the same document.
```markdown
[Home](route('home')) | [Docs](url('docs')) | [Google](https://google.com)
```
--------------------------------
### Registering the Extension
Source: https://github.com/mozex/commonmark-routes/blob/main/resources/boost/skills/commonmark-routes-development/SKILL.md
Methods for integrating the extension into standalone CommonMark environments or Spatie's Laravel Markdown package.
```php
use League\CommonMark\CommonMarkConverter;
use Mozex\CommonMarkRoutes\RoutesExtension;
$converter = new CommonMarkConverter();
$converter->getEnvironment()->addExtension(new RoutesExtension());
```
```php
'extensions' => [
Mozex\CommonMarkRoutes\RoutesExtension::class,
],
```
--------------------------------
### Embed images with helpers
Source: https://context7.com/mozex/commonmark-routes/llms.txt
Apply asset, url, and route helpers directly within Markdown image syntax to generate dynamic source URLs.
```php
use League\CommonMark\CommonMarkConverter;
use Mozex\CommonMarkRoutes\RoutesExtension;
$converter = new CommonMarkConverter();
$converter->getEnvironment()->addExtension(new RoutesExtension());
// Image using asset() - most common for static images
echo $converter->convert(")")->getContent();
// 
// Image using url()
echo $converter->convert(")")->getContent();
// 
// Image using route() with parameter
echo $converter->convert(")")->getContent();
// 
// Use helper in both alt text and src
echo $converter->convert(")")->getContent();
// 
// Multiple images with different helpers
echo $converter->convert(") )")->getContent();
//

// Mix images and links in one document
echo $converter->convert(") and [Home](route('home'))")->getContent();
//
and Home
```
--------------------------------
### Use asset() helper in links
Source: https://github.com/mozex/commonmark-routes/blob/main/README.md
Resolves static file paths through the Laravel asset pipeline.
```php
echo $converter->convert("[Download PDF](asset('files/doc.pdf'))");
// Download PDF
```
--------------------------------
### Using Helpers in Markdown Links
Source: https://github.com/mozex/commonmark-routes/blob/main/resources/boost/skills/commonmark-routes-development/SKILL.md
Syntax for embedding Laravel route, url, and asset helpers within Markdown link definitions.
```markdown
[Home](route('home'))
[Product](route('product', 3))
[Features](route('home', ['id' => 'features']))
[Home](route('home', absolute: false))
[About](url('about'))
[Docs](url('docs/getting-started'))
[Download PDF](asset('files/doc.pdf'))
```
--------------------------------
### Use url() Helper for Path-Based URLs in Markdown
Source: https://context7.com/mozex/commonmark-routes/llms.txt
Illustrates using the url() helper in Markdown to create full URLs from path strings. This is useful for linking to specific paths when named routes are not applicable.
```php
use League\CommonMark\CommonMarkConverter;
use Mozex\CommonMarkRoutes\RoutesExtension;
$converter = new CommonMarkConverter();
$converter->getEnvironment()->addExtension(new RoutesExtension());
// Simple path
echo $converter->convert("[About Us](url('about'))")->getContent();
// About Us
// Nested path segments
echo $converter->convert("[Getting Started](url('docs/getting-started'))")->getContent();
// Getting Started
// Use url() in both link text and URL
echo $converter->convert("[url('about')](url('about'))")->getContent();
// https://domain.com/about
// Mix url() with route() helpers in the same document
echo $converter->convert("[About](url('about')) and [Home](route('home'))")->getContent();
// About and Home
```
--------------------------------
### Lint code
Source: https://github.com/mozex/commonmark-routes/blob/main/CONTRIBUTING.md
Run the linter to ensure code style compliance.
```bash
composer lint
```
--------------------------------
### Image Syntax with Route Helper
Source: https://github.com/mozex/commonmark-routes/blob/main/README.md
Use the route() helper within image markdown syntax to generate image URLs based on named routes. The output is an HTML img tag.
```php
echo $converter->convert(")");
// 
```
--------------------------------
### Convert Markdown with dynamic routes
Source: https://github.com/mozex/commonmark-routes/blob/main/resources/boost/skills/commonmark-routes-development/SKILL.md
Initializes the CommonMarkConverter with the RoutesExtension to process Markdown containing Laravel helper functions.
```php
$markdown = <<<'MD'
Visit your [dashboard](route('dashboard')) to get started.
Download the [user guide](asset('docs/guide.pdf')) for detailed instructions.
Check the [API documentation](url('docs/api')) for endpoint details.
MD;
$converter = new CommonMarkConverter();
$converter->getEnvironment()->addExtension(new RoutesExtension());
echo $converter->convert($markdown);
```
--------------------------------
### Using Helpers in Markdown Images
Source: https://github.com/mozex/commonmark-routes/blob/main/resources/boost/skills/commonmark-routes-development/SKILL.md
Syntax for embedding Laravel helpers within Markdown image definitions using the exclamation mark prefix.
```markdown
)
)
)
```
--------------------------------
### Use route() Helper for Named Routes in Markdown
Source: https://context7.com/mozex/commonmark-routes/llms.txt
Demonstrates using the route() helper within Markdown links to generate URLs for named routes. Supports route parameters, query strings, and absolute/relative URL generation.
```php
use League\CommonMark\CommonMarkConverter;
use Mozex\CommonMarkRoutes\RoutesExtension;
$converter = new CommonMarkConverter();
$converter->getEnvironment()->addExtension(new RoutesExtension());
// Basic named route
echo $converter->convert("[Home](route('home'))")->getContent();
// Home
// Route with a parameter
echo $converter->convert("[View Product](route('product', 3))")->getContent();
// View Product
// Route with query string parameters
echo $converter->convert("[Features](route('home', ['id' => 'features']))")->getContent();
// Features
// Generate relative URL using named argument
echo $converter->convert("[Home](route('home', absolute: false))")->getContent();
// Home
// Generate relative URL with query string (positional arguments)
echo $converter->convert("[Features](route('home', ['id' => 'features'], false))")->getContent();
// Features
// Use route() in both link text and URL - URL appears in both places
echo $converter->convert("[route('home')](route('home'))")->getContent();
// https://domain.com
```
--------------------------------
### Image Syntax with URL Helper
Source: https://github.com/mozex/commonmark-routes/blob/main/README.md
Use the url() helper within image markdown syntax to resolve images to their absolute URLs. The output is an HTML img tag.
```php
echo $converter->convert(")");
// 
```
--------------------------------
### Image Syntax with Asset Helper
Source: https://github.com/mozex/commonmark-routes/blob/main/README.md
Use the asset() helper within image markdown syntax to resolve images to their absolute URLs, especially useful for CDN-served assets. The output is an HTML img tag.
```php
echo $converter->convert(")");
// 
```
--------------------------------
### Register Extension in Spatie Laravel Markdown
Source: https://context7.com/mozex/commonmark-routes/llms.txt
Add the RoutesExtension to the extensions array in the configuration file.
```php
// config/markdown.php
return [
/*
* 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,
],
// ... other configuration options
];
```
--------------------------------
### Registering CommonMark Routes Extension
Source: https://github.com/mozex/commonmark-routes/blob/main/README.md
Register the RoutesExtension in your Spatie Laravel Markdown configuration file (config/markdown.php) to enable its functionality. Ensure the extension implements League\CommonMark\Extension\ExtensionInterface.
```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,
],
```
--------------------------------
### Use Helpers in Blade Views
Source: https://context7.com/mozex/commonmark-routes/llms.txt
Utilize the @markdown directive to render Markdown containing dynamic URL helpers.
```php
// Usage in a Blade view with Spatie's @markdown directive
// resources/views/page.blade.php
@markdown
# Welcome
Check out our [documentation](route('docs')) or download the [user guide](asset('files/guide.pdf')).
)
For more information, visit our [about page](url('about')) or [contact us](route('contact')).
@endmarkdown
```
--------------------------------
### Image Syntax with Absolute URL
Source: https://github.com/mozex/commonmark-routes/blob/main/README.md
Regular image markdown syntax with an absolute URL passes through untouched, rendering as an HTML img tag.
```php
echo $converter->convert("");
// 
```
--------------------------------
### Handling Complex Arguments
Source: https://github.com/mozex/commonmark-routes/blob/main/resources/boost/skills/commonmark-routes-development/SKILL.md
Wrap helper calls in angle brackets to prevent Markdown parsing conflicts when using named arguments or arrays.
```markdown
[Home]()
[Features]( 'features'])>)
```
--------------------------------
### Handle complex arguments with angle brackets
Source: https://context7.com/mozex/commonmark-routes/llms.txt
Wrap helper calls in angle brackets to prevent special characters from interfering with Markdown parsing.
```php
use League\CommonMark\CommonMarkConverter;
use Mozex\CommonMarkRoutes\RoutesExtension;
$converter = new CommonMarkConverter();
$converter->getEnvironment()->addExtension(new RoutesExtension());
// Angle brackets with simple route
echo $converter->convert("[Home]()")->getContent();
// Home
// Angle brackets with named arguments (recommended for readability)
echo $converter->convert("[Home]()")->getContent();
// Home
// Angle brackets in both link text and URL
echo $converter->convert("[]()")->getContent();
// https://domain.com
// Image with angle brackets
echo $converter->convert("![Logo]()")->getContent();
// 
// url() with angle brackets
echo $converter->convert("[About]()")->getContent();
// About
```
--------------------------------
### Resolving Helpers in Link Text
Source: https://github.com/mozex/commonmark-routes/blob/main/resources/boost/skills/commonmark-routes-development/SKILL.md
The extension independently resolves helper calls found within the link text itself.
```markdown
[route('home')](route('home'))
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.