VOOZH about

URL: https://spatie.be/docs/laravel-markdown/v1/introduction

⇱ Introduction | laravel-markdown | Spatie


Laravel Markdown

Markdown renderer and Blade component for Laravel
4,062,251
409

Introduction

On this page

  1. We have badges!

This package contains:

  • a Blade component that can render markdown
  • a highly configurable class that you can use to render markdown

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 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">&#39;Hello world&#39;</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 or MarkdownRenderer can:

  • highlight code blocks correctly (via Shiki PHP) for 100+ languages, including PHP, JS, Blade, and many more.
  • add anchor links to headings
  • cache results to increase performance

We have badges!

👁 Latest Version
👁 Software License
👁 Total Downloads
Help us improve this page