Installation &amp; setup | 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)  Installation &amp; setup

 Version   v1      

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

  Installation &amp; setup    
- [ 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)

 Installation &amp; setup
========================

You can install the package with Go modules:

```
go get github.com/spatie/laravel-markdown-go@v0.1.0
```

Add the package explicitly in `bootstrap/app.go`. Installing the module alone does not activate it:

```
package bootstrap

import (
    markdown "github.com/spatie/laravel-markdown-go"
    laravel "go.laravel.com"
)

func Options() laravel.Options {
    return laravel.Options{
        Packages: []laravel.Package{markdown.New()},
    }
}
```

To enable code highlighting, no extra executable or JavaScript package is needed. Chroma is included in the compiled Go program.

There is no config file to publish. Pass a callback to change the defaults:

```
markdown.New(func(cfg *markdown.Config) {
    cfg.Options.HighlightCode = true
    cfg.Options.RenderAnchors = true
    cfg.Options.RenderAnchorsAsLinks = false
    cfg.Options.CodeAnnotations = true
    cfg.Options.FrontMatter = false
    cfg.Options.UnsafeHTML = false
    cfg.CacheEnabled = true
    cfg.CacheStore = ""
    cfg.CacheDuration = time.Hour
})
```

Import `time` for duration values. `Options.Theme` defaults to Chroma's `github`style and `DarkTheme` is absent. `Options.Configure` adds extensions, custom renderers and inline parsers. `Config.RendererFactory` can replace the entire rendering process. See [customizing the rendering process](advanced-usage/customizing-the-rendering-process).

These environment settings are read before your configuration callback:

VariableDefault`MARKDOWN_HIGHLIGHT_CODE``true``MARKDOWN_THEME``github``MARKDOWN_ANCHORS``true``MARKDOWN_ANCHOR_LINKS``false``MARKDOWN_CODE_ANNOTATIONS``true``MARKDOWN_FRONT_MATTER``false``MARKDOWN_CACHE_ENABLED``true``MARKDOWN_CACHE_STORE`empty, the application's default`MARKDOWN_CACHE_SECONDS``3600`Invalid booleans and integers stop startup. Unknown themes and negative cache durations are errors. Configuration belongs to each application, not global state.

 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)
