Installation | laravel-markdown-rust | Spatie       

 SPATIE  

laravel-markdown-rust
=====================

spatie.be/open-source

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

 Version   v1      

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

  Installation    
- [ Introduction ](https://spatie.be/docs/laravel-markdown-rust/v1/introduction)
- [ Support us ](https://spatie.be/docs/laravel-markdown-rust/v1/support-us)
- [ Installation ](https://spatie.be/docs/laravel-markdown-rust/v1/installation-and-setup)
- [ Usage ](https://spatie.be/docs/laravel-markdown-rust/v1/usage)
- [ Extensions and front matter ](https://spatie.be/docs/laravel-markdown-rust/v1/extensions)
- [ Testing ](https://spatie.be/docs/laravel-markdown-rust/v1/testing)
- [ Changelog ](https://spatie.be/docs/laravel-markdown-rust/v1/changelog)
- [ Views and components ](https://spatie.be/docs/laravel-markdown-rust/v1/views)

 Installation
============

###  On this page 

1. [ Register the package ](#content-register-the-package)
2. [ Environment settings ](#content-environment-settings)

- Requires Rust 1.99 or newer. Install Rust using [rustup](https://rustup.rs/).
- This crate is not published on crates.io. Use a Git dependency and commit `Cargo.lock`:

```
[dependencies]
spatie-laravel-markdown = { git = "https://github.com/spatie/laravel-markdown-rust", features = ["views"] }
```

- The package uses `laravel-rust =0.1.0` with default features disabled and a pinned public revision of `spatie-laravel-package-tools`.
- Enable application features on the application's own Laravel dependency.
- Omit `features = ["views"]` when the application does not use templates. This feature enables the framework's own MiniJinja engine.

Register the package
--------------------------------------------------------------------------------------------------------------------

Add the service provider to install `MarkdownConfig` from the environment and bind `MarkdownRenderer` using the final application configuration:

```
use laravel::{Application, config::Env};
use spatie_markdown::{MarkdownConfig, service_provider};

let app = Application::configure()
    .replace_env(Env::default())
    .with_providers(|providers| {
        providers.add(service_provider());
    })
    .create();
```

- Application `with_config` hooks run after package defaults, so they can replace the typed section or adjust its renderer.
- Application `with_services` hooks can replace the renderer binding. This does not change `MarkdownConfig::renderer`; use the same configured renderer for both when desired.
- No global renderer, cache store or template helper is installed. Configure a named `markdown` cache store if rendered HTML needs separate storage.
- Manual `config.set(MarkdownConfig::from_env(env))` remains supported when you do not use the provider.

Environment settings
--------------------------------------------------------------------------------------------------------------------

`MarkdownConfig::from_env` reads:

- `MARKDOWN_HIGHLIGHT_CODE` and `MARKDOWN_ANCHORS`, both `true` by default.
- `MARKDOWN_ANCHOR_LINKS`, `MARKDOWN_GITHUB_FLAVORED`, `MARKDOWN_FRONT_MATTER` and `MARKDOWN_CODE_ANNOTATIONS`, all `false` by default.
- `MARKDOWN_THEME`, an optional bundled theme name. Without it, highlighting uses CSS classes.
- `MARKDOWN_CACHE_ENABLED`, `true` by default for `MarkdownConfig::render`.
- `MARKDOWN_CACHE_STORE`, an optional named native store. Without it, the application's default store is used.
- `MARKDOWN_CACHE_SECONDS`, `3600` by default. Zero bypasses caching.
- Read the section through `laravel::config().section::<MarkdownConfig>()` or inject `laravel::config::Section<MarkdownConfig>` into a handler.
- Invalid typed environment values participate in the framework's startup validation.
- `MarkdownRenderer::to_html` never uses configuration or caching implicitly.
- Cache repositories require a finite TTL. Disabling caching avoids resolving a repository at all.
- Bundled grammars require no system regex library, Node installation or external process.
- Dependency and grammar updates can change rendered output. Bump the package version before reusing a shared cache after an output change.

 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)
