5

In this answer I see

code font exammple with oblique text between underscores

Notice how the text in the code blocks between underscores is italicized (or rather, in this font, oblique).

Here is the same text copy/pasted into this question (where I currently see no italics):

Using sed:

sed -rn "357s/(^.*payment_methods.*text COLLATE utf8_unicode_ci)( DEFAULT.*-1.*)(,$)/\1\3/p" file

Weirdly, if I try to edit the post, the effect disappears, so I can't tell from the preview whether it can be fixed by editing -- I'd have to perform possibly disruptive experiments:

in edit view, the effect disappears from the preview pane

3
  • 2
    While this question is closely related to Code block is rendered incorrectly (partially in italic after underscore) [duplicate] and the question which that one is closed as a duplicate of, Code block containing asterisks displaying in italics, this is not a duplicate. There was an issue here which required a separate change.
    – Makyen Mod
    Commented Dec 28, 2020 at 15:53
  • 1
    IMO, bug reports should not be closed as a duplicate of a prior bug report, unless there is nothing to be changed other than what was already changed/fixed with the prior bug report (i.e. it's the exact same bug, not just similar symptoms). This was a separate issue which presented in a very similar manner to the prior linked questions. While it might be reasonable to consolidate very similar, but not the same, bugs down to a chain of duplicates, it's only reasonable to do so after the underlying issue is resolved.
    – Makyen Mod
    Commented Dec 28, 2020 at 15:58
  • 1
    For these syntax highlighter issues, every single tag has a separate language setting, which means a bug report may need separate action taken to resolve it when it's on a different tag, even if the bug presents nearly identically to a previously reported issue. Once a bug report is closed, that indicates that there's no more need for any separate action with respect to that bug report. That is not the case when the syntax highlighter language settings for specific tags still need to be looked at and adjusted.
    – Makyen Mod
    Commented Dec 28, 2020 at 16:01

1 Answer 1

6

The Problem

The issue here was that the syntax highlighting was identifying the code block as Markdown and using the highlighting for that language. This happened because:

  1. The language tag was removed from the question in an edit (see revision 3), which caused lang-sh to not be the only potential syntax highlighting language passed to highlight.js.
  2. The syntax highlighting language for was set to default, which, when there isn't a specific language defined in other question tags, results in feeding the default list of languages to highlight.js as possible highlighting languages. This allows highlight.js to try to find the "best" language among those in the default list. [Note: that the default list is not used when there's a language defined on another tag is an assumption on my part, but that assumption is consistent with how it appears to be operating. I have not looked in SE's code to verify this is actually what's happening.]

Since the default list was being used, highlight.js did the best it could at guessing which language to use from among those in that list and the short amount of code. In this instance, highlight.js ended up deciding that Markdown was the "best", so used syntax highlighting for that language.

Resolution

I have changed the syntax highlighting language for the tag to <none> and rolled back the edit which removed the tag from that question.

2
  • In general I would say when highlight.js takes a guess the result is worse then the "default" that prettify used ....
    – rene
    Commented Dec 28, 2020 at 16:33
  • 4
    I agree. Unfortunately, SE appears to have chosen to leave the configuration of highlight.js in a state where it's basically guaranteed to do a poor job in many instances. I haven't seen the list of "default" languages, so I'm not sure if highlight.js was even given the option of having lang-sh as one of the possible languages to choose from.
    – Makyen Mod
    Commented Dec 28, 2020 at 16:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .