Skip to content
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

Double-space in markdownDescription: code block indentations rendered as literal   #960

Closed
1 of 4 tasks
LeShaunJ opened this issue Aug 4, 2023 · 0 comments · Fixed by redhat-developer/yaml-language-server#947
Milestone

Comments

@LeShaunJ
Copy link

LeShaunJ commented Aug 4, 2023

Describe the bug

VScode's builtin json LSP extension recognizes the schema property, markdownDescription:, which prompts it to ignore description: and instead render the markdown provided. vscode-yaml is no different; however, it falls victim to the same issue that examples: (#959) faces.

That is to say, when markdownDescription: is rendered during a hover, double-spaces ( ) are rendered as literal &emsp; if they occur as indentations within <code> blocks.

Expected Behavior

When hover is called on a schema property and its mardownDescription: is rendered, double-space indentations within <code> blocks should appear as two spaces, as is the case with VScode's builtin offering for json:

image

Current Behavior

When hover is called on a schema property and its mardownDescription: is rendered, double-space indentations within <code> blocks are replaced with the literal HTMLEntity, &emsp;:

image

Steps to Reproduce

  1. Create a schema that utilizes mardownDescription:, with its content containing a <code> block that include two space indentations:
    # schema.yaml (or schema.json, either/or)
    $schema: ...
    $id: ...
    type: object
    properties:
      edge_case:
        type: string
        description: A basic description of a thing.
        markdownDescription: |
          A detailed description of a thing.
          
          ## Note
          Beware of some gotcha in which something is not what it seems because of reasons. For example:
          ```yaml
          edge_case:
            prop: caveat
          ```
          This could result in whatever, might as well be lorem ipsum.
  2. Create a YAML that is binding to the aforementioned schema:
    # yaml-language-server: $schema=schema.yaml
    edge_case: {}
  3. Hover over the offending property (in this case, the edge_case: property).
  4. Note the literal &emsp; that has replaced the two space indentation before prop: in the rendered <code> block:

    A detailed description of a thing.

    Note

    Beware of some gotcha in which something is not what it seems because of reasons. For example:

    edge_case:
    &emsp;prop: caveat

    This could result in whatever, might as well be lorem ipsum.

Peculiarities

With all that said, this is not the case when rendered during a "peek" of a completion suggestion:

image

Which pokes a hole in my initial hunch was that this was linked to #959; hence, why I create a separate issue.

Workaround

Currently, the way to get around this is to exclusively use the tab character (\t) to indent <code> block content within markdownDescrption. Though, this is not ideal, as some languages (like YAML) consider \t as invalid indentation. Furthermore, \t is rendered at a length of , which you also wouldn't want if YAML is target <code> block rendering.

Environment

  • Windows
  • Mac
  • Linux
  • other (WSL2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants