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: 2 months 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 3 years ago)
- Default Branch: master
- Last Pushed: 2024-08-06T15:29:18.000Z (11 months ago)
- Last Synced: 2025-04-06T19:59:22.414Z (3 months ago)
- Topics: html, markdown, parser, parsing, php, regex, regexp
- Language: PHP
- Homepage:
- Size: 52.7 KB
- Stars: 32
- Watchers: 3
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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...");
```