Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jbroadway/slimdown
A simple regex-based Markdown parser in PHP.
https://github.com/jbroadway/slimdown
html markdown parser parsing php regex regexp
Last synced: 1 day ago
JSON representation
A simple regex-based Markdown parser in PHP.
- Host: GitHub
- URL: https://github.com/jbroadway/slimdown
- Owner: jbroadway
- License: mit
- Created: 2022-02-27T22:52:13.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-08-06T15:29:18.000Z (3 months ago)
- Last Synced: 2024-11-11T23:35:59.739Z (3 days ago)
- Topics: html, markdown, parser, parsing, php, regex, regexp
- Language: PHP
- Homepage:
- Size: 52.7 KB
- Stars: 32
- Watchers: 3
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Slimdown
![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/jbroadway/slimdown/ci.yml?branch=master)
![GitHub License](https://img.shields.io/github/license/jbroadway/slimdown)
![Packagist Version](https://img.shields.io/packagist/v/jbroadway/slimdown)
![Packagist PHP Version Support](https://img.shields.io/packagist/php-v/jbroadway/slimdown)A simple regex-based Markdown parser in PHP. Supports the
following elements (and can be extended via `Slimdown::add_rule()`):* Headers
* Links
* Bold
* Emphasis
* Deletions
* Quotes
* Code blocks
* Inline code
* Blockquotes
* Ordered/unordered lists
* Checklists
* ImagesOriginally hosted as a [gist here](https://gist.github.com/jbroadway/2836900).
## Usage
Here is the general use case:
```php
\2');echo Slimdown::render ('Know what I\'m sayin? :)');
```In this example, we add GitHub-style internal linking
(e.g., `[[Another Page]]`).```php
%s',
preg_replace ('/[^a-zA-Z0-9_-]+/', '-', $title),
$title
);
}Slimdown::add_rule ('/\[\[(.*?)\]\]/e', 'mywiki_internal_link (\'\\1\')');
echo Slimdown::render ('Check [[This Page]] out!');
```### A longer example
```php
A block quote
> across two lines.- [ ] One
- [x] Two
- [ ] ThreeMore text...");
```