Skip to main content
4 of 5
edited tags
Servy
  • 203.7k
  • 105
  • 683
  • 806

Can we make syntax highlighting easier?

It seems as though often the syntax highlighter does not detect the language I'm working in.

When this happens, I try to be responsible and apply the manual highlighting comment: <!-- language: NAME -->.

However, it's hard for me to remember this syntax because it is finicky.

Consider the following examples of the highlighting comment with subtle changes in spacing:

<!-- language: python -->

for i in range(10):
  print('hi')

<!--language: python -->

for i in range(10):
  print('hi')

<!-- language: python-->

for i in range(10):
  print('hi')

<!--language:python-->

for i in range(10):
  print('hi')

<!-- language:python -->

for i in range(10):
  print('hi')

<!-- language: python -->

for i in range(10):
  print('hi')

Since the foregoing doesn't display on Meta, I have an image:

Finicky highlighting syntax

In all cases, the comments are detected as such, but in only some cases is highlighting applied as a result.

Is there a way to make this command less finicky and, hopefully, thereby easier to use?

Richard
  • 60.7k
  • 14
  • 9