Package Data | |
---|---|
Maintainer Username: | spatie |
Maintainer Contact: | freek@spatie.be (Freek Van der Herten) |
Package Create Date: | 2021-07-11 |
Package Last Update: | 2024-11-12 |
Home Page: | https://freek.dev/2024-how-to-render-markdown-with-perfectly-highlighted-code-snippets |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-17 03:06:26 |
Package Statistics | |
---|---|
Total Downloads: | 1,315,401 |
Monthly Downloads: | 76,106 |
Daily Downloads: | 1,440 |
Total Stars: | 338 |
Total Watchers: | 3 |
Total Forks: | 31 |
Total Open Issues: | 0 |
This package contains:
Let's start with an example of the provided x-markdown
Blade component. This chunk of markdown...
<x-markdown>
# My title
This is a [link to our website](https://spatie.be)
```php
echo 'Hello world';
```
</x-markdown>
... will be converted by to component to this chunk of HTML:
<div>
<h1 id="my-title">My title</h1>
<p>This is a <a href="https://spatie.be">link to our website</a></p>
<pre class="shiki" style="background-color: #fff"><code><span class="line"><span
style="color: #005CC5">echo</span><span style="color: #24292E"> </span><span style="color: #032F62">'Hello world'</span><span
style="color: #24292E">;</span></span>
<span class="line"></span></code></pre>
</div>
You can also programmatically render HTML.
// by resolving the class out of the container all the options
// in the config file will be used.
app(Spatie\LaravelMarkdown\MarkdownRenderer::class)->toHtml($markdown);
Out of the box, the x-markdown
component and MarkdownRenderer
can:
We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.
You can find installation instructions and detailed instructions on how to use this package at the dedicated documentation site.
If you only need the league/commonmark extension to highlight code, head over to spatie/commonmark-shiki-highlighter.
In case you don't need the markdown support, but want to highlight code directly, take a look at spatie/shiki-php.
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
If you don't want to install and handle Shiki yourself, take a look at Torchlight, which can highlight your code with minimal setup.
The MIT License (MIT). Please see License File for more information.