Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

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

Open
akshaybabloo opened this issue May 23, 2016 · 16 comments
Open

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

akshaybabloo opened this issue May 23, 2016 · 16 comments

Comments

@akshaybabloo
Copy link

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
Copy link
Author

akshaybabloo commented Aug 18, 2016

This is not yet rectified in version 1.9.9.

@APerricone
Copy link

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

@dead-claudia
Copy link

dead-claudia commented Apr 14, 2019

Related bug: atom/language-gfm#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
Copy link

jeff-hykin commented Apr 14, 2019

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
Copy link

@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
Copy link

jeff-hykin commented Apr 23, 2019

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

This comment has been minimized.

@jeff-hykin
Copy link

jeff-hykin commented Jun 3, 2019

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
Copy link

@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
Copy link

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
Copy link

discretegames commented Sep 18, 2021 via email

@jeff-hykin
Copy link

jeff-hykin commented Sep 18, 2021

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
Copy link

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
Copy link

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
Copy link

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
Copy link

jeff-hykin commented Sep 20, 2021

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants