gopherdata / gophernotes

The Go kernel for Jupyter notebooks and nteract.
MIT License
3.8k stars 264 forks source link

use auto-rendering interfaces, as decided in #166 #169

Closed cosmos72 closed 5 years ago

cosmos72 commented 5 years ago

TODO: keep []xreflect.Type returned by eval(), to preserve interpreted methods

SpencerPark commented 5 years ago

@cosmos72 thanks this is working great! The display example notebook is looking really cool!

I took this PR for a test drive and everything ran smoothly (implementing the interfaces in within the notebook also worked well!) but one thing I noticed is that defining multiple render implementations results in only one being selected.

For example I would expect the following to display both text.html and text/latex:

type H struct {
}
func (h H) HTML() string {
    return `<h2 style="color:blue;">Hello again, world!</h2>`
}
func (h H) Latex() string {
    return `$Hello again, world!$`
}
H{}

It is up to the frontend to decide which it prefers to display.

cosmos72 commented 5 years ago

True, I did not think about it. Added in a079f39dab6cf77239c38301b6ffc3c5a65a4b58