Download the PHP package trianity/mparser without Composer
On this page you can find all versions of the php package trianity/mparser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download trianity/mparser
More information about trianity/mparser
Files in trianity/mparser
Package mparser
Short Description A generic content parser that supports the devto markdown format
License MIT
Homepage https://github.com/trianity/mparser
Informations about the package mparser
Trianity Mparser
Trianity Mparser parses Markdown content with optional front matter and support for built-in Liquid-style tags. Markdown is rendered to HTML with league/commonmark.
Current release: 1.0.0
Requirements
- PHP 8.4 or 8.5
- Composer
Installation
Usage
ContentParser::parse() stores the parsed front matter and Markdown body in the Content object. Pass true as the second argument to also render the body as HTML.
Front matter
Front matter uses a simple YAML-like key: value format between two --- lines. The parsed values can be read and changed with:
After changing the front matter, call updateRaw() to rebuild the raw content.
Built-in tags
The following tags are registered by default:
| Tag | Example | Output |
|---|---|---|
| Video | {% video /videos/test.mp4 %} |
HTML5 video element |
| Audio | {% audio /audio/test.mp3 %} |
HTML5 audio element |
| YouTube | {% youtube Pfkp-lrJTWM %} |
YouTube iframe |
Custom tags
Custom tags implement Trianity\Mparser\CustomTagParser and receive the tag value as a string:
The tag can then be used as {% callout Important notice %}.
Tests
Install the development dependencies and run the Pest test suite:
License
This project is licensed under the MIT License. See LICENSE.