Moving the indentation escaping logic to toMarkdown, so that we only escape non-markdown strings. Currently the escaping is done on the entire hover content, regardless of whether that content contains actual markdown. This change also fixes a bug where intentional indentation in markdownDescription is erroneously escaped.
Before:
After:
Note: I originally tried to keep the single header (rather than repeating it per-example), but the code fences don't appear to have a margin applied so the examples were all bunched together. Repeating the header looked much nicer.
What issues does this PR fix or reference?
Fixes: redhat-developer/vscode-yaml#896
Fixes: redhat-developer/vscode-yaml#959
Fixes: redhat-developer/vscode-yaml#960
Fixes: redhat-developer/vscode-yaml#961
Fixes: redhat-developer/vscode-yaml#965
Is it tested? How?
I updated an existing unit test. Also tested manually with the following (see screenshots):
schema.json:
{
"$id": "schema.json",
"$schema": "https://json-schema.org/draft-07/schema",
"title": "Example Schema",
"properties": {
"example": {
"title": "Example Property",
"description": "This property has examples that should be rendered as YAML code blocks.",
"examples": [
"string value",
{
"object_value": {
"enabled": true
}
}
],
"type": [
"object",
"string"
]
}
},
"type": "object"
}
coverage: 84.076% (+0.005%) from 84.071%
when pulling 7ff405ffa63f9979d254833363c630492808af5f on twelvelabs:examples-on-hover
into 5458ed334db24c36b341d296b5a39e1cc9cead95 on redhat-developer:main.
What does this PR do?
This MR improves the rendering of examples on hover by:
toMarkdown
, so that we only escape non-markdown strings. Currently the escaping is done on the entire hover content, regardless of whether that content contains actual markdown. This change also fixes a bug where intentional indentation inmarkdownDescription
is erroneously escaped.Before:
After:
Note: I originally tried to keep the single header (rather than repeating it per-example), but the code fences don't appear to have a margin applied so the examples were all bunched together. Repeating the header looked much nicer.
What issues does this PR fix or reference?
Is it tested? How?
I updated an existing unit test. Also tested manually with the following (see screenshots):
schema.json
:example.yaml
: