Jiří Lechner
Jiří Lechner

Reputation: 820

How to write square brackets in markdown

I need to write in my gitlab project wiki page a code block that contains square brackets. Unfortunately the square brackets are turn into a link. I assume gitlab is using markdown language or the gfm flavor.

This is my code:

```javascript
"{bla, """", [[foo],[]]}"
```

The foo],[ part is turn into a link. So basicaly I need a way to write a square brackets tah are not treated as a link. Surprisingly google doesn't provide any answer for such a trivial issue.

Upvotes: 1

Views: 6516

Answers (1)

JGC
JGC

Reputation: 6363

The current answer is that you can't do this. It is a know bug in GitLab, specifically in Wiki pages. GitLab markdown correctly handles square brackets in comments, and code blocks entered in issues, but NOT in wiki pages.

Please add your vote (thumbs up) on the issue to try and get it resolved:

https://gitlab.com/gitlab-org/gitlab-ce/issues/18725

Your (not very appealing) options boil down to these:

  1. Use a single line code entry `"{bla, """", [[foo],[]]}"`
  2. Use another syntax in your code block (e.g. {{), and include a note outside the code block saying to replace {{ with [[, etc - Note that you can use double brackets inside single quote blocks in GitLab Markdown.
  3. Use a screenshot of your code.

None of these are very nice solutions, but all you have at the moment.

Upvotes: 3

Related Questions