We can document code with backticks in JSdoc to see it styled like interpreted markdown when hovering over the definition:

/**
 * This function is similar to `someFunction(foo)`
 */
function bar() { ... }

This shows up as approximately the following on hover:

This function is similar to someFunction(foo)

But how can we document code that uses backticks, like tagged templates?

/**
 * This function is similar to `taggedFn\`foo ${someVar}\``
 */
function boo() { ... }

This shows up as approximately the following on hover (the formatting issues are intentional to illustrate the problem):

This function is similar to taggedFn\ foo ${someVar}``

This last example is how some other apps like Discord normally handle it: by allowing to escape backticks with a backslash as is common in markdown. However, this doesn't work in VSCode when hovering over the function definition as shown in the example output.

Note: Not tagging this question for JSdoc / PHPdoc because while these are the only instances where VSCode does this type of markdown rendering in code, it's not actually related to JSdoc or the others.

2 Replies 2

You can wrap with triple ticks:

* This function is similar to ```taggedFn`foo ${someVar}` ```

Note the `[space]``` at the end - you need that space for disambiguation.

So basically a code fence around the outside - I "think" it is the look you are after. Inside triple ticks, any backtick is just a regular character.

Thank you Mark, that works great! I hope I never need triple backticks inside triple backticks.

Your Reply

By clicking “Post Your Reply”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.