Recommend this page to a friend! |
![]() ![]() |
Info | ![]() |
![]() |
![]() ![]() |
Reputation | Support forum (1) | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2023-08-15 (1 month ago) ![]() | Not yet rated by the users | Total: 25 This week: 4 | All time: 10,958 This week: 29![]() |
Version | License | PHP version | Categories | |||
markdownify 1.0 | MIT/X Consortium ... | 5 | HTML, PHP 5, Text processing, Parsers |
Description | Author | |||
This package can parse and render Github-flavored markdown as HTML. Innovation Award
|
|
MarkDownify is a PHP library that simplifies the process of parsing Markdown into HTML code. It provides compatibility with the specifications of GitHub Flavored Markdown, making it a versatile tool for working with Markdown content.
You can install MarkDownify via Composer. Run the following command:
composer require kuasarx/markdownify
To use MarkDownify in your PHP project, follow these steps:
Require the autoloader generated by Composer:
require 'vendor/autoload.php';
Create a new instance of the `MarkDownify` class:
use MarkDownify\MarkDownify;
$text = "Your Markdown content";
$parser = new MarkDownify($text);
Parse the Markdown content into HTML:
$html = $parser->parse();
Here's how you can add CSS to the page to achieve a GitHub-like look: - Include GitHub Markdown CSS
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/github-markdown-css@4.0.0/github-markdown.min.css">
echo '<div class="markdown-body">' . $html . '</div>';
use MarkDownify\MarkDownify;
// Markdown content
$text = "# Hello, MarkDownify!\n\nThis is bold and italic text.";
// Create a new instance of MarkDownify
$parser = new MarkDownify($text);
// Parse Markdown into HTML
$html = $parser->parse();
echo $html;
use MarkDownify\MarkDownify;
// Markdown content with a task list
$text = "- [x] Task 1\n- [ ] Task 2\n- [x] Task 3";
// Create a new instance of MarkDownify
$parser = new MarkDownify($text);
// Parse Markdown into HTML
$html = $parser->parse();
echo $html;
use MarkDownify\MarkDownify;
// Markdown content with a table
$text = "| Name | Age | Gender |\n|-------|-----|--------|\n| John | 30 | Male |\n| Alice | 25 | Female |";
// Create a new instance of MarkDownify
$parser = new MarkDownify($text);
// Parse Markdown into HTML
$html = $parser->parse();
echo $html;
MarkDownify is released under the MIT License. See LICENSE for more information.
![]() |
File | Role | Description | ||
---|---|---|---|---|
![]() |
||||
![]() |
Data | Auxiliary data | ||
![]() |
Lic. | License text | ||
![]() |
Doc. | Documentation |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.