> What we'll need to do to handle more complex markup like this is replace the YouTube HTML tags with placeholders (as we already do with PRE blocks) before doing any further processing.
Can’t the YouTube regex be run after the link regex? Then you can just write the regex to check for any P element containing only a single A element linking to YouTube (or any other video platform). That sounds possible and not too complex. Of course I haven’t worked with the NNF regex for a while so I could be off. Maybe I’ll look into it tonight.
Else we can try not to mess with the NNF source code and write a DOMTemplate extension for the `theme_custom` function, much like I have previously done for gravatars: https://gist.github.com/Zegnat/4088332