mindtwo/laravel-markdown

This is my package laravel-markdown

1.0.1 2024-09-10 21:38 UTC

This package is auto-updated.

Last update: 2024-12-10 22:11:23 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

laravel-markdown is a simple, lightweight package for cleaning up and adjusting markdown content in Laravel applications. It provides functionality to remove bold formatting from markdown headlines and dynamically adjust the heading levels in markdown content based on a configurable maximum level. This is especially useful when rendering user-generated content and ensuring consistency in markdown formatting across your application.

Features

  • Remove Bold from Headlines: Automatically strip bold formatting (e.g., **Heading**) from markdown headings.
  • Adjust Headline Levels: Dynamically adjust markdown heading levels (e.g., # to ##, ## to ###, etc.) based on a configurable maximum level.

Installation

You can install the package via composer:

composer require mindtwo/laravel-markdown

Usage

To clean up your markdown content, you can use the CleanupMarkdown class, which handles both removing bold formatting from headlines and adjusting headline levels.

Example

use mindtwo\LaravelMarkdown\CleanupMarkdown;

$markdown = "# **Bold Heading**\n## **Bold Subheading**";
$cleanedMarkdown = (new CleanupMarkdown())->execute($markdown, 2);

echo $cleanedMarkdown;
// Outputs:
// ## Heading
// ### Subheading

In this example, the maximum headline level is set to 2, so all # headings are adjusted to ##, and bold formatting is removed from both headings.

Customization

You can specify the maximum headline level when calling the execute method. This determines how the headline levels will be adjusted:

$cleanedMarkdown = (new CleanupMarkdown())->execute($markdown, 3); // Max headline level is 3

Testing

To run the package's tests, use:

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Contributions are welcome! Please see CONTRIBUTING for details on how to contribute.

Security Vulnerabilities

If you discover any security-related issues, please review our security policy for how to report them.

Credits

License

The MIT License (MIT). Please see License File for more information.