-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nbShow for images and tables #74
Comments
So it would only work for types that are officially supported by nimib? I don't have full understanding of how this works, but wouldn't something like this perhaps work? template nbShow(t: untyped) =
t.nbShowApi(nbDoc)
proc nbShowApi(m: MyCustomType, nb: NbDoc) =
# Logic here All types which implement |
Still too early for me to understand how it will be for a custom type, but there will be some mechanism like the one you suggest to make this something that any custom type can implement. I do think though that for each nbShow there might be custom parameters (e.g. max rows and max columns for a table, caption for a plot, ...). |
That's a very good point! Didn't think about that. |
have been thinking about how this could be implemented, here I describe a possible implementation:
nb.partials["nbCode"]= """
{{>nbCodeSource}}
{{>nbCodeOutput}}
{{>nbCodeHtmlOutputs}}
"""
nb.partials["nbCodeHtmlOutputs"]= """
{{#htmls}}{{.}}{{/htmls}}
"""
what is nice about the above is that for every new type you just need to add a Note that in the above we assume that all html outputs produced by |
This API looks really clean, I really like the |
ah yes, all names are up for changes:
|
Here are my 10 cent:
|
Inflation really is ramping up 😜
|
🤣 That's what I get when I don't know your idioms properly...
|
I have thought a bit about this now. Why must template nbShow(obj: untyped) =
nbRawHtml(obj.toHtml()) Thought on this? Am I missing something we thought was brilliant with your approach back in October? |
Well, this might just be more brilliant :) This is rather straightforward indeed. The idea I had back then was to be able to use it inside nbCode so that you could show how you are calling it but indeed it is not very important (and maybe this actually works inside nbCode - the only issue would be that you cannot anymore change nbCode as last block - for example calling nbClearOutput) |
I don't think it works to create other blocks inside |
And to recap nbCode vs niminCode: #nbCode
newBlock(....)
capturestdOut:
body
#nimibCode
newBlock(....): # just read the code here, don't run it
discard
body # we run it afterwards instead Looking at this I think we could make nimibCode captureStdout if we just save a reference to the newly created block and add the output to it. :o If I could get it to work, maybe we could change nbCode to use this and deprecate nimibCode as it could handle nesting now? 🤔 |
Well, with support for container blocks (and allowing every block to be a container block) I think we should be able to call blocks from inside other blocks. |
the ref issue for container blocks is #117 and if they support also this use case we should actually make any block a container block |
That's a good point, all the contained blocks of a nbCode could be placed where you put the |
ah the part of the partial I had not yet thought about it... to be honest it is late and I am really tired so there are many things that I might not have considered, but making blocks also container blocks is something that looks more and more appealing! |
Haha yeah it's a shame that one has the most time when you should sleep and is tired 🤣 |
we should have a dedicated command nbShow whose behaviour will depend on the type of object is applied.
For example:
this should be in some nimib/show module that should uses
when compiles(import ggplotnim)
or similar mechanism not to introduce additional dependencies.I plan to do this after #24 (hopefully I will start soon working on that, likely starting from scratch)
The text was updated successfully, but these errors were encountered: