Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

publishToConfluence looses the id when generating level 2 page anchors #1161

Closed
srotman opened this issue May 9, 2023 · 1 comment · Fixed by #1162
Closed

publishToConfluence looses the id when generating level 2 page anchors #1161

srotman opened this issue May 9, 2023 · 1 comment · Fixed by #1162
Labels

Comments

@srotman
Copy link
Contributor

srotman commented May 9, 2023

Describe the bug
When using the subpagesForSections=2 setting, Confluence will loose the links to level 3 adoc headers

To Reproduce
Steps to reproduce the behavior:

  1. Set the concluence.with setting for subpagesForSections to 2
  2. Include a level 3 heading on an included page (In my case a level 2 heading, but with leveloffset +1, using the https://docs.asciidoctor.org/pdf-converter/latest/interdocument-xrefs/#converting-interdocument-xrefs-to-internal-xrefs syntax)
  3. The generated HTML page will render those as headers as h3 headings.
  4. On publishing, the pageAnchor for these headings gets lost, and no link macro will be generated for these links, resulting in broken links on the published Confluence page.

Expected behavior
The pageAnchors are not lost, and the links on the published Confluence page work :-)

Configuration

  • docToolchain 2.2.1, as well as docToolchain latest.
  • OS: Windows
  • JDK 11

Additional context
I created a minimal example containing this issue: https://github.com/srotman/docToolchain-1161

According to my analysis, the problem lies in the getPagesRecursive function:

def title = sect.select("h${level + 1}").text()
Elements pageBody
if (level == 1) {
pageBody = sect.select('div.sectionbody')
} else {
pageBody = new Elements(sect)
pageBody.select("h${level + 1}").remove()
}
def currentPage = [
title: title,
body: pageBody,
children: [],
parent: parentId
]
pageAnchors.putAll(recordPageAnchor(sect.select("h${level + 1}")))

It seems that the new Elements(...) constructor (line 949) does not perform a deep Copy, resulting in a removal of the h3 element on line 950. The subsequent select of that same element on line 958 now yields no results any longer.

If this line:

pageAnchors.putAll(recordPageAnchor(sect.select("h${level + 1}")))
is moved up to line 945 (right after the initial select) the pageAnchors are kept correctly, and the Confluence links will work as expected.

srotman pushed a commit to srotman/docToolchain-1161 that referenced this issue May 9, 2023
srotman added a commit to srotman/docToolchain that referenced this issue May 9, 2023
srotman added a commit to srotman/docToolchain that referenced this issue May 9, 2023
srotman added a commit to srotman/docToolchain-1161 that referenced this issue May 9, 2023
srotman added a commit to srotman/docToolchain-1161 that referenced this issue May 9, 2023
@srotman
Copy link
Contributor Author

srotman commented May 10, 2023

Would be fixed by #1162

@mh182 mh182 linked a pull request May 12, 2023 that will close this issue
5 tasks
PacoVK added a commit that referenced this issue May 12, 2023
…removal

Record page anchor before header removal. fixes #1161
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants