There is a description of how Dokuwiki parses files:
https://www.dokuwiki.org/devel:parser. While I understand the basic processes, I've never had the patience to master the details. But if you simply want to change the output of the parser, i.e. the HTML that it produces, you can create a renderer plugin:
https://www.dokuwiki.org/devel:renderer_plugins. In effect, renderers are an extension of the renderer type they are replacing, xhtml or metadata. So you only have to implement the class methods which you want to affect. Check parser/xhtml.php for all of the possible methods (and their parameters) and then look at some of the renderer plugins, to see what others have done.