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
Include directive does not find file relative to current file #369
Comments
I wouldn't say it goes against the behavior of the include directive. The target of an include directive is relative to the base directory (if set) or the document directory otherwise. If you alter those settings, you alter where the processor looks for the file. The one exception are nested includes. These should always be resolved relative to the document that is including them. That's because changing this behavior would be non-portable. Having said that, how top-level includes are resolved is a choice that should not be taken away from the author. |
@mojavelinux Maybe I should have written "against my expectations based on reading the Asciidoctor User Manual and the previous versions of the asciidoctor-gradle-plugin", but then again, the documentation says "The base directory defaults to the directory of the main document and can be overridden from the CLI or API", and asciidoctor-gradle-plugin no longer defaults to that location. |
The Gradle plugin has changed this default several times in its history, so it's always been an exception to the rule. The user manual describes what the core processor does, but it's not a mandate. I have no problem with the default. I would only have a problem if it's not configurable. (For example, consider what the Jekyll AsciiDoc plugin does: https://github.com/asciidoctor/jekyll-asciidoc#specifying-the-base-directory) |
@mojavelinux Thanks for the clarification. Such a solution (which is similar to what Schalk proposed in the other issue would be acceptable to me. |
…idoctor#369) Even with standardisation in 2.0, there are use cases which confuse users or surprises their contextual expectations. Therefore it is now possible to use specific strategies for controlling the base directory: - Base directory is root project directory - Base directory is project directtory - Base directory follows the source directory even if an intermediate working directory is being used. By default the base directory will still be the project directory as has been the case for 1.5 & 2.0. The base directory can also be set to be any arbitrary directory as required.
…idoctor#369) Even with standardisation in 2.0, there are use cases which confuse users or surprises their contextual expectations. Therefore it is now possible to use specific strategies for controlling the base directory: - Base directory is root project directory - Base directory is project directtory - Base directory follows the source directory even if an intermediate working directory is being used. By default the base directory will still be the project directory as has been the case for 1.5 & 2.0. The base directory can also be set to be any arbitrary directory as required.
…idoctor#369) Even with standardisation in 2.0, there are use cases which confuse users or surprises their contextual expectations. Therefore it is now possible to use specific strategies for controlling the base directory: - Base directory is root project directory - Base directory is project directtory - Base directory follows the source directory even if an intermediate working directory is being used. By default the base directory will still be the project directory as has been the case for 1.5 & 2.0. The base directory can also be set to be any arbitrary directory as required.
Allows simplified strategies for controlling the base directory (asciidoctor#369)
THe README has been updated to reflect this.
Fixed and scheduled for 2.2.0. |
I think you're missing one, which is that the basedir is not set (or it matches the docdir). That matches the default behavior of the processor. (Keep in mind, the whole basedir needs to be rethought because in many ways it's unintuitive, but we'll address that in core first). |
@mojavelinux I think basedir has always been set in the Gradle plugin - even before my time |
I get that. What I'm trying to communicate is that the processor doesn't work very consistently when basedir is set. It's a flaw in the design of core that needs addressing. It's purpose is just not very well defined. |
As a followup on #323, with asciidoctor-gradle-plugin 2.0 and higher, the include directive no longer works as documented in the Asciidoctor User Manual.
The workaround to add
{includedir}
to resolve includes correctly goes against the behavior of the include directive documented in the Asciidoctor User Manual, section File resolution:This change requires asciidoctor-gradle-plugin specific changes to sources, tightly coupling it to asciidoctor-gradle-plugin and breaking preview in authoring tools (eg resulting in "Unresolved directive in - include::{includedir}/chapters/introduction/introduction.adoc[]" in the preview of the Visual Studio Code Asciidoctor plugin), and hinders use of different asciidoctor (build) tools with these sources.
As the second rule (includes relative to included files) is supported, the workaround seems to be to define an asciidoctor-gradle-plugin specific root-document that only contains
When authoring using
real_root_document.adoc
, other tools will correctly render the files, but this is hardly a good solution in my opinion.This is possibly a regression from #83.
The text was updated successfully, but these errors were encountered: