asciidoctor / asciidoctor-kroki

Asciidoctor.js extension to convert diagrams to images using Kroki!

Home Page:https://kroki.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue when using a relative PlantUML diagram path

rbsamoht opened this issue · comments

Environment

  • Ubuntu 22.04 LTS
  • Antora 3.1.0
  • Kroki 0.17.2
  • asciidoctor-kroki 0.16.0

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

  • Start a kroki server so that it is accessible at the following URL: http://kroki:8000
  • Run the following command: antora generate antora-playbook.yml, using the Antora playbook presented above

Is there anything I am doing wrong ?

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

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