jeff-hykin / better-cpp-syntax

💾 The source of VS Code's C++ syntax highlighting
GNU General Public License v3.0
154 stars 29 forks source link

objc and obj-cpp highlighting failed when used as embedded grammar in markdown #582

Open Zaxzeng opened 2 years ago

Zaxzeng commented 2 years ago

Grammar files for objective-c (and -cpp) could not properly work while been used as an embedded grammar, for example, a code block in a markdown file.

The code with a problem is:

Open vs-code, create an empty markdown file, insert following code block of objective-c:

    In a markdown file:
    ```objc
    //highlight ok
    first = [[Cat alloc] initWithAge:12]

    //highlight failed
    second = [[Cat alloc] initWithAge:13]


## It looks like:

<img width="283" alt="lookslike" src="https://user-images.githubusercontent.com/59133639/147315506-a792a2a6-f124-4ab5-abf8-2690d7c686d6.png">

## It should look like:

<img width="283" alt="shouldbe" src="https://user-images.githubusercontent.com/59133639/147315547-bc3eb4f1-338d-4a26-965f-df80bc1cf4f8.png">

## More comments

Seems those grammar files should replace all uses of "$base" as "$self". 

I'm not expert in text-mate nor vs-code, Afraid these changes may bring unexpected effect on other related parts or features. Just report this and wishing anyone who is more familiar with these tech could give a fix.
jeff-hykin commented 2 years ago

Hmm this is a strange reoccurring issue. I wonder if something was undone.

You're right it's related to $base and $self, and there can be some nuances with it.

Could you try installing the Better Obj-C++ Syntax? If it's still an problem, if you can post an issue on that repo that'll help me put it on a Todo list for later

https://github.com/jeff-hykin/better-objcpp-syntax