asciidoctor / asciidoctor-kroki

Asciidoctor.js extension to convert diagrams to images using Kroki!
https://kroki.io/
MIT License
149 stars 50 forks source link

Issue when using a relative PlantUML diagram path #391

Closed rbsamoht closed 1 year ago

rbsamoht commented 2 years ago

Environment

Issue description

I am getting the error message below when generating HTML from my Antora project (project source can be found here):

Skipping plantuml block macro. ENOENT: no such file or directory, open 'docs/modules/ROOT/pages/diagrams/diagram1.puml'

I am confused because this path exists in my project structure.

Below is the content of my antora-playbook.yml file:

site:
  title: Antora bug
  start_page: antora-bug::bug.adoc
content:
  sources:
    - url: https://github.com/rbsamoht/antora-bug.git
      branches: main
      start_path: docs
ui:
  bundle:
    url: https://gitlab.com/antora/antora-ui-default/-/jobs/artifacts/master/raw/build/ui-bundle.zip?job=bundle-stable
    snapshot: true
asciidoc:
  extensions:
    - asciidoctor-kroki
  attributes:
    kroki-server-url: http://kroki:8000
    kroki-fetch-diagram: true
    diagramsdir: "docs/modules/ROOT/pages/diagrams"

Below is the directory structure of my Antora project:

├── antora-playbook.yml
└── docs
    ├── antora.yml
    └── modules
        └── ROOT
            ├── nav.adoc
            └── pages
                ├── bug.adoc
                └── diagrams
                    └── diagram1.puml

Note that I am using an Antora attribute (named diagramsdir) to link to the PlantUML diagram, as below (source of the docs/modules/ROOT/pages/bug.adoc file). A value for this attribute is provided in the antora-playbook.yml file.

plantuml::{diagramsdir}/diagram1.puml[format=svg,align="center"]

Steps to reproduce the issue

Is there anything I am doing wrong ?

ggrossetie commented 2 years ago

Note that I am using an Antora attribute (named diagramsdir) to link to the PlantUML diagram, as below (source of the docs/modules/ROOT/pages/bug.adoc file). A value for this attribute is provided in the antora-playbook.yml file.

You should use resource id instead of using an attribute: https://docs.antora.org/antora/latest/page/resource-id-coordinates/.

plantuml::example$diagram1.puml[format=svg,align="center"]

You will need to move diagram1.puml into the examples directory: https://docs.antora.org/antora/latest/page/include-an-example/#examples-root

Skipping plantuml block macro. ENOENT: no such file or directory, open 'docs/modules/ROOT/pages/diagrams/diagram1.puml'

My guess is that the extension is trying to resolve docs/modules/ROOT/pages/diagrams/diagram1.puml from the pages directory and not from the working directory/root. Anyway, you should not use relative paths when using Antora: https://docs.antora.org/antora/latest/page/resource-id/#important

ggrossetie commented 1 year ago

I'm closing this issue, if you have questions please join the community chat: https://chat.asciidoctor.org/