AsciiDoc references don't work when a custom reference is assigned
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Summary
When defining a cross reference ([[ref]]
or [#ref]
) to a section, image, or similar, that reference can't be resolved by GitLab's preview.
Steps to reproduce
Create a file.adoc
in your repository with e.g. the following content
= My Document
See [[secAnother]].
// Insert some text to achieve vertical spacing
== A section
// Insert some text to achieve vertical spacing
[[secAnother]]
== Another section
// Insert some text to achieve vertical spacing
With this file previewed in GitLab, I can create a link to A section
by clicking the link symbol left of it. The created link will look something like ...branch/file.adoc#user-content-a-section
. I can't do this for Another section
. The link will end in ...branch/file.adoc#secAnother
, which is not resolved to the correct vertical position by GitLab.
Example Project
https://gitlab.com/cbachhuber/asciidoc-playground
What is the current bug behavior?
When clicking the link left of Section 5.6.3 DOCX
, this link (https://gitlab.com/cbachhuber/asciidoc-playground#docx) is opened and I'm forwarded to a seemingly random vertical position. This is because I assigned cross reference [#docx]
to this section. Section links without a user-defined cross reference work fine, e.g. the link to the first chapter (https://gitlab.com/cbachhuber/asciidoc-playground#user-content-first-chapter).
User-defined cross references also destroy links from references within the document, such as entry 3 of the table of contents, which resolves to https://gitlab.com/cbachhuber/asciidoc-playground#alternative_heading. Other ToC entries work as expected.
With canonical asciidoctor tools, all cross references in my repository are resolved as expected, so I'm using correct syntax.
What is the expected correct behavior?
Correct vertical scrolling to the referenced item (section, image, table etc.).
Possible fixes
Can probably be solved by keeping the #user-content-item
URL ending instead of replacing it with #referenceName
.