Skip to content

CI Markdown is a CodeIgniter library for parsing Markdown to HTML.

Notifications You must be signed in to change notification settings

jonlabelle/ci-markdown

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

85 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CI Markdown

CI Markdown is a modified rendition of Michel Fortin's PHP Markdown and PHP Markdown Extra for CodeIgniter.

Install

Requirements

Download

Download and extract the zip release to your CoddeIgniter application/libraries/ directory.

The extracted path should resemble:

  • application/libraries/Markdown.php

Usage

Configuration

Custom PHP Markdown settings are defined in the config/markdown.php config file.

Initializing the Markdown Class

Like most other classes in CodeIgniter, initialize it from your controller using the $this->load->library() method:

$this->load->library('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' => '/>'
);

$this->load->library('markdown', $config);

Markdown to HTML

  • $this->markdown->transform()

Accepts a single string parameter of Markdown text and returns the transformed HTML.

$this->load->library('markdown');

$markdownText = "# Heading "."\n"."## Sub-heading";
echo $this->markdown->transform($markdownText);
// <h1>Heading</h1>
// <h2>Sub-heading</h2>

Markdown file to HTML

  • $this->markdown->transform_file()

Accepts a single string parameter for a Markdown file path and returns the transformed HTML.

$this->load->library('markdown');

echo $this->markdown->transform_file('/path/to/markdown/file.md');
// <h1>Heading</h1>
// <h2>Sub-heading</h2>

Issues

For all issues including feature requests, please open a new issue.

Changes

See the Changelog page.

Credits