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:
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?
<!--
single-spacelanguage:
single-space name single-space-->
really so hard to remember? There is no space before the colon, but that’s the standard typesetting on computers anyway.```python\ncode goes here\n```
)<!-- language: ... -->
or<!-- lang: ... -->
. The reason why I sometimes make this mistake is because you should actually uselang-py
in stead ofpython
, so sometimes I accidentally write<!-- lang: lang-py -->
. Bookmarking What is syntax highlighting and how does it work? helped a lot.language: python
.language: lang-py
is not something I'd've guessed, especially withlanguage: c#
as an example.