i guess we will agree to disagree. Maybe leaning out and attacking is RAI. I have no idea. I only know what is written and the rules say nothing about revealing and attacking being simultaneous.
How else can you you attack from hiding
without revealing yourself at the same time?
The rules allow for a hidden creature sniping you from a hiding spot (with advantage) however it is explicitly the attack that reveals them, not the 'popping out'.
If the creature didn't snipe you from hiding, and instead stood up and waved, then walked over to you while juggling and bemoaning his marital problems at home (after you were momentarily startled) he ceases being hidden.
You're placing all these artificial parsing and convoluted exceptions into a general rule that's intended to be applied by the DM using common sense.
Here is how I interpret the rules for Hiding to work, taking into account the RAW, RAI and Sage advice tweets on the topic:
1. Can I (in full view of the Ogre, who is observing me closely and not otherwise distracted) move behind a pillar in a room (obtaining total cover in the process) and Hide?
No. The Ogre knows where you are, saw you go into your little hiding spot, and accordingly you cant take the Hide action relative to the Ogre.
2. Can I do it while the Ogre is distracted (maybe by my Half Orc Barbarian friend trying to carve him a new smile with a 20lb flaming axe) and not watching me carefully?
Probably, but with disadvantage.
3. Can I do it before the Ogre enters the room, when he is unaware of me, or while he is not observing me at all such as by having his back to me?
Yes.
4. Assuming I'm hidden from the Ogre behind the pillar, can I snipe him from the pillar?
Yes, but you reveal your location the instant the attack is resolved (hit or miss).
5. If I am hidden relative to the Ogre, how can the Ogre find me? Either by taking the
Search action and rolling higher that your Stealth result on a Perception check, or occasionally by virtue of a lucky (or educated) guess.
6. What if I'm a halfling or wood elf? Does this change anything?
Yes, in addition to the pillars in the room, you can also attempt to hide behind a Medium or larger sized creature (halfling) or any light natural obscurement present in the room (elf). All the other restrictions on hiding remain the same (you cant attempt to Hide while you're being directly observed etc).
7. What about if I have the
Skulker feat? Firstly this feat enables you to Hide in light obscurement (shadows and so forth) similar to the wood elf ability (all other restrictions on hiding still apply, and you still cant attempt to Hide while under direct observation). Secondly, you don't automatically reveal your position when you snipe from a hidden spot unless you actually hit your target. The shot might tip them off to your presence however (if they weren't already aware of it) and they might come looking for you (via the Search action, or a lucky guess).
Its not rocket science. Its just common sense.