# Is there a weave live preview server?

**URL:** <https://discourse.julialang.org/t/is-there-a-weave-live-preview-server/40466>\
**Category:** New to Julia\
**Tags:** vscode, literate-programming\
**Created:** [May 30, 2020, 11:03am UTC](https://discourse.julialang.org/t/is-there-a-weave-live-preview-server/40466 "2020-05-30T11:03:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![feanor12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/feanor12/32/8212_2.png) [@feanor12](https://discourse.julialang.org/u/feanor12)\
**Post date:** [May 30, 2020, 11:03am UTC](https://discourse.julialang.org/t/is-there-a-weave-live-preview-server/40466/1 "2020-05-30T11:03:55Z")

</div>

I want to write a document using weave, but currently I have to manually rerun the “save to file” or “show preview” commands in vscode.

Is there a server which watches the file and recompiles the changed document?  
Maybe even using some caching.

At the moment it seems like vscode is starting a new julia session to rerun the weave commands.  
The reason I think this happens is that is takes always a lot of time when running the chunks containing Plots.jl etc

---

<div class="post-metadata">

**Author:** ![feanor12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/feanor12/32/8212_2.png) [@feanor12](https://discourse.julialang.org/u/feanor12)\
**Post date:** [May 30, 2020, 12:26pm UTC](https://discourse.julialang.org/t/is-there-a-weave-live-preview-server/40466/2 "2020-05-30T12:26:44Z")

</div>

I wrote a crude script to watch for save events to trigger a recompile of the document.  
Maybe it is helpful for someone.

To view the generated document I use the Liveserver extension in vscode.

```julia
using Weave
using FileWatching

while true 
    jmdfilepth = normpath("mydoc.jmd")
    status = watch_file(jmdfilepth)
    outpath = "out"
    if status.changed
        @info "change detected"
        weave(jmdfilepth, doctype="md2html", out_path= "out",cache=:none,fig_path="fig")
        for folder in filter((x)->startswith(x,"jl_"),readdir(outpath))
            tmpdir = joinpath(outpath,folder)
            @info "delete $tmpdir"
            rm(tmpdir,recursive=true)
        end
    end
    sleep(1)
end

```

---

<div class="post-metadata">

**Author:** ![Markus\_Hauschel](https://avatars.discourse-cdn.com/v4/letter/m/7ba0ec/32.png) [@Markus\_Hauschel](https://discourse.julialang.org/u/Markus_Hauschel)\
**Post date:** [May 30, 2020, 9:52pm UTC](https://discourse.julialang.org/t/is-there-a-weave-live-preview-server/40466/3 "2020-05-30T21:52:27Z")

</div>

This might be helpful [Livereload with Weave.jl](https://discourse.julialang.org/t/livereload-with-weave-jl/36750)

Unfortunately I didn’t have time to have a look at it, since I focus on two projects in R right now, but it looks promising!
