Execute code in Julia Markdown in VS code

For a Julia file, I can execute code with Alt+Enter. Is there a similar way, to do the same in a Markdown?

1 Like

Are you asking if there’s a way to view the rendered markdown in VS Code? If so, there are numerous markdown extensions for VS Code. The one I use is called Markdown Preview Enhanced by Yiyi Wang (1.2 million+ downloads).

Thanks, I have Weave, and it has a preview, that looks exactly like it should, except that doesn’t have any outputs or plots. I was hoping to have Jupyter, so I could do things in more real time. I know there are ways to do that, which involve istalling Python add ons to VSCode.

Have you used Pluto.jl? You can enter markdown into the cells and it’s much easier to learn than Jupyter. I haven’t written a Jupyter notebook since Pluto launched…

1 Like

I never heard of it. Just installing it now, and will check the documentation. Do I have to do anything with VS Code?

It has nothing to do with VS code.

I agree the documentation is lacking for Julia with VS Code at the moment. But I’m pretty sure this is possible in VS code. Hopefully someone else can comment and give more insight.

Ok, thanks, it looks good online, and I can save i all there, the only thing is that I can’t bring over the work I have already done on a Julia Markdown (I tried and it gives an error). I can redo stuff, but it would be nice to have a way to save a markdown, as a Pluto notebook.

I got that sorted, it turns out I can save a pluto notebook in pluto, which is good, unless I want to do stuff in VS Code, I found a way to export an HTML, and PDF, but not LaTex. Is there at least a way to enter formulas in LaTex?

You can write math in your markdown blocks in pluto, see the example here.

For reference, latex is a way to compile pdfs, not a format you would export something to. I don’t think pluto uses latex to make the pdfs though.

1 Like

That could be handy, I still can’t get Julia or LaTex to execute code in VS studio, nor as a pdf (no output, no plots, and equations aren’t formatted)

Why not just use the weave function in the julia repl?

Do you mean to create a pdf?

To create a pdf from a markdown file, with plots and stuff included, yes.

I used the drop down menu in VS Code, that got the LaTex to work, but none of the plots, nor output of any of the functions in Julia equations.

Do you know how to use the repl to weave a document? It’s described here

I used it before so I should, I didn’t think it would matter, hold on.

I tried

weave(“Assignment6testing.jmd”, out_path=“C:/Users/Documents/Test/REPL”, doctype=“md2pdf”)

and I get an error, that no file or directory as Assignment6testing.jmd exists, even though I just saved my document as that.

can you use full path for that file since your Julia may started somewhere else

1 Like

It uses the editing language I think, but I’ll have to look into more of the specifics. there are different applications that used the language MS Word uses it for equations in Word Documents. It seems that PLUTO and Julia Markdown both execute LaTex code, and that Weave interprets it in pdfs. The problem I’m having is that a pdf made from a .jl or a .jmd file, does not have plots, nor outputs.

Also, I’m now having code give an error

julia> weave("C:/Users/Brett/Documents/Test/Assignment6.jl", out_path = "C:/Users/Brett/Documents/Test/REPLl", doctype = "md2pdf")
[ Info: Weaving chunk 1 from line 1
ERROR: Base.Meta.ParseError("extra token \"and\" after end of expression")

You have an unrelated error in your code. I would encourage you to try an example file that is very small. Save the following as test.jmd and then use the weave command with it.

# This is my document

This is some text

```julia
x = 1
print(x)
```

It’s very hard to help without more information. Additionally, I would encourage you to try harder to recognize when the error you encounter has to do with the problem you are trying to solve, and when it is an unrelated error due to a typo in your code.

4 Likes