Formatting code examples in text with Franklin.jl

This looks great! What system are you using to write it, if you don’t mind my asking? I like the tabbed code bars in particular, that’s a rather clear way to illustrate small differences in example code.

I’m using Franklin. It’s highly customizable, so you can create your own templates for the website. What’s more, you can integrate it with Julia, so that you can write Julia code and the output in REPL will be exported automatically to the website.

It took me a lot of time and I’m still automatizing some parts and fixing bugs. It was the first time I created a website! so only know the basics of HTML/CSS/JS.

For the tabs in particular, I use a macro in VS code to call the basic structure of the code. It looks like this

This code calls functions using Franklin (e.g., \hidetabs{open}{}) to add the layout you specified, whether the tab should be opened automatically, etc. Then, I define functions like \Mcode, \out, etc. to call the code chunk and its corresponding output directly. I still need to polish it, but the idea is that you write Julia code as you’d normally do and add some keyword like ###region1###. Then, you can extract that part of the code, run it, and create a text file with the output.

1 Like

Have you found a way of integrate the output of PrettyTables? That is, to make Franklin plot PrettyTables?

If I remember well, I had found a way but it was too cumbersome and not easy to be automotized. I was using the idea of exporting a prettytable as html, based on this Franklin’s demos.

The workaround I use is to transform tables into dataframes and then export their REPL output. For example,

But, yeah, it’s not ideal. I guess I’ll revisit this if I write a section on data analysis.

I love the colours here. I would suggest making the font one or two points larger please.
The font itself is great - very legible. Just a tad small for me.

have you tried to zoom in? I was torn about it because increasing the font was causing some issues on 13 inches laptops (e.g., Dell XPS). In the end, I tried to keep it flexible by just allowing people to zoom in and out, which I made sure wasn’t breaking anything.