asciidoctor / asciidoctor-diagram

:left_right_arrow: Asciidoctor diagram extension, with support for AsciiToSVG, BlockDiag (BlockDiag, SeqDiag, ActDiag, NwDiag), Ditaa, Erd, GraphViz, Mermaid, Msc, PlantUML, Shaape, SvgBob, Syntrax, UMLet, Vega, Vega-Lite and WaveDrom.
http://asciidoctor.org
MIT License
432 stars 106 forks source link

D2: Set working directory for the process(?) to document dir so that relative images can be resolved. #410

Closed eiswind closed 1 year ago

eiswind commented 1 year ago

Currently an image relative to the document cannot be resolved.


test: {
  shape: image
  icon: ./images/target.png
}
eiswind commented 1 year ago

After a little digging i have to add that I'm running on JRuby. There is a "JAVA" switch there for the CLI Runner. Doing Dir.pwd prints the documents directory, so this seems to be ok.

but d2 is using my Home-Directory for the basepath, but I did not find out where this is coming from.

Can anyone give me a pointer here?

pepijnve commented 1 year ago

@eiswind could you give df004ecb65649850da045732d144c2725b8e9349 a try on jruby? I've tested with MRI already and that works correctly now afaict.

eiswind commented 1 year ago

Thanks for your support! First to say I have little to absolutely no clue about what I'm doing here.

What I'm doing is kind of hacky as I'm using artifacts from asciidoctorj with maven. There I can override some files (not knowing what I'm doing) using local requires. This seems to work for converter.rb where I did the sketch patch.

When I try to add the cli_generator (which pulls in java.rb etc) it fails with undefined method `put' for # Does that mean anything to you?

looking at the build files for asciidoctorj-diagram i have no idea how to build that from ruby sources as it uses a gem download.

pepijnve commented 1 year ago

Not sure what the put error is about, but it looks like I made a couple of small mistakes. The tests were failing as well. I've tweaked the code a bit and things seem to be working correctly under jruby as well now.

eiswind commented 1 year ago

Thanks again. This Maven Setup is a pain when it comes to patching.

eiswind commented 1 year ago

I can confirm that this is ok now.