vim-markdown icon indicating copy to clipboard operation
vim-markdown copied to clipboard

Capitalized fenced code block languages aren't handled properly

Open ElnuDev opened this issue 2 years ago • 4 comments

There's an issue with how capitalization is handled in fenced code blocks. In my configuration, I've set rs to be associated with Rust:

let g:vim_markdown_fenced_languages = ['rs=rust']

However, if I open a markdown file and enter the following:

```RS
fn amogus() {
  println!("sus");
}
```

The Rust code won't highlight, even if I close and reopen the file. At first I thought this is because vim_markdown_fenced_languages is case sensitive, but this turned out to not be the case, because the code is rendered correctly as soon as any non-capitalized code block is added. In fact, switching RS to rs and then putting it back again will also fix the issue for a single session.

This same issue happens for file types not added to vim_markdown_fenced_languages.

ElnuDev avatar Jan 18 '23 07:01 ElnuDev

What markdown spec allows capitalized names? As far as I know all the parsers agree fully lowercased names are the canonical form. I don't even think VIM will accept that as a filetype, we'd have to do the case casting ourselves instead of just passing it through.

alerque avatar Jan 27 '23 10:01 alerque

The CommonMark spec "doesn’t mandate any particular treatment of the info string" according to its documentation , so I don't think there's any reason to think they're disallowed. Even if lowercased names are considered canonical, they still work in every single parser I've used, including GitHub's. Shouldn't the plugin agree with parser outputs? I don't really see any disadvantage in having capitalized info strings work properly, not having them work properly just makes vim-markdown appear broken for people who use a convention of capitalizing language names.

It's not like vim-markdown doesn't render capitalized names at all anyway, it just acts buggy when they're around, being temperamental whether or not it decides to highlight them.

ElnuDev avatar Jan 27 '23 17:01 ElnuDev

Okay, if other parsers normalize this I suppose we can too. The VIM filetypes we have to map to are all lower case, but I'd be happy to facilitate a PR that normalizes these before passing them to VIM.

alerque avatar Jan 27 '23 19:01 alerque

Alright! I'll make a PR soon.

ElnuDev avatar Jan 27 '23 20:01 ElnuDev