There are actually 4 ways manufacturers do it. Something like the Disaster Area Designs[1] MIDI Box is a necessity once you start dealing with guitar effects pedals.
[1]: https://www.disasterareadesigns.com/shop/p/midi-box-4
I've had A/B solved by just schottky rectifier and low enough current optocoupler, but damn ,didn't knew there is even more to that mess
I've had A/B solved by just schottky rectifier and low enough current optocoupler, but damn ,didn't knew there is even more to that mess