jsx-lexer icon indicating copy to clipboard operation
jsx-lexer copied to clipboard

Error while using javascript

Open jcubic opened this issue 8 years ago • 1 comments

I have code like this:

{% highlight jsx %}
function Pagination(props, children) {
   var list = [];
   var _class;
   for (var i=0; i<props.size; i++) {
      if (i == props.selected) {
        _class = 'selected';
      } else {
        _class = '';
      }
      list.push(<li class={_class}>{i}</li>);
   }
   return (<ul>{list}</ul>);
}
{% endhighlight %}

and the output in jekyll blog post, look like this:

image

white with red have class "err".

jcubic avatar Aug 27 '17 14:08 jcubic

The issue is that the lexer is parsing <props.size; as a Tag. If you write it as i < prop.size; it will be parsed correctly.

That said, if that's valid JSX (ie: if your bundler parses it correctly), jsx-lexer should support it.

fcurella avatar Aug 28 '17 15:08 fcurella