7

Syntax highlighting for both Powershell and Batch works if specified manually in an HTML comment, but not via a code block:

  • Doesn't Work: (code block)
    • ```bat
      
    • ```powershell
      

  • Works: (HTML comment)
    • <!-- language-all: lang-bat -->
      <!-- language: lang-bat -->
    • <!-- language-all: lang-powershell -->
      <!-- language: lang-powershell -->

Why is there this disparity?

  • I'm not familiar with how StackExchange sites individually function, but wouldn't it be a lot simpler and efficient, causing less discombobulation, if shell languages were supported the same across all sites supporting code block markdown?

    For example, syntax highlighting for both Powershell and Batch are auto-applied on StackOverflow.
6

1 Answer 1

6

Why is there a disparity between code fences and HTML comments used to set language?

Reproduced and fixed.

The issue was that the "Code Language (used for syntax highlighting)" in the tag descriptions was set to "none".

Changing that to "default" in and fixed the issue:

enter image description here

Note that the list of languages available do not include options that are more suited to or so I took a guess and used "default".

Here is my test question (which I'm going to delete)

Source:

testing common mark for batch files and powershell

```batch
echo Hello World!
```

```powershell
Write-Host "Hello World"
```

<!-- language: lang-bat -->
    echo Hello World!


<!-- language: lang-powershell -->
    Write-Host "Hello World"

Rendered:

enter image description here

3
  • Just an FYI, the issue is occurring again... it worked for a while, but if specifying powershell or bat after a code fence, it's not applying any syntax highlighting in the preview or when saved. Could this be browser-specific, occurring in one browser but not another (I use Chromium-based Edge)?
    – JW0914
    Sep 17, 2020 at 12:25
  • 1
    No idea, but I would not do anything until the new syntax highlighter is rolled out network wide (Sep 24th?). See meta.stackexchange.com/questions/353983/…
    – DavidPostill Mod
    Sep 17, 2020 at 12:29
  • 1
    Highlight for the cmd/bat language codes in source fences seems to not be working currently.
    – bad_coder
    Oct 18, 2021 at 15:37

You must log in to answer this question.

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