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

textDocument/hover Markdown and double escaping of punctuation characters #301

Closed
danielmartin opened this issue Mar 5, 2020 · 1 comment

Comments

@danielmartin
Copy link

My editor is getting the following Markdown as part of the textDocument/hover payload:

Result: {
  "range": {
    "start": {
      "line": 46,
      "character": 37
    },
    "end": {
      "line": 46,
      "character": 54
    }
  },
  "contents": {
    "value": "### variable `annotationBuilder`  \n\n---\nType\\: `FBS::AnnotationPropertiesBuilder`  \n\n---\n```cpp\n// In AnnotationFlatbufferTest_PrimitiveTypeDeserialization_Test::TestBody\nFBS::AnnotationPropertiesBuilder annotationBuilder(builder)\n```",
    "kind": "markdown"
  }
}

As you can see, the colon after "Type" is double escaped: Type\\: This is causing that my editor shows an additional backlash in its documentation window:

Screenshot 2020-03-04 at 11 54 48 PM

If I paste the same Markdown into a GH issue and preview it, the same additional backslash is rendered:

Screenshot 2020-03-05 at 8 48 37 AM

The double backlash seems to be added at https://github.com/llvm/llvm-project/blob/c0b27c489104f6c3c055a3ac1573d05393fe32eb/clang-tools-extra/clangd/FormattedString.cpp#L42 I'm not very familiar with Markdown syntax so my question is, is it really needed to add a double backslash here or a single one would suffice? I'm deciding If this is something that should be fixed server-side or client-side. Thanks.

@sam-mccall
Copy link
Member

There's just a single backslash in the content, the second one is in the JSON encoding of the string only.

That said, we're indeed doing too much escaping here - it's not necessary and apparently not recognized by GFM.

Over escaping also causes problems in coc.nvim that chooses to display and highlight the markdown.

arichardson pushed a commit to arichardson/llvm-project that referenced this issue Apr 2, 2020
Summary:
Conservatively escaping everything is bad in coc.nvim which shows the markdown
to the user, and we have reports of it causing problems for other parsers.

Fixes clangd/clangd#301

Reviewers: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75687
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this issue Oct 7, 2022
Summary:
Conservatively escaping everything is bad in coc.nvim which shows the markdown
to the user, and we have reports of it causing problems for other parsers.

Fixes clangd/clangd#301

Reviewers: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75687
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

No branches or pull requests

2 participants