1

I recently posted this question on apple.stackexchange which contains a hex dump, like this:

00000210: 616e 7369 6f6e 0a20 2020 2020 2020 5f08  ansion.       _.

Different to here (on Meta Stackexchange), the hexdump in apple.stackexchange was syntax coloured - some hex values displayed in red and some in green.

Is there a deeper meaning in these colours? I wonder according to which rule the colours are chosen here.

10
  • 1
    Looks like the numbers containing only decimal digits, are coloured differently from those containing the letters a-f. Commented Jul 6, 2023 at 13:00
  • @S.L.Barthsupportsmodstrike : Sounds reasonable! I wonder what highlighter is actually used here. If you post your comment as answer, I will accept it. Commented Jul 6, 2023 at 13:14
  • I'll wait a bit to see if a more informed answer comes by. So far, I only have a single observation. I don't know why the highlighting there is different from the highlighting here. Commented Jul 6, 2023 at 13:20
  • @S.L.Barth it's different because of different default language between the sites, or more likely the tags there having associated highlight language. Commented Jul 6, 2023 at 13:35
  • In this specific case, it's more likely different since the linked question contains many lines, and this one only one
    – Erik A
    Commented Jul 6, 2023 at 13:37
  • I see no hexdump anywhere on that page. Did you link to a wrong question? Commented Jul 6, 2023 at 13:51
  • @EmilJeřábek you might be using adblock which hide it. There is hex dump, this is what I see: i.sstatic.net/So61o.png. Commented Jul 6, 2023 at 14:07
  • @ShadowWizardStrikesBack I’m not using any adblocks or anything of that sort. Now I see that the page is completely different. It seems that I get automatically redirected to what appears as the duplicate question target in your screenshot. Is this because I don’t have an account on Ask Different? If so, this is extremely confusing behaviour. Commented Jul 6, 2023 at 14:25
  • And, sure enough, now that I’ve “joined this community”, the link works. So, yes, this must be intended behaviour, but I can’t describe it any other way than idiotic. Commented Jul 6, 2023 at 14:30
  • @EmilJeřábek huh! Forgot about it, and fixed it by adding flag telling SE to not redirect, link should now work for everyone. Commented Jul 6, 2023 at 14:34

1 Answer 1

5

The code is being highlighted as YAML. Which makes sense, I guess, YAML allows numbers and strings without string separators, and often begins lines with a string, then a colon.

You can find this out by inspecting the HTML, which reveals:

<code class="hljs language-yaml">
   <span class="hljs-attr">00000210:</span> 
   <span class="hljs-string">616e</span> 
   <span class="hljs-number">7369 </span>
   <span class="hljs-string">6f6e</span>
etc...

And you can of course disable this by specifying lang-none

7
  • Weird, according to the tag page of the tag used in the question, the default language is lang-shell. (And lang-bash for the other tag) Commented Jul 6, 2023 at 13:36
  • 2
    As I understood it, the syntax highlighter is not smart enough to prefer these if multiple are listed in the tags and just goes to lang-default, but I could be wrong, can't seem to find that documented.
    – Erik A
    Commented Jul 6, 2023 at 13:44
  • 2
    According to the faq: "By default, Stack Exchange uses the tags on a question to determine the language you are using. If there's more than one tag that has a highlighting language specified, it lets highlight.js infer what's the best language to use", so it should be either shell or bash. Commented Jul 6, 2023 at 14:05
  • 1
    @Shadow That's not really clear, I read that as "let highlight.js infer == lang-default", but I see how you could interpret it differently
    – Erik A
    Commented Jul 6, 2023 at 14:23
  • @Shadow given that yaml was used, Erik's interpretation is correct - so the choice is not between tag-associated languages (which would be the more sensible thing to do), but based on the general detection method.
    – Marijn
    Commented Jul 6, 2023 at 14:33
  • @Marijn yeah, wonder how the faq answer can be made more clear then. Commented Jul 6, 2023 at 14:35
  • 1
    @ErikA’s interpretation is correct. See meta.stackexchange.com/questions/354793/… for a request to fix this. Commented Jul 6, 2023 at 14:35

You must log in to answer this question.

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