Home > Net >  GitHub flavored markdown code syntax highlighting forcing type
GitHub flavored markdown code syntax highlighting forcing type

Time:03-12

Take this simple code markdown:

```cs
var x = new Locked<Rec>(new ("John", 35)); 
```

This renders in GitHub readme like this:

enter image description here

I now just add a definition:

```cs
record Rec(string Name, int Age);
var x= new Locked<Rec>(new ("John", 35)); 
```

and it now renders like this:

enter image description here

As you can see the type Locked and the new are for some reason no longer coloured purple. Why is this and how can I get around it ?

CodePudding user response:

Visual Studio Code does the same thing.

I'm not a C# developer, but GitHub rendering with syntax highlighting

It works even better if you declare the record inside Main as well:

GitHub rendering with syntax highlighting

  • Related