mindtwo / laravel-markdown
This is my package laravel-markdown
Fund package maintenance!
mindtwo
Requires
- php: ^8.2
- illuminate/contracts: ^10.0||^11.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^2.9
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^9.0.0||^8.22.0
- pestphp/pest: ^2.34
- pestphp/pest-plugin-arch: ^2.7
- pestphp/pest-plugin-laravel: ^2.3
- pestphp/pest-plugin-watch: ^2.1
- phpstan/extension-installer: ^1.3
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-phpunit: ^1.3
README
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.