I knew I wanted to have some sort of simple text editing with this blog. Rendering out the body text was going to take some basic conversion from CR-LF to HTML br tags was going to be required. I was at a meetup recently where the presenter had talked about how he had shifted his own personal note taking over to using Markdown, exclusively. Markdown sounded like the way to go.
That said, I was tripping over myself trying to get it integrated. I have noticed that there are many add-ons for PHP that use Composer to install and load the add-on. I haven't had much luck with getting this working on my WAMP server at home. Probably another round of learning needed on another day.
After some trial and error, I was able to get it all working. I needed this at the start of the view post page:
require_once 'Michelf/MarkdownExtra.inc.php'; use Michelf\MarkdownExtra;
I am using MarkdownExtra as I need the code block support to post things like this exact post. It only took 2 lines to call the Markdown to HTML transform.
$parser = new MarkdownExtra; $postBody = $parser->transform($postBody);
$postBody was read from the database, then transformed before rendering.