Links to other elements in imported markdown are not imported correctly

Sam Schreiner February 2, 2021

I'm trying to include some automatically-generated markdown on a wiki page. I'm using the "Insert Markup" macro to insert the markdown into a wiki page. My issue is that I cannot find a solution to create inter-page links (hyperlinks to other anchors on the same page).

 

Things I've tried:

Option 1: Using an "id" or "name" attribute on an HTML element in the markdown to create an anchor point. The problem is that "id" and "name" html attributes are stripped off when saving (but not on import!). For instance,

<span id="test"> TEST ME </span> 

is correctly imported (yes, I know it's HTML nested within markdown), but when I save the page, the id is stripped away and all I'm left with is:

<span> TEST ME </span> 

To get this option to work, I'd have to figure out a way to maintain the id attribute when saving. I imagine Conluence strips all that stuff off for security reasons or something.

 

Option 2: Try to use a pure markdown approach.

[link to my heading](#myHeading)
## myHeading

This works in most markdown viewers (I've tested in github and a Visual Studio Code markdown viewer extension), but when I import into Confluence it turns into the following:

<a href="#myHeading">link to my heading</a>
<h2 id="Page-Name-myHeading"> myHeading </h2>

So the problem here is that Confluence appends "Page-Name" (the specific name of whatever page this is on) to the anchor when creating the <h2> tag, but it creates the INCORRECT href attribute on the <a> tag. This seems to be a bug in Confluence, but perhaps I'm using it wrong?

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events