andre-simon / highlight

Source code to formatted text converter
GNU General Public License v3.0
206 stars 58 forks source link

add js and json extensions #57

Closed mattsawyer77 closed 6 years ago

andre-simon commented 6 years ago

The lang files are called js.lang and json.lang, so these extensions are not required in filetypes.conf. A mapping to javascript would not work as intended, as there is no lang file with this name.

mattsawyer77 commented 6 years ago

@andre-simon ah, OK. well, it seems that javascript files are only identifiable via shebang but not via file extension. What is the best way to fix this problem?

andre-simon commented 6 years ago

.js is automatically mapped to js.lang. If a new language like Z should be supported, it is sufficient to create a file called z.lang in the langDefs directory. If Z has more extensions, like .zinc, then zinc needs to be listed in filetypes.conf.

If js is not highlighted correctly, please run highlight -Sjs --verbose and look for the loaded file after Loading language definition:

mattsawyer77 commented 6 years ago

This was a simple error on my part. I was piping a javascript file to highlight, expecting it to detect the file type for some reason. If I run the command passing in a filename, it works fine. Sorry for the noise.

andre-simon commented 6 years ago

You can use the -s option to define the syntax. This also overrides extension and shebang recognition.