pietroppeter / nimib

nimib 🐳 - nim 👑 driven ⛵ publishing ✍
https://pietroppeter.github.io/nimib/
MIT License
176 stars 10 forks source link

small addition: possibility to customize the output block #13

Open ghost opened 3 years ago

ghost commented 3 years ago

Right now the output of running Nim code is just pasted as normal code. It would be nice to be able to customize it - e.g. add a prefix like "Output:" or add some custom CSS styling.

pietroppeter commented 3 years ago

currently possible adding after nbCode:

nbBlock.output = "Output: " & nbBlock.output

If you need to use it more than occasionally, you can make your custom block (to be added or included after nbInit):

template nbMyCode(body: untyped) =
  nbCode(body)
  nbBlock.output = "Output: " & nbBlock.output

Also very possible to do it with custom css (using mustache partials or a fully custom template).

Keeping this open until I add this as example of customization somewhere in the documentation.

ajusa commented 3 years ago

One thing that might be cool to have (by default) is support for colored text that is printed with terminal escape codes. I had to disable colored printing in my code so that all the escape sequences didn't show up in the output tab, but it might be nice to have a transformation that would apply styles to the output using the same color scheme as the syntax highlighting.

pietroppeter commented 3 years ago

yes, it could be something nice to have. In the meantime I have some example of color printing in https://pietroppeter.github.io/nimib/ptest.html (look in the source for spanColor)

pietroppeter commented 2 years ago

the possibility of customizing code output has been greatly improved with 0.3. Now one would change the partial of nbCode and it would automatically be applied to all code blocks. Still have to document this.