asciidoctor / asciidoctor-gradle-plugin

A Gradle plugin that uses Asciidoctor via JRuby to process AsciiDoc source files within the project.
https://asciidoctor.github.io/asciidoctor-gradle-plugin/
Apache License 2.0
283 stars 120 forks source link

Documentation or example for Ditaa with asciidoctorPdf task #479

Open msgilligan opened 4 years ago

msgilligan commented 4 years ago

I'm having trouble getting a Ditaa diagram to render correctly in the PDF format. I'm using the asciidoctorPdf task.

Issue #450 reported the same problem, but was closed without explanation. The example in https://github.com/ixchelruiz/asciidoctor-gradle-diagram works for me, but it doesn't use the asciidoctorPdf task. The documentation does not (directly) explain how to do this nor is there an example using the asciidoctorPdf task.

ysb33r commented 4 years ago

Can you drop a snippet of your gradle build file in here?

msgilligan commented 4 years ago

The project is open source, but I haven't pushed the build file to Github yet since it doesn't work. Here's what I'm starting with:

buildscript {
    repositories {
        jcenter()
    }
}

plugins {
    id 'org.asciidoctor.jvm.convert' version '2.4.0'
    id 'org.asciidoctor.jvm.pdf' version '2.4.0'
}

repositories {
    jcenter()
}

def buildDocDir = file('build/doc')

asciidoctorj {
    modules {
        diagram.version '1.5.18'
    }
}

asciidoctor {
  sourceDir file("$projectDir")
  sources {
    include 'PaymentChannelResearch.adoc', 'RGBProtocolOverview.adoc'
  }
  outputDir  buildDocDir
}

asciidoctorPdf {
  sourceDir file("$projectDir")
  sources {
      include 'PaymentChannelResearch.adoc', 'RGBProtocolOverview.adoc'
  }
  outputDir  buildDocDir
}

task renderAll(dependsOn: [asciidoctor, asciidoctorPdf])
ysb33r commented 4 years ago

Do not write the output of both tasks to the same folder. If you want that, rather create a Copy/Sync task that will sync from both tasks to a common folder.

msgilligan commented 4 years ago

Do not write the output of both tasks to the same folder. If you want that, rather create a Copy/Sync task that will sync from both tasks to a common folder.

I changed the output to separate folders and the problem remains. I believe the problem is specific to the Ditaa format which has different image-path processing than PlantUML, which works correctly.

Here 's the section of the PDF that shows the problem:

Screen Shot 2019-12-18 at 2 55 38 PM

ysb33r commented 4 years ago

Mmm.. I've seen that before, but cannot recall how I solved it. I'll try look into this over the weekend.

In the mean-time, maybe

asciidoctorPdf {
  useIntermediateWorkDir()
}

might help.

msgilligan commented 4 years ago
asciidoctorPdf {
  useIntermediateWorkDir()
}

might help.

That didn't seem to help. You can see the full project and the Github Actions build here: https://github.com/msgilligan/Research/commit/f9d38fda17d8d07966455fc5efe5e3aa2b7ea217/checks?check_suite_id=365725075

If you look in the archive you can see that the rendered image wasn't included in the PDF. And you can also see the error message for the missing image on line 114:

asciidoctor: WARNING: image to embed not found or not readable: /home/runner/work/Research/Research/diag-1d92173716e045e7243d9800988c027c.png