code-hike / codehike

Marvellous code walkthroughs
https://codehike.org
MIT License
4.51k stars 140 forks source link

Enhancement: Determine syntax highlighting based on filename on Codeblocks #180

Open brianespinosa opened 2 years ago

brianespinosa commented 2 years ago

It would be great if when defining a codeblock and putting a filename, that our codeblocks could determine the language for syntax highlighting based on the filename alone.

This of course might be challenging if codeblocks are looking for these frontmatter values in an array.

pomber commented 2 years ago

Do you mean

``` hello.py
print("Hello, world!")
```

should be highlighted as python? Or you have something different on your mind?

brianespinosa commented 2 years ago

@pomber yes, that is 100% what I am thinking.

pomber commented 2 years ago

can you find/build a map from filename to language? I'll be happy to add the logic to the code

brianespinosa commented 2 years ago

This might be more than we need relative to available language syntax highlighting... but I think we might be able to start with this? https://gist.github.com/ppisarczyk/43962d06686722d26d176fad46879d41