Linguist: Javascript/JSX single-quote/apostrophe breaks syntax highlighting

Created on 15 Aug 2017  Â·  16Comments  Â·  Source: github/linguist

Most helpful comment

I hope to squeeze in a release this week or next and will experiment with @Alhadis's suggestion from https://github.com/github/linguist/issues/3044#issuecomment-452385154

All 16 comments

I know it says to report issues to specific language repo, but the JSX repo seems to be version-locked/deprecated: https://github.com/github-linguist/language-babel

Yeah, this is a bit of a known issue and stems from changes made to the upstream grammar that aren't compatible with the regex engine (Ruby's PCRE compiled without the PCRE_UCP flag - see https://github.com/github/linguist/issues/3291#issuecomment-255750842 why) forced us to lock to a particular version. More details in https://github.com/github/linguist/issues/3044

I've done a quick crude test and maybe switching to https://github.com/babel/babel-sublime may be the best solution going forward. It's not as actively developed as https://github.com/gandm/language-babel but it is recommended for Sublime by Facebook here and doesn't experience the problem...

Thoughts @Alhadis, @larsbrinkhoff & @pchaigno

I've done a quick crude test and maybe switching to https://github.com/babel/babel-sublime may be the best solution going forward.

:+1:

Also an open PR with an attempt to fix #3677.

Would be so rad to see a fix for this, would be more than happy to help if someone can point me in the right direction of the fix you'd like to see.

@lewisblackwood Yup. Your That fix is also feeling the apostrophe pain. I'll spin up a PR to switch the source for the grammar.

@lildude I saw that your PR was closed on this. Is there anything we can do here to get this fixed? Still a big frustration for us!

Is there anything we can do here to get this fixed?

Beg the original upstream maintainer to relax his ways would be ✨ but sadly that's not likely to happen. 😢

The only alternative is to either update and keep maintaining our own fork of https://github.com/gandm/language-babel (not ideal) or find a better, yet still maintained, source for the grammar as https://github.com/babel/babel-sublime is lacking.

@Alhadis, I'm not an expert with writing/maintaining grammars, but how hard would it be to update https://github.com/github-linguist/language-babel with the upstream changes and tweak things to play nice with Linguist? At the moment, that's looking like the quickest solution to this long running issue. I'm not asking for any obligation for you to do it, just your expert opinion.

I don't imagine it'd be terribly difficult. Theoretically, it should be straightforward to hack together a script which converts Oniguruma-only grammars to PCRE-friendly ones. Both engines have different syntax for what're ultimately the same features.

This would be my preferred approach, because the actual grammar itself is long and beastly. Updating that by hand would be absurd. 😀

I have found one case to break.

~~~js
const a = ["I'm", "foo"];

switch (true) {
case /I'm foo/.test(a.join(' ')):
console.log(true);
break;
}
~~~

I know this issue is closed, but I am still seeing the issue whenever using an apostrophe inside of a text node, which is really messing with my code reviews:

render () {
  return (
    <Text>
      It's an apostrophe!
    </Text>
  );
}

I'm guessing that using a RIGHT SINGLE QUOTATION MARK (U+2019) would be out of the question, right? 😉

Ha! Obviously, I'd prefer the syntax highlighting handle the edge case, but this is a surprisingly good suggestion for my particular use case.

I hope to squeeze in a release this week or next and will experiment with @Alhadis's suggestion from https://github.com/github/linguist/issues/3044#issuecomment-452385154

any update here?

any update here?

Nope. This is still a problem with the grammar and my attempt to switch it out wasn't successful - see https://github.com/github/linguist/issues/3044#issuecomment-459420383

Actually, looks like the upstream Atom grammar will get updated to reflect this. See https://github.com/github/linguist/issues/3044#issuecomment-461474332 onwards with a reference to https://github.com/atom/language-javascript/issues/641 in the upstream grammar. So as it stands, we're waiting on the upstream grammar.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lucasrodes picture lucasrodes  Â·  6Comments

d4nyll picture d4nyll  Â·  3Comments

Haroenv picture Haroenv  Â·  4Comments

henrywright picture henrywright  Â·  6Comments

FranklinYu picture FranklinYu  Â·  4Comments