Suppose the following chunk of code:

lines = text.split`\n`

Not relevant, but it is valid ES6 code

My question is: How to write it inside one comment? When I use backticks around content it displays the content formatted as code. But what if there are backticks inside this content?

up vote 9 down vote accepted

Backslashes should do it. e.g.:

`lines = text.split\`\n\``

will produce the same formatting in a comment as you have in your question.

  • I think the OP might've meant meant inline code, not a comment. Doesn't seem to work there. (Or maybe I'm trying too hard to read things into the question.) – Cascabel Jun 10 '16 at 23:36
  • @Jefromi Hmm. Yeah, that seems to be busted. I thought multiple backticks would work there, but in testing it... guess not. – Adam Lear Jun 10 '16 at 23:38
  • It worked, thanks... @Jefromi. Sorry, probably I wrote something wrong. Thanks anyways – Washington Guedes Jun 10 '16 at 23:38
  • Ah, and there is a super-old dup for the inline version: meta.stackexchange.com/questions/55437/… - open and close with multiple backticks; that seems to work in comments too. – Cascabel Jun 10 '16 at 23:41
  • @Jefromi Aha, that's what I was thinking of. Thanks for digging it up. – Adam Lear Jun 10 '16 at 23:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .