3

I am seeing a bit of weirdness with the new code formatting library on this Stack Overflow question:

Phone Number Regex Conditions

Here is how my answer is being formatted:

enter image description here

As you can see, something is spoofing the JavaScript engine into thinking that it should be doing into Italic mode, inside a code block. For reference, my answer works (assuming PHP is actually the OP's language), as this demo shows.

Here are my browser specs (Windows laptop):

Chrome Version 83.0.4103.116 (Official Build) (32-bit)

Does anyone know what is going on here?

9
  • @WaiHaLee There are no asterisks in my answer. I have never seen this behavior the entire 8 years I have been using Stack Overflow, hence I posted a question here. Commented Oct 9, 2020 at 8:15
  • 1
    Late comment: The italics seem to be getting kicked in due to the underscore. But, that UI feature should be turned off inside a code block, I think. Commented Oct 9, 2020 at 8:31
  • This is a PHP question, right? Try adding the PHP tag to the question and see if the formatter behaves better.
    – legoscia
    Commented Oct 9, 2020 at 8:49
  • @legoscia Brilliant answer. Could you post that, assuming there isn't already an exact duplicate? Commented Oct 9, 2020 at 8:51
  • The question now is, what is the default behavior for code formatting in absence of an actual programming language. Commented Oct 9, 2020 at 8:51
  • It tries to guess the language. If there are only a few lines of code, it seems to guess Markdown more often than it should, where using italics between asterisks and underscores makes sense.
    – legoscia
    Commented Oct 9, 2020 at 8:53
  • 2
    Can't believe I've never seen this before. Which also means that generally folks are very good about tagging with their language. Commented Oct 9, 2020 at 8:53
  • This is a new problem following the change to highlight.js in September.
    – Wai Ha Lee
    Commented Oct 9, 2020 at 11:25
  • @legoscia [Current maintainer of Highlight.js here] If someone wants to compile a list of 5-10 examples of "guesses Markdown more than it should" and file a GitHub issue I'd be happy to take a closer look when I have time... Commented Feb 15, 2021 at 2:52

0

Browse other questions tagged .