Skip to content

Some links between markdown files point to non-existing pages #294

@cmanique

Description

@cmanique

Hello,

Running version 7.12 of plugin with Java 8 or 17, against confluence server 7.x.

Please find below the steps to try and reproduce links being generated to non-existing pages.

site.yaml

home:
  uri: home.md
  children:
    - name: Page-A
      uri: a.md
      children:
        - name: Page-B
          uri: b.md
        - name: Page-C
          uri: c.md

a.md

# Page A
- [This is Page-B Link](b.md)
- [This is Page-C Link](c.md)

b.md

# Page B
- [This is Page-A Link](a.md)
- [This is Page-C Link](c.md)

c.md

# Page C
- [This is Page-A Link](a.md)
- [This is Page-B Link](b.md)

The page structure is correctly published to confluence:

unnamed

However some of the links are not correctly generated, as you can see on the storage format for each of the pages:

Page-A storage format:

<h1>Page A</h1>
<ul>
  <li>
    <ac:link>
      <ri:page ri:content-title="TCAAS3218-466 - Page-B"/>
      <ac:link-body>This is Page-B Link</ac:link-body>
    </ac:link>
  </li>
  <li>
    <ac:link>
      <ri:page ri:content-title="TCAAS3218-466 - Page-C"/>
      <ac:link-body>This is Page-C Link</ac:link-body>
    </ac:link>
  </li>
</ul>

Page-B storage format:

<h1>Page B</h1>
<ul>
  <li>
    <ac:link>
      <ri:page ri:content-title="TCAAS3218-466 - TCAAS3218-466 - Page-A"/>
      <ac:link-body>This is Page-A Link</ac:link-body>
    </ac:link>
  </li>
  <li>
    <ac:link>
      <ri:page ri:content-title="TCAAS3218-466 - Page-C"/>
      <ac:link-body>This is Page-C Link</ac:link-body>
    </ac:link>
  </li>
</ul>

Page-C storage format:

<h1>Page C</h1>
<ul>
  <li>
    <ac:link>
      <ri:page ri:content-title="TCAAS3218-466 - TCAAS3218-466 - Page-A"/>
      <ac:link-body>This is Page-A Link</ac:link-body>
    </ac:link>
  </li>
  <li>
    <ac:link>
      <ri:page ri:content-title="TCAAS3218-466 - TCAAS3218-466 - Page-B"/>
      <ac:link-body>This is Page-B Link</ac:link-body>
    </ac:link>
  </li>
</ul>

It seems like the pages are being processed/created in ascending order, and the only links that are broken are the ones for pages that didn’t exist at the time (they have an extra TCAAS3218-466).
TCAAS3218-466 in this case is the value of the pageTitle parameter (didn’t try this with the default that uses maven cords, but I’d naifly argue it’s not related).

By glancing at the repo I'm tempted to say the code below is the likely culprit:

public void visit(Link node) {
final String destination = processLinkUrl(node.getDestination(), parseContext);
processChildren(node)
//.preAndPost("<<LNK>>")
.pre(() -> "[" )
.captureOutput( v -> buffer().append(v) ) // ignore text
.post(() -> format("|%s%s]", destination, ofNullable(node.getTitle()).map( v -> "|"+v ).orElse("")) )
.process()
.nl(isParentRoot(node));
}

Maybe it needs a second pass to recheck destinations that were not yet present, or something of the sort.

Metadata

Metadata

Assignees

Labels

bugdiscussionstart discussion about issue

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions