# TeX math interacts with italic and bold formatting

In this answer, I noticed a math bug that looks like an interaction between the parser and the TeX system. When you have a word that starts with math and then has italics or bold later, the italics or bold is formatted correctly in the preview, but not formatted correctly in the final output of the answer.

For example, if you type $x$-**word**, what you get in the preview is the letter $x$ followed by word in bold, as desired. However, in the final output you get $x$ followed by *word* in italics, not bold, with visible asterisks.

Similar problems happen if you enter $x$-*word*. In that case you don't get any italics in the final output, just two visible asterisks.

I need to point out that putting the bold in front, like **$x$-word** isn't a solution, because that makes the symbol $x$ bold. There are cases in mathematics where the bold actually has a semantic value, and even when it doesn't the standard convention is not to put math in a bold font.

Also, I hit another difference between the preview display and the final display when editing the previous paragraph: if you remove the second backslash and compare preview to final output you will see it.

• Oh, like this and this? – J. M. ain't a mathematician Dec 20 '10 at 13:42
• Part of this maybe related to the broken regexp observed before. – Willie Wong Dec 20 '10 at 13:47
• @J.M.: Strange, at the first like it says "status-completed" ... – Hendrik Vogt Dec 20 '10 at 13:48
• @J.M. it is probably related, but different. As in the first thread you linked to it appears that a fixed has already been deployed for that bug. – Willie Wong Dec 20 '10 at 13:48
• Let's see how it is in comments: $\LaTeX$-italic and $\LaTeX$-bold ... yeah, it's worse here. Maybe use \textbf for the time being? – J. M. ain't a mathematician Dec 20 '10 at 13:51
• @J. M.: Thanks, I looked but didn't find those. However, the first one is marked "completed", while this is still broken. The difference may be the space (or lack of space) between TeX and markdown. (I will also add a markdown tag to my question.) – Carl Mummert Dec 20 '10 at 14:18
• @Willie Wong: do they really use regexes to implement markdown? – Carl Mummert Dec 20 '10 at 14:20
• Well, I am not the brightest bulb when it comes to programming, but how else do you implement/parse a mark-up language besides searching for and pairing delimiters? – Willie Wong Dec 20 '10 at 14:59
• @Willie Wong: the stereotypical way to parse a programming language is to break up the input into a stream of tokens with a "lexer", then use a parser to make a parse tree. Sometimes it is possible to just make in-text replacements using regular expressions, but for more complicated languages the code can be much more complicated. See en.wikipedia.org/wiki/Parsing#Overview_of_process for a summary. I have no idea what system is used for the stackexchange engine, but this problem looks more like a "lexer" error than a "parser" error. – Carl Mummert Dec 20 '10 at 16:13

Basically, the - was getting eaten in a processing pass* causing us to treat the *italic* or **bold** as intra-word (and thus ignored). This has been fixed on dev, and should go out sometime tonight.