Escape plain text description hover correctly#283
Conversation
|
The reformatting makes it hard to discover what the fix is. Can you explain? |
Legend-Master
left a comment
There was a problem hiding this comment.
Ah sorry about the formatting/refactor, so I started with the block above and did some clean ups as I read them but then I realized that the problem is more at the toMarkdown function, the main fixes should be in there
| return plain | ||
| .trim() | ||
| .replace(/[\\`*_{}[\]()<>#+\-.!]/g, '\\$&') // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash | ||
| .replace(/([ \t]+)/g, (_match, g1) => ' '.repeat(g1.length)) // escape spaces tabs | ||
| .replace(/\n/g, '\\\n'); // escape new lines |
There was a problem hiding this comment.
This is the main fix
| enumValue = JSON.stringify(enumValue); | ||
| } | ||
| } | ||
| if (!schema) { |
There was a problem hiding this comment.
Didn't realize the change created such a big diff, the main change here is just an early return, and a for of instead of every
|
Test failure... |
Head branch was pushed to by a user without write access
Should be fixed now |
Removed `MarkedString.fromPlainText` as that escapes the input and is not what we want here (we use `toMarkdown` which isn't the same)
|
why are spaces being replaced with non line breaking spaces ( this makes text wrapping on long tooltips worse |
|
It is used to preserve consecutive spaces, text wrappings are definitely a problem though, maybe we could use pre tag here instead? Edit: |
This matches the behavior with the documentation shown in the autocomplete
With this schema:
{ "$schema": "http://json-schema.org/draft-07/schema#", "properties": { "test": { "description": "For example:\n\n<script>\n alert(1)\n</script>\n\n Test [1]" } } }Before:
After: