Download the PHP package erikaheidi/parsed without Composer
On this page you can find all versions of the php package erikaheidi/parsed. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download erikaheidi/parsed
More information about erikaheidi/parsed
Files in erikaheidi/parsed
Package parsed
Short Description A generic content parser that supports the devto markdown format
License MIT
Homepage https://github.com/librarianphp/parsed
Informations about the package parsed
Parsed
A generic content parser based on the devto post format, with front matter and liquid tag support. Parsed uses league/commonmark as base markdown parser.
Current liquid tags implemented:
- HTML Video embed (mp4):
{% video path_to_video.mp4 %}
- HTML Audio embed (mp3):
{% audio path_to_audio.mp3 %}
- Twitter embed:
{% twitter tweet_id %}
- Youtube video embed:
{% youtube video_id %}
- GitHub File (Gists not supported atm):
{% github full_path_to_repo_file %}
More to come, contributions welcome.
Installation
Usage Examples
Obtaining Front Matter
There are two methods to work with the front matter: frontMatterHas
and frontMatterGet
:
Creating Custom Liquid Tags
Liquid tags are classes that implement the CustomTagParserInterface
. They need to implement a method named parse
, which receives the string provided to the liquid tag when called from the markdown file.
For instance, this is the full code for the video
liquid tag parser class:
You'll have to include your custom tag parser class within the ContentParser:
Note: The built-in tag parsers are already registered within ContentParser. These are: video
, audio
, twitter
, youtube
and github
.
For instance, if you have in your markdown:
It will convert to the tag into the following code:
Tests
Parsed uses Pest as testing framework. To run the tests:
All versions of parsed with dependencies
ext-json Version *
minicli/curly Version ^0.2.0
league/commonmark Version ^2.0
minicli/stencil Version ^0.1.1