valentinnodan / mdx-intellij-plugin

MIT License
8 stars 2 forks source link

Triangle tag inside attribute causes parse error #9

Open danon opened 3 years ago

danon commented 3 years ago

You can have regular tags inside regular strings or template strings:

<Component attr={'<'}/>
<Component attr={`<`}/>
<Component attr="<"/>

but if you move the attribute to the next line, there is parse error

<Component 
    attr={`<`}/>
danon commented 3 years ago

Actually, even code like this causes parse error:

<div>
  {`<test>`}
</div>
vladsholokhov commented 3 years ago

@Danon Hi, Could you share the exact file/ screenshot with the issue?

danon commented 3 years ago

Sure, I'm using 1.0.3-SNAPSHOT.

Here's the parse error: JSX tag, newline, and attribute with a template tag that holds < character. image

If I remove the new line, or I remove the < character, or I replace template string with a regular " or ' quote string, everything works ok. image image

But In my case I need both the new line, and < and the template string.

vladsholokhov commented 3 years ago

Thank you!

Moving /> to the next line fixes the issue as well. image

Original issue:


<CodeTabs
    tregx={``}
    php={`<`}/>

Of course, `first()` callback will asd qwe

:::note
WebStorm 2021.1 Beta
Build #WS-211.6305.4, built on March 2, 2021
vladsholokhov commented 3 years ago

сс: @anstarovoyt

danon commented 3 years ago

@vladsholokhov Yea, but using <> in the string still breaks it, even with the enter.

<CodeTabs
    tregx={`<>`}
    php={`<`}
/>
danon commented 3 years ago

@vladsholokhov Do you think we can start some progress here?

danon commented 3 years ago

@vladsholokhov Can you point me in the right direction, so maybe I can fix the bug myself? @@anstarovoyt

anstarovoyt commented 3 years ago

@Danon Hi! I've published the "1.2.211" version with the fix, please give it a try.

anstarovoyt commented 3 years ago

Unfortunately, the problem is rather general, so if you see something similar please let us know.

anstarovoyt commented 3 years ago

yes, it must be compatible with any IJ-based 2021.1 versions (PhpStorm, WebStorm, IJ IDEA, RubyMine, and so on)

danon commented 3 years ago

@anstarovoyt The update didn't fix it all. For example this code, still breaks it

<CodeTabs
  tregx="<c"/>

Interestingly, if you remove the enter, it doesn't break.

<CodeTabs tregx="<c"/>
danon commented 3 years ago

@anstarovoyt Remember that the attributes must work for all kinds of strings, so:

<CodeTabs
  tregx="<c"/>
<CodeTabs
  tregx={"<c"}/>
<CodeTabs
  tregx={'<c'}/>
<CodeTabs
  tregx={`<c`}/>
anstarovoyt commented 3 years ago

@Danon could you please share the full code snippet, because I cannot reproduce with problem with 1.2.211

danon commented 3 years ago

@anstarovoyt Sure: https://github.com/T-Regx/T-Regx.github.io/blob/source/docs/match-group.mdx This is a part of my documentation written in JSX. The parts in <CodeTabs are a part of code samples.

anstarovoyt commented 3 years ago

the problem is different there (as I said before it is rather general). This sample doesn't work because of the multi-line attribute value and I am not sure that it can be easily handled in the current model.

danon commented 3 years ago

@anstarovoyt So what can we do about it? Multiline attributes are valid in JSX.

Do you think you can show me shortly around, and maybe I could edit the plugin?