Hi all, I realized I never did officially announce the library 
🐳[nimib](https://github.com/pietroppeter/nimib) on the forum (although I did 
mention it multiple times since its 
[beginning](https://github.com/pietroppeter/nimib/blob/main/changelog.md#01-march-2021)
 in November 2020).

Three weeks ago, we (me and @hugogranstrom) released a version 0.3 (codenamed 
BlockMaker) which reaches a big milestone in my vision for nimib, so I think 
this calls for a little celebration and a post on the forum.

First a brief introduction for those who have never heard of Nimib. It is a 
template based DSL that allows to transform nim code in a html document. The 
basic structure of a nim file using Nimib is as follows:
    
    
    import nimib
    
    nbInit # always needed to start a document
    
    nbText: """# a title
    put **markdown** text and it will be translated to html"""
    
    nbCode:  # code in a nbCode block is executed and output captured and 
rendered
      let x = "hello"
      echo x
    
    # there are other blocks you can use
    nbImage: ...
    
    ...
    
    nbSave # with this block at the end Nimib will create a html document with 
the contents of all processed blocks
    
    
    Run

there are various examples in Nimib site linked above, and I started to collect 
random stuff in a blog (still in draft mode). A simple but nice example I did 
today is a plot of a function that looks like a plant: 
<https://pietroppeter.github.io/nblog/drafts/trigonometric_plant.html>

One of the feature I like the most of Nimib's default theme is the fact that in 
bottom right you have a **Show source** button that shows you the source used 
to produce the document. If you copy and paste that code in a `example.nim` 
file and run `nim r example --nbShow` you will see that a `example.html` file 
will be created and the browser will open to show it (this last thing thanks to 
`--nbShow` option).

So _what is new in this 0.3 release_? there are detailed [release 
notes](https://github.com/pietroppeter/nimib/releases/tag/v0.3.0) but the big 
milestone is the fact that Nimib is now able to easily produce **interactive** 
documents thanks to Nim's js backend. Basically we added a block that takes 
code, compiles it to javascript and writes the result in the html file. You can 
read more about how this works in [this 
document](https://pietroppeter.github.io/nimib/interactivity.html) and you can 
watch another example I just produced (a [bouncing 
ball](https://pietroppeter.github.io/nblog/drafts/bouncing_ball_p5js.html)).

On top of that, we added a special template `nbKarax` to be able to reduce a 
little the boilerplate needed in order to create a Karax app. An example of 
this is this simple [caesar](https://pietroppeter.github.io/nimib/caesar.html) 
app that implements [caesar's 
cipher](https://en.wikipedia.org/wiki/Caesar_cipher). Click show source to see 
the code and you can try to run it as mentioned above (you will need to install 
Nimib and Karax).

The above has been possible by a refactoring on the internal api and how the 
document is rendered. The result is that now is rather easy to create custom 
blocks for Nimib. Examples of this are:

  * how to build a custom block to add [diagrams using 
mermaid.js](https://pietroppeter.github.io/nblog/drafts/mermaid_diagram.html)
  * how to build a custom block to show [plotly's plot in 
nimib](https://pietroppeter.github.io/nblog/drafts/show_plotly.html)
  * how to build a custom block to create a [before/after image 
slider](https://pietroppeter.github.io/nblog/drafts/before_after_image_slider.html)



Among other improvements, documents are now built automatically in CI and there 
is a preview generated when you open a PR. This should make contributing (and 
managing contributions) much easier. We also plan to use more the [integrated 
github's forum](https://github.com/pietroppeter/nimib/discussions) to discuss 
and share stuff, so feel free to say hi there!

Last but not least, as I mentioned in the beginning, @hugogranstrom is joining 
me as maintainer of this library. Indeed, many (most) of the changes in this 
release are thanks to him. Thanks a lot Hugo ❤️ and welcome to the team 🥳!

ps: what will be next? there might be another announcement soon, and there is 
already a plan for what will be the next major breakage (a refactor of the 
rendering backend that should allow to easily add other backend). The idea for 
now is to have this release to settle, which means to fix stuff around, there 
are a ton of small improvements that can be made (contributions welcome!), but 
more than that: produce content with nimib. My personal number one priority 
though is to try and build a simple Static Site generator (similar to Jekyll, 
Hugo, ...) that will simplify the building of more complex sites. In particular 
I sorely need to have a decent theme for the nblog which I linked multiple 
times above. 

Reply via email to