Bat: README.MD is not recognized as markdown

Created on 20 Jan 2020  路  3Comments  路  Source: sharkdp/bat

README.MD is not recognized as markdown while README.md is. I suppose there is a case sensitive pattern for checking the file extension. Is it a bug or a feature?

I am willing to submit a PR but I am not Rust developers so pointers to the right lines would be appreciated ;)

question syntax-highlighting

Most helpful comment

@HakubJozak Thank you for your feedback.

I'm not sure if the Sublime syntax file_extensions field is intended to be case-insensitive or not, but depending on the answer to that, either Syntect or sublimehq/Packages is doing something incorrectly.

Third possible option: the uppercase .MD file extension should not really be supported because it's non standard(?).

I think it's correct that the file_extensions field is case-sensitive. The field is also use to match against full filenames, and some of these are case-sensitive (PKGBUILD, CMakeLists.txt, Dockerfile). Apparently, there are also some file extensions which are case-sensitive (.M for Objective C, see https://en.wikipedia.org/wiki/Objective-C).

So if this should be fixed, it has to be added to the Markdown syntax file.

All 3 comments

I can confirm this bug.

I believe the issue is caused by how Sublime syntaxes specify their applicable file extensions. The highlighting library used by bat (Syntect) determines the syntax for a file extension using a case-sensitive comparison. I'm not sure if the Sublime syntax file_extensions field is intended to be case-insensitive or not, but depending on the answer to that, either Syntect or sublimehq/Packages is doing something incorrectly.

Unfortunately, it looks like the Markdown syntax file that we use only specifies lowercase file extensions. I'm not sure how @sharkdp would prefer to handle it, but there's a couple options that I can think of:

  1. Include --map-syntax MD:md in your bat config file.
    This can be done without any changes to bat or the Sublime Packages repository.

  2. Create a patch file for the Markdown syntax and patch it during the build process.
    While it could work, I don't think it's an ideal solution.

  3. Create an upstream issue about it.

@HakubJozak Thank you for your feedback.

I'm not sure if the Sublime syntax file_extensions field is intended to be case-insensitive or not, but depending on the answer to that, either Syntect or sublimehq/Packages is doing something incorrectly.

Third possible option: the uppercase .MD file extension should not really be supported because it's non standard(?).

I think it's correct that the file_extensions field is case-sensitive. The field is also use to match against full filenames, and some of these are case-sensitive (PKGBUILD, CMakeLists.txt, Dockerfile). Apparently, there are also some file extensions which are case-sensitive (.M for Objective C, see https://en.wikipedia.org/wiki/Objective-C).

So if this should be fixed, it has to be added to the Markdown syntax file.

I'm going to close this for now. @HakubJozak If you feel that .MD should be supported, please open a bug report at https://github.com/sublimehq/Packages

Was this page helpful?
0 / 5 - 0 ratings