-
Notifications
You must be signed in to change notification settings - Fork 114
Non italics text treated as italics after C code block #214
Comments
BTW, I'm still reproducing this in safe mode, following the original repro steps. It's basically destroyed formatting for a couple of my files, and my current workaround is to just disable highlighting of that code block (the offending C/C++-specific highlighting issues are all in a private personal repo). Here's my version info:
|
My theory is that the C code isn't being matched greedily enough, and between that and the looseness of C's grammar itself, it's confusing the syntax highlighter. |
@isiahmeadows I believe the cause is that the C++ grammar crosses with the C grammar in places, and this crossing method uses a reference to the base grammar of the file. I haven’t had any part on writing those grammars, so can’t comment on how necessary this is, but I recall it being a known issue. In normal C++ files the base grammar is C++, so it all works, but in a markdown codeblock the base is markdown. Unfortunately, there does not exist a way to refer to the “parent” grammar. |
@Aerijo Are you sure? My example specifically sets C, not C++, and although the C++ grammar explicitly extends the C grammar, the C grammar doesn't depend on any C++ productions. Also, the tree-sitter grammar for C and C++ don't seem to intersect except through rules common across both. (I don't think the GFM grammar has a tree-sitter variant, though.) |
@isiahmeadows Yes, the C grammar uses The Tree-sitter grammar is irrelevant, as only same kind grammars can be embedded in each other currently and |
@Aerijo Oh okay. I didn't realize that part, nor did I know what So should I file a bug against |
@isiahmeadows Looks like one already exists. I think it's been known for a while, and I appear to have referenced that issue before, but the problem is that the editor TextMate also has that bug, and the grammar engine was designed to be compliant with TextMate. |
I wrote this comment over in that bug. Should this be closed as a dupe of that, since it predated this by over a year (and nothing new has since arisen)? |
Prerequisites
Description
In C language,
/* */
stands for comment. But in some case, if we use/* */
in code block,*
will be treated as italics begin. This only happen in C or Cpp code block, Java and C# code block do not have this matter.Steps to Reproduce
Github Markdown
.Only the first format will cause some matter. That means
/* */
in{ }
scope.Expected behavior: [What you expect to happen]
These two code segments are both correct, and the text after the code block should not be italic.
Actual behavior: [What actually happens]
Non italics text treated as italics in first format.
If we delete the first
{
, the highlight is correct.And if we change the language of the code block from c to java or c#, this problem do not happen.
Reproduces how often: [What percentage of the time does it reproduce?]
Always.
Versions
Atom : 1.21.0
Electron: 1.6.9
Chrome : 56.0.2924.87
Node : 7.4.0
apm 1.18.5
npm 3.10.10
node 6.9.5 x64
python 3.5.1
git 2.9.3.windows.3
visual studio 2015
OS: Windows 10 64 bit
Additional Information
There are some similar issues:
#198
#133
#171
But this problem still not solved...
The text was updated successfully, but these errors were encountered: