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

**URL:** https://meta.discourse.org/t/does-syntax-highlighting-only-work-on-fenced-code-blocks-but-not-indented-code-blocks/121466
**Category:** Support
**Created:** [June 27, 2019, 8:00am UTC](https://meta.discourse.org/t/does-syntax-highlighting-only-work-on-fenced-code-blocks-but-not-indented-code-blocks/121466 "2019-06-27T08:00:22Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![abcoathup](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/abcoathup/32/145066_2.png) [@abcoathup](https://meta.discourse.org/u/abcoathup)
#### Post date: [June 27, 2019, 8:00am UTC](https://meta.discourse.org/t/does-syntax-highlighting-only-work-on-fenced-code-blocks-but-not-indented-code-blocks/121466/1 "2019-06-27T08:00:22Z")

</div>

Does Syntax highlighting only work on [fenced code blocks](https://spec.commonmark.org/0.29/#fenced-code-blocks) but not [indented code blocks](https://spec.commonmark.org/0.29/#indented-code-blocks)?

### Fenced Code Block

```plaintext
// 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();
        }
    }
}

```

---

<div class="post-metadata">

### Author: ![schleifer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schleifer/32/86416_2.png) [@schleifer](https://meta.discourse.org/u/schleifer)
#### Post date: [June 27, 2019, 9:31am UTC](https://meta.discourse.org/t/does-syntax-highlighting-only-work-on-fenced-code-blocks-but-not-indented-code-blocks/121466/2 "2019-06-27T09:31:16Z")

</div>

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.

```cs
// 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();
        }
    }
}

```

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [July 27, 2019, 9:31am UTC](https://meta.discourse.org/t/does-syntax-highlighting-only-work-on-fenced-code-blocks-but-not-indented-code-blocks/121466/3 "2019-07-27T09:31:16Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
