Note: pedantic typophile here, so don't mind the details.
First, the logic.
When sections of text of different languages [domains] are mixed, they can occur side-by-side as equals, or one section could be embedded within another [which is the typical case].
Language identification is pretty straightforward in most scenarios, eg:
The grammar of this very sentence is English, even if we embed right-to-left inline Arabic text like أبجد هوز
within it.
Within the text أبجد هوز
there should be no English punctuation nonsense. Not unless you happen to be re-embedding English text within the Arabic text, eg:
We can embed inline Arabic text which itself has embedded inline English text, eg قائلا أن Google Chrome is good هو الحق.
, within a main English text like how it's done in this very sentence.
Now consider instead of inline embedding, we do "block-level" embedding:
The grammar of this very sentence is English, even if we embed right-to-left "block-level" Arabic text like:
هذا نص على مستوى الكتلة الطويلة باللغة العربية. هذا نص على مستوى الكتلة الطويلة باللغة العربية.
..within it.
The outer English sentence may even contain no furthur text after embedding the block-level Arabic text, eg:
This very sentence ends with a block-level Arabic text, after this embedded text:
هذا نص على مستوى الكتلة الطويلة باللغة العربية. هذا نص على مستوى الكتلة الطويلة باللغة العربية.
And this very sentence is a new sentence after the embedded block-level Arabic text.
We can surmise that for English grammar, terminating punctuation marks are optional after block-level embeds (cf. 1) (cf. 2a) (cf. 2b) (cf. 3) (cf. 4) (cf. 5) (cf. 6) (cf. 7a) (cf. 7b) (cf. 8) (cf. 9) (cf. 10).
If an editor insists on having optional fullstops shown, eg:
Assume we have an editor who insists on having a fullstop after this block-level embed:
هذا نص على مستوى الكتلة الطويلة باللغة العربية. هذا نص على مستوى الكتلة الطويلة باللغة العربية.
. Said fullstop can be produced as desired, as seen right before this very sentence.
..readers will find it jarring because it's atypical for stray English punctuations to appear as the first text of the line as they would normally be kerned with the preceding text.
Hence, to make it appear less jarring to readers, we should too kern the fullstop with the preceding text [the block-level Arabic text], as such:
This very sentence has its fullstop kerned with the text before the fullstop [the block-level Arabic text]:
هذا نص على مستوى الكتلة الطويلة باللغة العربية.
.
Look carefully at the previous sentence before this very sentence. It ends with a fullstop which is kerned with the block-level Arabic text embed before it.
Also see "Widows and orphans".
Now, on to Maths text.
The concept we outlined for foreign text within English text applies regardless of the interacting languages. For block-level maths text embedded within English text, the syntax thus looks like:
Just as with the Arabic text, there are distinct non-overlapping areas allocated to the text of each language. There's no logical sense if the grapheme(s) of the outer language [English text] appears within the area allocated to the embedded language [Maths text]:
In fact, it is so senseless that a quick reader can't easily tell if the grapheme refers to a punctuation of the outer text [English], or if the grapheme is actually part of the embedded text [Maths] itself.
So, applying the concepts mentioned, we can either have a stray fullstop after the block-level embed:
..or we can kern the punctuation with the block-level embed preceding it:
..or we can go without the fullstops altogether (My preferred solution.). With the context of the text, and the capitalization of the next English sentence right after the Maths text, ambiguity is almost non-existent:
Consider this text:
$$x^2 + y^2 = r^2$$
Even if the reader does not see a fullstop after the Maths text, it's obvious that this very sentence is a full standalone sentence and the embedded Maths text is not part of this sentence.
..and:
Consider this text:
$$x^2 + y^2 = r^2$$
..which is a basic equation. Since the English text after the Maths text begins with a two-dot ellipsis, it's obvious to the reader that the English text which continues after the Maths text belongs to the same sentence as the Maths text.
The end.
More on MathJax.
You can produce punctuation kerning in Stackexchange posts using a combination of vertical spacing [<br>
] and horizontal spacing [
].
It's possible to use pure-MathJax to achieve punctuation kerning on StackExchange posts. Sample code:
$$
\color{transparent}{
\quad\text{.}
}
\begin{align}x^2 + y^2 = r^2
&
\\
&\quad\text{.}
\end{align}
$$
..which outputs:
$$
\color{transparent}{
\quad\text{.}
}
\begin{align}x^2 + y^2 = r^2
&
\\
&\quad\text{.}
\end{align}
$$
..(And here's a screenshot:
..) but the font of the "fullstop" produced by MathJax is not the same as the font of the fullstop produced by normal English text.
Another issue is there is no control over pixel-perfect vertical-spacing as the vertical spacing using MathJax's align
is a multiple of 24px [0px, 24px, 48px, etc].