atom / language-c

C support in Atom
Other
118 stars 154 forks source link

Markdown syntax colour issue while using /* .. */ #146

Open akshaybabloo opened 8 years ago

akshaybabloo commented 8 years ago

Description

I don't know if this is happening to everyone but when I write /* .. */ in a code block, everything after that turns to pink (See the screenshot).

screen shot 2016-05-23 at 3 48 34 pm

Steps to Reproduce

  1. Follow the content in the screenshot.

Expected behavior: No pink color

Actual behavior: Turns anything after /* .. */ to pink.

Versions

Atom version

Atom : 1.7.3 Electron: 0.36.8 Chrome : 47.0.2526.110 Node : 5.1.1

No amp installed.

OS - OSX 10.11.5

akshaybabloo commented 8 years ago

This is not yet rectified in version 1.9.9.

APerricone commented 5 years ago

any news on it? I have the same issue of #250

dead-claudia commented 5 years ago

Related bug: https://github.com/atom/language-gfm/issues/214

I feel the proper solution is two-part:

  1. The C and C++ TextMate grammars need to be fully split so neither depends on the other.
  2. The grammar should be modified such that $base is converted to an actual rule that dispatches to everything, like most other languages' grammars.

Is this sufficient to unblock the bug?

jeff-hykin commented 5 years ago

I would imagine though that Atom would be using Tree-sitter parser instead of TextMate.

If you want to use a TextMate grammar, jeff-hykin/cpp-textmate-grammar fixes the embedding issue. It's based on atom/language-c, but its already separated the C and C++ languages and removed the use of $base. It's also used as the VS Code C++ TextMate Grammar.

And, yes @isiahmeadows those two changes fix the embedding bug.

dead-claudia commented 5 years ago

@jeff-hykin Atom does use Tree Sitter normally for C files, but not for its GFM grammar. And it doesn't let TextMate grammars delegate to Tree Sitter grammars (or vice versa). It'd be nice, but it doesn't.

jeff-hykin commented 5 years ago

So I found out the embeddings are a bit harder to solve, at least for VS Code.

Markdown needs $base to be changed to be $self, so that C++ doesn't inject markdown into its patterns. However, the Objective-C and Objective-C++ TextMate grammars need the C and C++ syntax to keep things as $base because they inherit/import the C and C++ syntax. Just a heads up, its something we're still working on fixing.

This might not be a problem for Atom though if the Tree sitter is being used for Objective-C / Objective-C++. Today I built a feature into the toolset we're using so we can dynamically change between $base and $self. I'm going to reach out to the Objective-C and Markdown maintainers probably in the next 3 weeks to figure out the best solution. If you could make use of a $self version right now though let me know and we'll generate it.

dead-claudia commented 5 years ago

I get the feeling this is really blocked on https://github.com/atom/first-mate/pull/90. I find it odd it hasn't gotten elevated in priority yet, considering how many issues it unblocks. Edit: I'm wrong. Ignore this comment.

jeff-hykin commented 5 years ago

This issue is now fixed on https://github.com/jeff-hykin/cpp-textmate-grammar

The Objective-C and Objective-C++ TM grammars were added and made to be independent of the C and C++ syntaxes, and then the C and C++ TM grammars were effectively changed from $base to $self which has fixed the issue in markdown files.

All 4 languages are now independent so that issues like this won't happen in the future.

discretegames commented 3 years ago

@jeff-hykin Does your last comment apply to VSCode or only to Atom? I tried your VSCode extension and C embedded in markdown still had issues:

C embedded in markdown syntax highlighting issue

Namely the white printf and return lines.

jeff-hykin commented 3 years ago

Sorta. The atom maintainers just need to import it.

But, Atom Community is maintained better than the original Atom repo. I try to help out over there when I can. If it doesn't have the fix merged in, we can get it merged in over there.

discretegames commented 3 years ago

Sorry, I'm not certain I understand. I was asking about the embedded highlighting behavior in VSCode - I'm not sure how that relates to Atom. (Though I realize I probably shouldn't be asking about vsc on the atom repo.)

On Sat, Sep 18, 2021 at 12:22 PM Jeff Hykin @.***> wrote:

Sorta. The atom maintainers just need to import it.

But, Atom Community is maintained better than the original Atom repo. I try to help out over there when I can. If it doesn't have the fix merged in, we can get it merged in over there.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/atom/language-c/issues/146#issuecomment-922360186, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIQV7TAXRWRZCUJPSLIDI73UCTRJFANCNFSM4CETXNPQ .

jeff-hykin commented 3 years ago

Oh that's my bad I didn't pay attention to the screenshot.

Yeah if it's broken in vs code that's a problem. Try installing the Better C++ Syntax Extension and see if the problem sticks around

discretegames commented 3 years ago

I tried with the Better C++ Syntax extension (and restarted VSCode to make sure) but the C code embedded in markdown is highlighted in the exact same faulty way.

jeff-hykin commented 3 years ago

Oh, that explains it. A bit more than a week ago I broke up the C++/C/Objective-C/Objective-C++ into seperate repos/extensions. Try installing the better-c-syntax and let me know if that fixes it.

There is still a problem; it shouldn't need an extension to be fixed, but if the extension doesn't fix it there's a much bigger problem.

discretegames commented 3 years ago

Hmm, even with the Better C Syntax VSCode extension the issue persists.

image

I went and tried several extensions and extension packs and none fixed the issue. Microsoft's C/C++ Themes did change the highlight colors but printf("Hello, World!\n"); and return 0; were still white in the C embedded in markdown.

jeff-hykin commented 3 years ago

Welp, looks like that problem has actually been there for a long time. I went ahead and fixed it just now and published a new version. The C Syntax could use a lot of work