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 At this point the first wolf has moved on.

But in any case, punctuation isn't part of grammar, so it's not going to affect grammatical correctness.

How did thou come to that conclusion, @typeswitch? Punctuation is as important as words (or identifiers) to deliver meaning, whether it's a formal or natural language. There are cases like the example given by @andrewrk where there is more than one way to express the same thing without ambiguity, but in general, misuse of punctuation is gonna give Godzilla a stronk.
@cnx @typeswitch @andrewrk punctuation is covered by "orthography".