Introduction | laravel-markdown-go | Spatie       

 SPATIE  

laravel-markdown-go
===================

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-markdown-go](https://spatie.be/docs/laravel-markdown-go/v1)  Introduction

 Version   v1      

 Other versions for crawler [v1](https://spatie.be/docs/laravel-markdown-go/v1) 

  Introduction    
- [ Introduction ](https://spatie.be/docs/laravel-markdown-go/v1/introduction)
- [ Support us ](https://spatie.be/docs/laravel-markdown-go/v1/support-us)
- [ Requirements ](https://spatie.be/docs/laravel-markdown-go/v1/requirements)
- [ Installation &amp; setup ](https://spatie.be/docs/laravel-markdown-go/v1/installation-setup)
- [ Questions and issues ](https://spatie.be/docs/laravel-markdown-go/v1/questions-issues)
- [ Changelog ](https://spatie.be/docs/laravel-markdown-go/v1/changelog)
- [ Resources and alternatives ](https://spatie.be/docs/laravel-markdown-go/v1/resources-and-alternatives)
- [ About us ](https://spatie.be/docs/laravel-markdown-go/v1/about-us)
- [ Testing ](https://spatie.be/docs/laravel-markdown-go/v1/testing)
- [ Releasing ](https://spatie.be/docs/laravel-markdown-go/v1/releasing)

Usage in templates
------------------

- [ General usage ](https://spatie.be/docs/laravel-markdown-go/v1/usage-in-blade/general-usage)
- [ Configuring code highlighting ](https://spatie.be/docs/laravel-markdown-go/v1/usage-in-blade/configuring-code-highlighting)
- [ Rendering anchors ](https://spatie.be/docs/laravel-markdown-go/v1/usage-in-blade/rendering-anchors)
- [ Adding custom attributes ](https://spatie.be/docs/laravel-markdown-go/v1/usage-in-blade/adding-custom-attributes)
- [ Passing options to Commonmark ](https://spatie.be/docs/laravel-markdown-go/v1/usage-in-blade/passing-options-to-commonmark)

Rendering markdown
------------------

- [ General usage ](https://spatie.be/docs/laravel-markdown-go/v1/rendering-markdown/general-usage)
- [ Configuring code highlighting ](https://spatie.be/docs/laravel-markdown-go/v1/rendering-markdown/configuring-code-highlighting)
- [ Rendering anchors ](https://spatie.be/docs/laravel-markdown-go/v1/rendering-markdown/rendering-anchors)
- [ Passing options to Commonmark ](https://spatie.be/docs/laravel-markdown-go/v1/rendering-markdown/passing-options-to-commonmark)

Advanced usage
--------------

- [ Highlighting lines ](https://spatie.be/docs/laravel-markdown-go/v1/advanced-usage/highlighting-lines)
- [ Caching results ](https://spatie.be/docs/laravel-markdown-go/v1/advanced-usage/caching-results)
- [ Customizing the rendering process ](https://spatie.be/docs/laravel-markdown-go/v1/advanced-usage/customizing-the-rendering-process)

  Laravel-markdown-go 
=====================

 A highly configurable Markdown renderer for Laravel Go 

### Useful links

- [Repository](https://github.com/spatie/laravel-markdown-go)
- [Discussions](https://github.com/spatie/laravel-markdown-go/discussions)

Introduction
------------

###  On this page 

1. [ Differences from PHP ](#content-differences-from-php)

This package contains:

- a template function and component that can render markdown
- a highly configurable renderer that you can use to render markdown

Let's start with an example of the provided `markdown::markdown` component:

```
{{template "markdown::markdown" (dict "Source" .Body)}}
```

With `# My title` as the body, this produces:

```
<div><h1 id="my-title">My title</h1>
</div>
```

You can also programmatically render HTML. By resolving the service from the request, all options of the package configuration will be used:

```
html, err := markdown.From(r).ToHTML(r, source)
```

Out of the box, the component and renderer can:

- highlight code blocks with [Chroma](https://github.com/alecthomas/chroma), without Node or Shiki
- add anchor links to headings
- cache results to increase performance

Start with [installation &amp; setup](installation-setup), then read [usage in templates](usage-in-blade/general-usage) or [rendering markdown](rendering-markdown/general-usage).

Differences from PHP
--------------------------------------------------------------------------------------------------------------------

The docs keep the PHP package's page hierarchy. The `usage-in-blade` paths now describe Go templates, since Laravel Go does not run Blade. Goldmark replaces league/commonmark, so parser options and extension types use Goldmark's API. Chroma uses its own theme names and XML styles rather than VSCode themes.

Raw HTML and unsafe URLs are omitted by default. `UnsafeHTML` opts into trusted editorial HTML. Extensions and replacement renderers are trusted application code and must escape their own output. Markdown is never executed as a template program.

Heading IDs are unique within each document. Permalinks sit inside headings rather than wrapping a heading, which avoids nesting links around headings containing links. Caching defaults to one hour rather than forever, since Laravel Go requires a finite lifetime. See [caching results](advanced-usage/caching-results).

 A good
match?
-------------

### What we do best

- All things Laravel
- Custom frontend components
- Building APIs
- AI-powered features
- Simplifying things
- Clean solutions
- Integrating services

### Not our cup of tea

- WordPress themes
- Cutting corners
- Free mockups to win a job
- "Just execute the briefing"

 In short: we'd like to be a **substantial part** of your project.

 [ Get in touch via email ](mailto:info@spatie.be?subject=A%20good%20match%21&body=Tell%20us%20as%20much%20as%20you%20can%20about%0A-%20your%20online%20project%0A-%20your%20planning%0A-%20your%20budget%0A-%20%E2%80%A6%0A%0AAnything%20that%20helps%20us%20to%20start%20straightforward%21)
