Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Hello,
I'm trying to use diagrams using asciidoctor-j (1.5.3-SNAPSHOT) and working well. How can I specify the target directory for generated diagrams ? Thanks Patrick |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
If you use Asciidoctor Diagram 1.3 preview, you can specify using the imagesoutdir attribute. It also has a more sane default. A final version of 1.3 should be released shortly. Cheers, -Dan |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
I am not able to specify the output directory... (I am using asciidoctor-j 1.6 SNAPSHOT)
I tried something like: Attributes attributes = new Attributes (); attributes.setAttribute ("imagesoutdir", new File ("/tmp/test-images")); Options options = new Options (); options.setAttributes (attributes); String asciiDocHtml = asciidoctor.convert (asciiDocStr, options); and Options options = new Options (); options.setAttribute ("imagesoutdir", new File ("/tmp/test-images")); String asciiDocHtml = asciidoctor.convert (asciiDocStr, options); What am I missing ? Patrick |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
I found two problems here.
First, AsciidoctorJ includes the ruby gem asciidoctor-diagram 1.3.preview.1 (https://github.com/asciidoctor/asciidoctorj/blob/asciidoctorj-1.6.0/asciidoctorj-diagram/gradle.properties#L3). However, the attribute Dan mentioned was included in 1.3.preview.3. I could make your code work changing the version in asciidoctorj-diagram (the jar) and installing asciidoctorj-diagram locally. So, I'm sorry to say there's no public fix for your problem. Second, in your code, you use convert which outputs the generated files to a String, I've tested it and I see that it does not create any output file, html or images. Using convertFile created the images in the folder set in imagesoutdir. If you need to get the content of the HTML this could be a problem. Here is a snippet of my test:
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
I changed the version in asciidoctorj-diagram (to 1.3.preview.3).
the diagrams are generated in the output directory (great !!) but... The generated html doesn't include the output directory ... I get < img src="diagram-classes.png" alt="diagram classes" width="256" height="283"> instead of < img src="myfolder/diagram-classes.png" alt="diagram classes" width="256" height="283"> ![]() |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Now, here it come one of those funny cases. There's a simple solution but I think this may collide with your use case.
Before getting into details, can you explain what are you trying to achieve? Now the solution; the thing is that asciidoctor-diagram uses 'imagesoutdir' to define the target folder to generate the images. But, it uses 'imagesdir' to set the path in the image element of the document. So the simple solution is setting the 'imagesdir' attribute to the same value as 'imagesoutdir'. But depending on what you would like to do, mixing folders may be a problem. Part of me thinks this could be considered a bug, but not sure. |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
BTW, here it is the original conversation about the attribute. There're some interesting comments about the meaning of attributes you may be interested on.
https://github.com/asciidoctor/asciidoctor-diagram/issues/39 |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Actually, I am rendering the html as string and writing it to a target directory myself.
When rendering a String, the output directory of Asciidoctorj-diagrams is the WORKING directory... I am using the imagesDir for all images and working as expected. When imagesDir is used, imagesoutdir is not used at all. The images are generated in imagesDir (in the working directory) I would need to use imagesoutdir as an ABSOLUTE target to generate diagrams and I could set imagesDir accordingly. I think currently the only way achieve my goal is to move the generated diagrams to my target directory after the generation... |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
On Tue, Aug 4, 2015 at 1:15 AM, patrickm [via Asciidoctor :: Discussion] <[hidden email]> wrote: I think currently the only way achieve my goal is to move the generated diagrams to my target directory after the generation... That's in part the design behind the imagesoutdir. The idea is to prevent it from putting the images into a source folder, not necessarily the right final folder. A build tool can then get them to the final resting spot. ...another solution is to specify an absolute path for imagesoutdir as you have pointed out. No real harm in that, bien sûr. Cheers, |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Yes, except that imagesoutdir is not used when using imagesdir (and I have to use it)... ![]() Thanks ... Patrick |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
On Tue, Aug 4, 2015 at 7:45 AM, patrickm [via Asciidoctor :: Discussion] <[hidden email]> wrote: Yes, except that imagesoutdir is not used when using imagesdir (and I have to use it)... It should be. -Dan |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Strange... With asciidoctorj 1.6-SNAPSHOT patched with asciidoctorj-diagram to 1.3.preview.3.
public static void main (String[] args) throws Exception { OptionsBuilder optionsBuilder = OptionsBuilder.options ().safe (SafeMode.UNSAFE).backend ("html5").mkDirs (true); Attributes attributes = new Attributes (); attributes.setAttribute ("imagesoutdir", "/tmp/images-1"); attributes.setImagesDir (new File ("/tmp/images-2").getPath ()); optionsBuilder.attributes (attributes); Asciidoctor asciidoctor = Asciidoctor.Factory.create (); asciidoctor.requireLibrary ("asciidoctor-diagram"); String asciiDocString = "[plantuml, diagram-sequence, png] \n" + "....\n" + "Alice -> Bob: Authentication Request\n" + "Bob --> Alice: Authentication Response\n" + "Alice -> Bob: Another authentication Request\n" + "Alice <-- Bob: another authentication Response\n" + "...." ; System.out.println (asciidoctor.render (asciiDocString, optionsBuilder.asMap ())); }the images are generated in "/tmp/images-2" and the produced String is: <div class="imageblock"> <div class="content"> <img src="/tmp/images-2/diagram-sequence.png" alt="diagram sequence" width="293" height="215"> </div> </div> |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
On a side note, 1.3.0 is now available. I strongly recommend that you first try it with the Ruby version of Asciidoctor and Asciidoctor Diagram just to ensure that it is behaving as you expect. Then try it with AsciidoctorJ. That way, we know where the problem is occurring. It could very well be somewhere in between. -Dan On Wed, Aug 5, 2015 at 2:28 AM, patrickm [via Asciidoctor :: Discussion] <[hidden email]> wrote: Strange... With asciidoctorj 1.6-SNAPSHOT patched with asciidoctorj-diagram to 1.3.preview.3.public static void main (String[] args) throws Exception { OptionsBuilder optionsBuilder = OptionsBuilder.options ().safe (SafeMode.UNSAFE).backend ("html5").mkDirs (true); Attributes attributes = new Attributes (); attributes.setAttribute ("imagesoutdir", "/tmp/images-1"); attributes.setImagesDir (new File ("/tmp/images-2").getPath ()); optionsBuilder.attributes (attributes); Asciidoctor asciidoctor = Asciidoctor.Factory.create (); asciidoctor.requireLibrary ("asciidoctor-diagram"); String asciiDocString = "[plantuml, diagram-sequence, png] \n" + "....\n" + "Alice -> Bob: Authentication Request\n" + "Bob --> Alice: Authentication Response\n" + "Alice -> Bob: Another authentication Request\n" + "Alice <-- Bob: another authentication Response\n" + "...." ; System.out.println (asciidoctor.render (asciiDocString, optionsBuilder.asMap ())); }the images are generated in "/tmp/images-2" and the produced String is:<div class="imageblock"> <div class="content"> <img src="/tmp/images-2/diagram-sequence.png" alt="diagram sequence" width="293" height="215"> </div> </div> ... [show rest of quote] Dan Allen | http://google.com/profiles/dan.j.allen |
Free forum by Nabble | Edit this page |