How do I remove link in code block?

Claire May 25, 2016

This question is in reference to Atlassian Documentation: Code Block Macro

I have some XML that I want to show in a code block. An element in this XML happens to have an attribute that is a URL. For example:

<add key="SomeUrl" value="https://example.com" />

I don't want the URL to be clickable. Any way to do this?

3 answers

1 accepted

0 votes
Answer accepted
Peter Milakovich
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 26, 2016

Does it need to be a code block?  When I want pure vanilla, I use the no format macro.  The URL will not be clickable.

Code Block

&lt;add key="CNN" value="https://www.cnn.com" /&gt;

No Format

&lt;add key="CNN" value="https://www.cnn.com" /&gt;
Claire May 26, 2016

But then you lose syntax highlighting. Although in my particular case, that would be quite acceptable since my XML snippet has only four lines. I'd rather do without syntax highlighting than have reader accidentally open link when attempting to select text for copy/pasting.

James AwokeKnowing June 6, 2016

@Peter Milakovich automatic links in code is also extremely undesirable at my company too, especially when documenting our api.   There are a number of links that trigger actions such as tracking counts etc and it is a problem.     

This should be controllable at least by adding a css style to each page or code block.

Jim Doyle January 21, 2021

This code block behavior creates a catch-22 for code snippets with URLs.  You can only get Confluence's "double-click to select code" behavior with a code block macro, not with No Format.  But you can only prevent these automatic links with No Format, not Code Block.  If you have a Code Block with a code snippet including a long URL, there will be a large part of the area where the user sees a "double-click to select code" tooltip, but the user's click will navigate the browser away from the confluence page, because of the automatic link.

0 votes
James AwokeKnowing June 6, 2016

agreed, this can be very annoying especially when the links have "effects" 

0 votes
Peter T
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 25, 2016

I don't think it is possible without changing the code block marco code.

There are other ways to achieve similar formatting visualization, but if you want the code block I am afraid this is how it works.

Claire May 26, 2016

I feared so. Although I can't see why having active links in a code block should be desirable. But that's ok, I'll live with it. Thanks.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events