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

Asterisk seems to be treated specially in documentation preview #42353

Closed
ramya-rao-a opened this issue Jan 29, 2018 · 11 comments
Closed

Asterisk seems to be treated specially in documentation preview #42353

ramya-rao-a opened this issue Jan 29, 2018 · 11 comments
Assignees

Comments

@ramya-rao-a
Copy link
Contributor

From @jawnsy on January 29, 2018 17:43

Description

Documentation preview requires an asterisk to be escaped, while godoc does not require the escaping. This is a pretty minor issue but I'd expect vscode-go to behave as close to godoc as possible.

Actual behavior

This comment:

// ValidFileName returns nil if the string is a valid file name, or an
// error otherwise. If pattern is true, file glob patterns are permitted
// ("*" and "?", e.g. "abc*")

is rendered like so:

actual

Notice that the * is missing between "".

Expected behavior

godoc -http renders it like so:

godoc

I'd expect this to be correct, though I haven't read godoc spec.

Workaround

You can escape the * in the comment (\*), like so:

// ValidFileName returns nil if the string is a valid file name, or an
// error otherwise. If pattern is true, file glob patterns are permitted
// ("\*" and "?", e.g. "abc*")

Then it appears to be rendered as expected:

workaround

Version info

vscode-go 0.6.73

VSCode version info (OS: Windows 10):

Version 1.19.2
Commit 490ef761b76b3f3b3832eff7a588aac891e5fe80
Date 2018-01-10T15:55:03.538Z
Shell 1.7.9
Renderer 58.0.3029.110
Node 7.9.0
Architecture x64

Copied from original issue: microsoft/vscode-go#1486

@ramya-rao-a
Copy link
Contributor Author

Thanks for reporting!
Seems to be an issue with VS Code and not the Go extension.
I get similar issues on hover text when using typescript

@ramya-rao-a
Copy link
Contributor Author

image

image

@jrieken
Copy link
Member

jrieken commented Jan 30, 2018

Seems to be an issue with VS Code and not the Go extension.

@ramya-rao-a Are you saying that you are using MarkdownString#appendText and this still happens?

There are two APIs (old/new). The old is MarkedString and extension authors must manually escape markdown syntax. The new is MarkdownString with some sugar-utils to append text as text or markdown.

@ramya-rao-a
Copy link
Contributor Author

ramya-rao-a commented Jan 30, 2018

For Go, I am using the old MarkedString, I can give the new one a try.
My screenshots in #42353 (comment) are for typescript. @mjbvz What do you use there?

@jrieken jrieken assigned ramya-rao-a and unassigned jrieken Jan 30, 2018
@mjbvz
Copy link
Collaborator

mjbvz commented Jan 31, 2018

We support markdown content in JSDocs so we don’t escape anything. The * is probably being treated as the start of italics. Can you escape the * manually in the doc?

@ramya-rao-a
Copy link
Contributor Author

@mjbvz Thats right. The text between the 2 * is being treated as italics in typescript.

So what's the expectation here?
We cant expect code owners to escape the * all the time

@jawnsy
Copy link

jawnsy commented Jan 31, 2018

The expectations might be different between JavaScript/TypeScript/JSDoc and Go/godoc.

I'd expect JSDoc to render markdown content if the Markdown plugin is configured, but not otherwise. In other words, I'd expect the preview to be as close as possible to what I'd see in generated HTML. The current behavior doesn't seem to check the configuration before rendering?

godoc doesn't seem to support Markdown as far as I can tell, so it shouldn't be rendered in VSCode either.

@mjbvz
Copy link
Collaborator

mjbvz commented Feb 1, 2018

@ramya-rao-a No good solution. Either you convert your jsdocs to markdown or we disable markdown everywhere. I don't think we can detect when a jsdoc comment should or shouldn't be markdown (although if you surround the * with spaces, I don't think it will be treated as an italic marker)

@ramya-rao-a
Copy link
Contributor Author

@mjbvz Anyway I can tell the hoverprovider to treat given content as just string and not markdown?

@mjbvz
Copy link
Collaborator

mjbvz commented Feb 2, 2018

@ramya-rao-a In general, or for a given jsdoc?

@mjbvz
Copy link
Collaborator

mjbvz commented Mar 1, 2018

Closing this as-designed for jsdocs. No good solution without breaking jsdocs that do want to use markdown.

Workaround is to escape any special markdown characters, such as \*

@mjbvz mjbvz closed this as completed Mar 1, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Apr 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants