CS Suehs <skelter....@gmail.com> writes:

> Should I expect PlantUML source blocks and their resulting images to
> be cached and respect `:cache true` ?

Yes.

> In my experience they regenerate every export, even with :cache true.

Can you provide an example?

This example caches correctly for me on v9.1.14.

    #+name: helloworld
    #+header: :cache yes
    #+BEGIN_SRC plantuml :file helloworld.png
      @startuml
      Hello --> World
      @enduml
    #+END_SRC

    #+RESULTS[f29ead8751dde1b4c4ee1b8fcb97e133c75eed0d]: helloworld
    [[file:helloworld.png]]

The only time I've seen caching break is if the diagram imports an
external file.  In that case, the diagram doesn't regenerate often
enough, because org doesn't notice that the external file changed.  The
fix to that is to include the hash of the external file as a dependent
var.

    #+name: md5
    #+BEGIN_SRC shell :cache no :var afile="PLACEHOLDER"
      md5sum $afile
    #+END_SRC

    #+name: cache-correctly
    #+header: :var md5input=md5("data.txt")
    #+BEGIN_SRC R :exports results :results output graphics :file data.svg
      aData <- read.csv("data.txt")
      ggplot(data = aData,
             mapping = aes(x = aData$id, y = aData$value))
    #+END_SRC

Thanks,
Nick

Reply via email to