Author of the highlight.js grammar for LaTeX here. Phelype Oleinik identified the issue correctly in his comment: The grammar doesn't know about the possible optional argument of \lstinline
.
A bit of history: Back in 2020 the powers changed the SE parser to highlight.js without much warning which totally broke all highlighting here. After collecting issues, I completely rewrote the grammar and that is pretty much still what we have today. Sadly, the powers weren't very responsive when it came to adapting the colors to match the old site theme, even after repetitive prodding. Maybe it's worth trying again, but I don't have high hopes. I say all this just to clarify that even if the issue is resolved in highlight.js, there is no guarantee that the fix will be used here any time soon.
Now, for the issue at hand. Feel free to open an issue on the highlight.js issue tracker and ping me there. I'm currently rather swamped but I can try to find some time to look at it. One difficulty is that LaTeX has quite a varied syntax and covering all of it is impossible (and out-of-scope for highlight.js). I tried to cover the most common verbatim cases back then, as that will otherwise often mess up highlighting, but obviously not all of it.
Another difficulty is that putting all the possible sequences of arguments into a highlight.js grammar is rather cumbersome due to it's mode of operation. I don't quite remember the limitations of what I came up with back then. I'll have to check if this can be easily fixed. There was already quite some discussion about adding a feature to hightlight.js that would make this much simpler (and I was kind of hoping that would be available when I finally sat down and went through my list of improvements for the grammar), but it isn't here yet.
If you decide to open an issue over on GitHub, it would be great if you could include a list of all the common verbatim environments with all the possible usages. That way we could discuss beforehand what makes sense to include and then try to address all of it at once. Maybe it even reignites the sequence discussion. You are of course welcome to contribute to this yourself.
\normalfont
is unrelated. You would have the same syntax highlighting with two identical code blocks. The syntax highlighter just does not notice that your first block is finished.Text \verb{test} Text
(the "Text" shouldn't be marked as math code)\lstinline
is a verbatim macro, but doesn't know it accepts an optional argument, so it treats the following character ([
) as a begin-of-verbatim delimiter, and stops verbatim mode at the next[
. Not sure if a bug or a feature. Same for\verb
: the highlighter doesn't know that\verb{test}
is valid, so it thinks it has to stop only when it finds another{