Blogging with Julia code blocks

question
web

#21

Thanks @dpsanders, I am working on an extension example for my research, hopefully it will work out well :slight_smile:

@ChrisRackauckas has made a very good connection in the comments, feel free to add another comment if you have an extension in mind, always good to learn new interesting stuff! Appreciate your feedback.


#22

I just meant to show how to use exponential random variables in continuous time. At least the version I saw didn’t have a code example for that.


#23

Got it, I thought it would pollute the grand finale, I prefer to leave the mystery :slight_smile:


#24

Thanks @ChrisRackauckas, submitted the feed to juliabloggers.com just now.


#25

@juliohm I would use the methods suggested by @Tamas_Papp above to work with Jekyll. It does mean you need come up with a separate Makefile for jmds so it’s not ideal.

Also it doesn’t look too hard to write your own Converter for Jekyll https://jekyllrb.com/docs/plugins/#converters. You could e.g. write out the content to a temp file, run weave and read the converted contents back to Jekyll.


#26

Given that the weaving is the most costly step, and woven files tend to be static after that, I prefer to keep it manual.


#27

@mpastell, my main concern with writing a converter is that it will rely on Weave.jl and won’t build on GitHub pages, correct?


#28

Correct. You’d need to run Jekyll locally and commit the build.


#29

No, it is not. It just has stuffed a lot of dust under the rug

Also, not that.
Output (and everything else) is generated in any post tagged jupyer-notebook.

My solution is actually pretty convoluted and gross,
is kind of a variation on what @ChrisRackauckas does,
to generate blog posts from Jupyter Notebooks.
I uses the script that is in https://github.com/oxinabox/oxinabox.github.io/tree/master/scripts/jupyter to generate the posts.
It uses a custom nbconverter config, including a custom template (in nbconvert fashion using Jinja2).

I can no longer recall the difference between defining your own nbconverted config+template,
and defining your own converter for notebook-> jekyll

This then generates the Jekyll posts, which include the liquid templating for Highlighting.
I hoped that I could get Kramdown to do the highlighting which would have made:

 ```julia
 #code here
blocks work.

But I could not, so I had to use the [Jekyll/Liquid way](https://jekyllrb.com/docs/templates/#code-snippet-highlighting), with the 

{% highlight julia %}
#code here
{% endhighlight %}


Which I think is worse.


The truely painful stuff was not in getting highlighting to work, it was in getting the Images in the output working.
I learnt a new level of hatred for nbconvert and jekyll that day.

#30

@oxinabox so Jekyll and Julia will never play well? What should we do about this issue?


#31

What’s the problem with running Weave locally and pushing generated markdown to gh pages? I could add a Jekyll formatter to use {% highlight julia %} for code and correct figure paths for output.

I don’t use Jekyll myself so I’d appreciate if you opened an issue of whats missing.


#32

juliohm
@oxinabox so Jekyll and Julia will never play well? What should we do about this issue?

Problem is, I am concluding, jekyll is just not a great platform.
And nor is Jupyter.
They are both merely better than other things for various reasons.
You can make them both work,
but nothing is loverly about doing.
Merely, possible.

mpastell
What’s the problem with running Weave locally and pushing generated markdown to gh pages?

I see nothing wrong with this plan.


#33

@mpastell could you please elaborate on how this is done with a simple example?


#34

I set a simple example repo that should get you started, see: https://github.com/mpastell/weave-ghpages-sample . Let me know if something is not clear.


#35

Thank you @mpastell, that is awesome, I will look into the repo for future posts, just released a new one where I copy the Julia output manually again:


#36

Update: Weave.jl now works with Hugo (thanks @mpastell!) This blog post has links to the source of my blog if someone wants to implement this setup.


#37

I’m a bit late to this party, but I’m currently using http://prismjs.com/ which can be used in a bunch of different platforms.