Does Syntax highlighting only work on fenced code blocks but not indented code blocks?

AI-generated summary

abcoathup is inquiring whether syntax highlighting only works on fenced code blocks and not on indented code blocks. An example of each type of code block is provided, demonstrating the difference in syntax highlighting between them.

schleifer responds that syntax highlighting can work for both types of code blocks, depending on the settings. On meta, for instance, indented code is never highlighted while fenced code only highlights when a language is specified. A fenced code block example with language specification (cs) is provided to illustrate this.

Does Syntax highlighting only work on fenced code blocks but not indented code blocks?

Fenced Code Block

// A Hello World! program in C#.
using System;
namespace HelloWorld
{
    class Hello 
    {
        static void Main() 
        {
            Console.WriteLine("Hello World!");

            // Keep the console window open in debug mode.
            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }
    }
}

Indented Code Block

// A Hello World! program in C#.
using System;
namespace HelloWorld
{
    class Hello 
    {
        static void Main() 
        {
            Console.WriteLine("Hello World!");

            // Keep the console window open in debug mode.
            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }
    }
}

It can work for both, depending on settings. Here on meta default code lang is text and autohighlight all code is false, so indented code is never highlighted and fenced code only when a language is specified.

// A Hello World! program in C#.
using System;
namespace HelloWorld
{
    class Hello 
    {
        static void Main() 
        {
            Console.WriteLine("Hello World!");

            // Keep the console window open in debug mode.
            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }
    }
}