mistle welcome to Flarum !
This is the library used to parse posts in Flarum https://s9etextformatter.readthedocs.io/
Some of the features (markdown, bbcode, emojis, ...) are enabled by Flarum itself. Other features are enabled via extensions like FoF Formatter.
I don't think the library includes support for Mermaid content. However the library is extensible, so it should be possible for a developer to create a third-party extension that adds Mermaid support to Flarum.