Inside of you are two wolves:

One of them wants to be grammatically correct and put the punctuation inside "the quoted text."

The other one has been programming for 25 years and is howling at the top of its lungs, "I demand proper nesting!".

@andrewrk Many (natural) languages don't have this problem. English just needs to be fixed. We will do this over time.

@phairupegiont @andrewrk
Punctuation in German is similar:

"Punctuation marks that belong to what is reproduced literally are placed before the closing quotation mark.

Punctuation marks that belong to the accompanying clause are placed after the closing quotation mark. Both the quoted sentence and the accompanying sentence retain their exclamation and question marks."

https://german.stackexchange.com/a/74921

Punctuation inside or outside quotes

My question is in regards to how to deal with punctuation and quotes. For instance: „Hallo,“ sagte sie. „Hallo“, sagte sie. Which one is correct? „Hallo?“ sagte sie. „Hallo?“, sagte sie. Whic...

German Language Stack Exchange