New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Typescript markup for comment after enclosed lambda. #2489
Conversation
@@ -0,0 +1,2 @@ | |||
<span class="hljs-keyword">const</span> bad = <span class="hljs-function">(<span class="hljs-params">(a, b</span>) =></span> [...a, b]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not correct output, please compare to https://github.com/highlightjs/highlight.js/blob/master/test/markup/typescript/functions.expect.txt (wrt: params wrapping)
The () aren't being wrapped or paired properly. The proper fix here is likely more complex.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You would also need some tests for nested parenthesis inside arguments, which is likely what the self was trying to catch in the first place.
return this.sides.every((length,width=(3+2+(4/5))) => length > 0 );
They have to be properly paired so the first )
we see doesn't end the params.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but Javascript has the same problem. At least this change produces the same output that JS language produces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a perfect world I think simple cases would look something like:
const bad = ((a, b) => [...a, b]);
const bad = (a => [...a, b]);
bad = (<span class="hljs-function">(<span class="hljs-params">a, b</span>) =></span> [...a, b]);
bad = (<span class="hljs-function"><span class="hljs-params">a</span> =></span> [...a, b]);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I see.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but Javascript has the same problem. At least this change produces the same output that JS language produces.
Then it would seem they are both broken, just in different ways. Fixing some of these requires really digging in deep and understanding what is happening, why the rules are there, the different possible issues (like in this case nested parens), etc. My bet is this is one of the harder ones, but I"m not certain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you were trying to follow my last comment (thanks) but now that I've looked a little closer I don't think the fix here is just "do what JS does".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
------------v
const bad = ((a, b) => [...a, b]);
The problem here is that first ( is matched as the start of a function when it is not, it's just an expression. That's what someone needs to tackle here - this misdetection.
If you're curious I believe this actually resolves the issue: |
This resolves #2189. Function params can't contains
self
.