7

I write UML diagrams in org-mode with PlantUML and usually "compile" it to HTML to view the result. Is there a way to have the image show up in my buffer?

I try to enable iimage-mode but it doesn't work well. It replaces the file name at the start of the source block.

#+begin_src plantuml :file my-diagram.png
...
#+end_src
#+results:
[[file:my-diagram.png]]

Both references to the filename get replaced and the source stays. Is there a way to hide the source block and only show one instance of the image?

5

I'm not so sure about replacing the source with an image, but you can have inline images as results to source blocks.

If you add the startup option "inlineimages" to your buffer, any links in your buffer that point to local images it understands will be rendered.

If you don't have a startup options block, it would just be a line at the top of your file that looks like: #+STARTUP: inlineimages.

This only fixes half of your problem though...when you C-c C-c a block that spits out an image, you will get a link rather than an inline image...

Luckily, you can fix this by adding the following to your Emacs config:

(add-hook 'org-babel-after-execute-hook
          (lambda ()
            (when org-inline-image-overlays
              (org-redisplay-inline-images))))

This will allow you to see images inline when you first open the buffer, and update them by evaluating the block source.


Now, as for the whole source-replacing business:

I'm not sure how to do this inside of your Org buffer, but in Org exports (To HTML, PDF, and so on...), if you don't want to show the source blocks that generate their results, you can add an ":exports results" argument to the head of your code block. This will make it appear as though the source has been replaced with your image result.

0

From org-mode 8.2.10 onwards it has been possible to add the :eval no-export argument to the code block header. The result is that code block is executed normally but not exported. Only the output, figure in this case, after the #+RESULTS: line is visible in the exported document.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.