CI Markdown is a modified rendition of Michel Fortin's PHP Markdown and PHP Markdown Extra for CodeIgniter.
- PHP version 8.1 or newer
- CodeIgniter version 4.5.x
Download and extract the ZIP release to your CodeIgniter
app
directory.
The extracted paths should resemble:
app/Libraries/Markdown.php
app/Config/Markdown.php
Custom PHP Markdown settings are defined in the Config/Markdown.php config file.
Like most other classes in CodeIgniter, initialize it from your controller
using the Factories::libraries();
method:
Factories::libraries('Markdown');
To programmatically configure the Markdown instance, overriding any matched settings defined in the config file:
$config = array(
'tab_width' => 2,
'no_markup' => true
'empty_element_suffix' => '/>'
);
$markdown = Factories::libraries('Markdown', [], $config);
$markdown->transform()
Accepts a single string
parameter of Markdown text and returns the
transformed HTML.
$markdown = Factories::libraries('Markdown');
$markdownText = "# Heading "."\n"."## Sub-heading";
echo $markdown->transform($markdownText);
// <h1>Heading</h1>
// <h2>Sub-heading</h2>
$markdown->transform_file()
Accepts a single string
parameter for a Markdown file path and returns the
transformed HTML.
$markdown = Factories::libraries('Markdown');
echo $markdown->transform_file('/path/to/markdown/file.md');
// <h1>Heading</h1>
// <h2>Sub-heading</h2>
- John Gruber's PHP Markdown Syntax Guide
- John Gruber's PHP Markdown Converter
- Michel Fortin's PHP Markdown Extra Syntax Guide
For all issues including feature requests, please open a new issue.
See the Changelog page.