Formatting
Flarum uses the powerful s9e TextFormatter library to format posts from plain markup into HTML. You should become familiar with how TextFormatter works before you attempt to extend it.
In Flarum, post content is formatted with a minimal TextFormatter configuration by default. The bundled Markdown and BBCode extensions simply enable the respective plugins on this TextFormatter configuration.