Search code examples
sqlmacrosescapingsanitizationconfluence

How can prevent confluence from auto-linkyfing square brackets produced by a macro?


I'm using Atlassian Confluence (woe is me).

I have an {sql} macro inside a groovy macro in a wiki markup block. Now, the SQL selects some strings which look like Foo[Bar]. The results wiki page auto-linkifies the bar, i.e. you get

FooBar

which is not what I want. I tried something like

SELECT REPLACE(REPLACE(name, '[', '\['), ']', '\]') FROM mytable;

but that triggered an error, while

SELECT REPLACE(REPLACE(name, '[', '\\['), ']', '\\]') FROM mytable;

didn't trigger an error but also did not help. What can I do?


Solution

  • Your macro is outputting the string in wiki-markup. A simple solution would be to make sure that you're preventing the output being interpreted as wiki-markup, by enclosing the result in {html} tags.