CodeIgniter Forums
Markdown Pages for CodeIgniter 4 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Addins (https://forum.codeigniter.com/forumdisplay.php?fid=34)
+--- Thread: Markdown Pages for CodeIgniter 4 (/showthread.php?tid=92246)



Markdown Pages for CodeIgniter 4 - michalsn - 12-31-2024

This library allows you to use Markdown files as pages in your CodeIgniter 4 application. It dynamically converts Markdown content to HTML and serves it as web pages, making it ideal for static content like documentation or simple sites.

GitHub Repository: codeigniter-markdown-pages

Installation:
Code:
composer require michalsn/codeigniter-markdown-pages

Example Usage:
PHP Code:
$markdownPages  service('markdownpages'APPPATH 'Views/markdown');
$file $markdownPages->file('first-steps/second-file');
// returns "Second File"
$file->getName();
// returns parsed markdown
$file->parse()->getContent();
// returns parsed meta from YAML part of the file

$file->parse()->getMeta(); 

Docs:

https://michalsn.github.io/codeigniter-markdown-pages/


RE: Markdown Pages for CodeIgniter 4 - gosocial2 - 12-31-2024

I ran into this post at a time I was looking for a CI4 alternative to laravel-markdown. Awesome news.

Does it also feature a solution for code syntax highlighting?


RE: Markdown Pages for CodeIgniter 4 - michalsn - 12-31-2024

By default, it uses the League CommonMark parser. But you can use a different parser or extension for CommonMark, like Github-Flavored Markdown.

I will try to add an example to the docs tomorrow.


RE: Markdown Pages for CodeIgniter 4 - michalsn - 01-01-2025

(12-31-2024, 08:58 AM)gosocial2 Wrote: I ran into this post at a time I was looking for a CI4 alternative to laravel-markdown.

Oh... it's not really an alternative. This package only works with static files.

If you want to parse markdown you can just use CommonMark parser alone. Create a service and use it - simple as that.

In case anyone needs to use a different parser, here is an example of how to set it up: https://michalsn.github.io/codeigniter-markdown-pages/extending/