mattn / emmet-vim

emmet for vim: http://emmet.io/
http://mattn.github.io/emmet-vim
MIT License
6.43k stars 411 forks source link

Error on curly brace content (javascript) #332

Closed zanona closed 8 years ago

zanona commented 8 years ago

Apparently when using content replacement on tags if there's a curly brace followed by a character, it will ignore the rest of the expression To replicate:

 script{obj={foo:'bar'};} #stops at first }
 script{foo({foo:'bar'})} #stops at first }
 script{obj={foo:'bar'}}  #works

Expands to:

<script>obj={foo:'bar'</script>
<script>foo({foo:'bar'</script> 
<script>obj={foo:'bar'}</script>
mattn commented 8 years ago

This is bits difficult to implement. For example, emmet doesn't work with script{obj={foo:'b}ar'};}. Please try this on http://docs.emmet.io/

mattn commented 8 years ago

FYI, single quote must not work with escaping. because we may use {} like below.

{don't expand single quote}
zanona commented 8 years ago

Thanks @mattn I see that script{obj={foo:'b}ar'};} indeed won't work on emmet website as you mentioned. Although script{obj={foo:'bar'};} seems to work fine?

mattn commented 8 years ago

What the behavior do you expect about below?

script{"don't}+div{don't"}
zanona commented 8 years ago

I believe something like the below?

<script>"don't</script>
<div>don't"</div>

Now if I could scape the curly brace like:

script{"don't\}+div\{don't"}

I would expect something like:

<script>
  "don't}+div{don't"
</script>
zanona commented 8 years ago

Thanks a lot @mattn! I'm afraid, there is still an edge case causing errors such:

script{obj={foo:'${1}'};} 

outputting:

<script>obj={foo:''</script> 

instead of:

<script>obj={foo:'_'};</script>
mattn commented 8 years ago

fixed.

zanona commented 8 years ago

Thanks again @mattn, Sorry if I am seeming too picky but here's another case where it's returning an error:

script{${1}}+div{${1}} 

output:

<script>}+div{</script> 

expected would be:

<script>_</script>
<div></div>
mattn commented 8 years ago

please try again

zanona commented 8 years ago

@mattn thanks a lot for your work on this! The past change works great but when using with white space characters like:

script{${1} foo bar}+div{${1}}

It still outputs

<script> foo bar}+div{</script>

instead of

<script> foo bar</script>
<div></div>
mattn commented 8 years ago

note that this simple parser doesn't work with nested braces

zanona commented 8 years ago

Understood! Thanks a lot for all your help @mattn. It seems to be working great now! Have a great weekend