-
-
Notifications
You must be signed in to change notification settings - Fork 788
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
cross-document links without anchor become wrong on include #3596
Comments
That's exactly what you have to do in this scenario. Otherwise, the processor cannot know what you're linking to. Except, you should be adding the ID directly on the document title, not inline. That will fix your warning.
|
Let's try not to mix the issues, as I still see them as separate. Why can't the processor know where to link to? |
Because the include directive is not a subdocument and thus has no concept of structure (it's a preprocessor line inserter). This is something that has come up many, many times. An include does not generate a referencable part of the document. So you have to explicitly add that reference so that once the include has been resolved, there is something there to reference. We can debate about the merits of having a subdocument macro, which we've already established is necessary. But that doesn't change what is possible today. |
Don't get me wrong, I'm just looking at this from a blackbox view, I'm not in any way into the implementation of asciidoctor, subdocuments and macros.
So from a blackbox view, the including and sibling documents know which situation it is and the included knows too, so it should hopefully be possible to translate to |
It's simply not possible to accommodate that with the current include mechanism (tracking where an include was used). We would need a new mechanism. While we've talked about introducing a subdocument macro in several issues, there has never been an issue that clearly proposes it. So I've opened one. #3603
It's the policy of this processor to not hard fail by default. That's why we have the optional warning and the failure level setting. You can force it to fail if you decide.
It's doing exactly what you request it to do. It's using the fragment
where the target document has the ID That's how the interdocument xref system is currently designed to work in Asciidoctor core (for reasons I have described). |
how? I didn't find it |
The Asciidoctor CLI has a |
Well, that wouldn't really help, would it? And besides that, that would work for the possibly wrong ID case, What I suggested was, if you have some link like |
I believe I'm in a similar situation, so I post a small example here instead of #3603. I understand inter-document So if I do: == Chapter 1
[#test,reftext="go to chapter 1"]
Some test text.
xref:chapters/chapter-2.adoc#test[] == Chapter 2
[#test,reftext="go to chapter 2"]
Some test text.
xref:chapters/chapter-1.adoc#test[] The I need to write longer explicit IDs, like to append the file name: == Chapter 1
[#1-test,reftext="go to chapter 1"]
Some test text.
xref:chapters/chapter-2.adoc#2-test[] == Chapter 2
[#2-test,reftext="go to chapter 2"]
Some test text.
xref:chapters/chapter-1.adoc#1-test[] |
For the Spock documentation at https://github.com/spockframework/spock/tree/spock-1.3/docs, there is one adoc file per chapter and one
all_in_one.adoc
file that aggregates them into a one-page doc.Difference can be seen in http://spockframework.org/spock/docs/1.3/ vs. http://spockframework.org/spock/docs/1.3/all_in_one.html.
The problem is, there are some dead links in the one-page version where top level of other documents are referenced.
If you for example go to http://spockframework.org/spock/docs/1.3/interaction_based_testing.html#_explicit_interaction_blocks, there is a link to
Data Driven Testing
that is defined ininteraction_based_testing.adoc
as<<data_driven_testing.adoc#,Data Driven Testing>>
.This works perfectly fine for the multi-page version.
But in the one-page version at http://spockframework.org/spock/docs/1.3/all_in_one.html#_explicit_interaction_blocks you can see, that the same link just links to
#
on the same page.So if such a doc is included that contains a cross-document link without anchor, this should probably better be rendered as the anchor that is created only if the document is included, but not if it is rendered stand-alone.
Workaround: Manually define an anchor at the top section title of the document like
= [[data-driven-testing]]Data Driven Testing
and then make the link point to that anchor point with<<data_driven_testing.adoc#data-driven-testing,Data Driven Testing>>
, then it works in both versions. While there is a warning about "possible invalid reference" in the conversion output.The text was updated successfully, but these errors were encountered: