nimib icon indicating copy to clipboard operation
nimib copied to clipboard

small addition: possibility to customize the output block

Open Yardanico opened this issue 3 years ago • 4 comments

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.

Yardanico avatar Mar 08 '21 10:03 Yardanico

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.

pietroppeter avatar Mar 08 '21 11:03 pietroppeter

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.

ajusa avatar Mar 24 '21 13:03 ajusa

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 avatar Mar 24 '21 16:03 pietroppeter

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.

pietroppeter avatar Jul 02 '22 17:07 pietroppeter