Injecting classes into normal tag output by Kirbytext

Is there an easy way to inject/add classes to the Kirbytext/Markdown output?

I recently adopted the BEM methodology (which I wholeheartedly recommend btw – it made my CSS layout workflow much faster) to structure my SASS/CSS and ideally, if you follow BEM strictly, you’re not supposed to style basic selectors or selector chains anymore.

So for example, instead of a raw p tag, I’d like Kirby to output something like this:

<p class="bodytext__p"> … </p>

Ideally I would be able to change what class name is used from one context, i.e. template, to the other.

Is there really no way to achieve that, other than writing my own special wrapper function, that does lots of regular expression parsing and replacing? Doing that seems a bit of over the top to me. “Mit Kanonen auf Spatzen schießen”, as I would say in German. :wink:

Anything I’m missing here? Some genius hidden technique? Thanks for any info in advance!

There is a plugin for that:

Don’t think this works on a template/blueprint basis, though.

Yeah, I know about this plugin. Unfortunately it is pretty rigid. As you said, there is no way to modify the classes it outputs depending on context.

I guess for the time being I’ll stick to not using strict BEM on Markdown output.