SPATIE
  • Products
  • Open Source
  • Courses
  • Web Development
VacanciesAboutBlogDocsGuidelines Log in

Docs Laravel-markdown Usage-in-blade

Edit
Other versions for crawler v1
    • Introduction
    • Support us
    • Requirements
    • Installation & setup
    • Questions and issues
    • Changelog
    • Resources and alternatives
    • About us

    Usage in Blade

    • General usage
    • Configuring code highlighting
    • Rendering anchors
    • Passing options to Commonmark

    Rendering markdown

    • General usage
    • Configuring code highlighting
    • Rendering anchors
    • Passing options to Commonmark

    Advanced usage

    • Highlighting lines
    • Caching results
    • Customizing the rendering process

The markdown given to the x-markdown component will be converted by the class specified in the renderer_class value of the markdown config file.

You can change this value to a class of your own. We highlight recommend that your class extends the default Spatie\LaravelMarkdown\MarkdownRenderer class. This default class is organised using easy to override methods.

Here's an example. If you want to customize the environment of the league/commonmark package that is used under the hood, override the configureCommonMarkEnvironment method.

use League\CommonMark\ConfigurableEnvironmentInterface;use Spatie\LaravelMarkdown\MarkdownRenderer;

class MyCustomRenderer extends MarkdownRenderer
{
    public function configureCommonMarkEnvironment(ConfigurableEnvironmentInterface $environment) : void
    {
        parent::configureCommonMarkEnvironment($environment);
        
        // customize the `$environment` here.
    }
}
Learn how to write quality tests in Pest and PHPUnit in our video course Testing Laravel
  • Products
  • Open Source
  • Courses
  • Web Development
VacanciesAboutBlogDocsGuidelines Log in

Kruikstraat 22, Box 12
2018 Antwerp, Belgium
info@spatie.be
+32 3 292 56 79
  • GitHub
  • Instagram
  • Twitter
  • YouTube
  • Privacy
  • Disclaimer

+32 3 292 56 79

Our office is closed now, email us instead

    Enter a search term to find results in the documentation.