Closed vishwesh5 closed 5 years ago
I guess you could create your own HTML class, a bit like in the Notebook example with the image class: https://github.com/QuantStack/xeus-cling/blob/master/notebooks/xcpp.ipynb
struct html
{
inline html(const std::string& value)
{
m_value = value;
}
std::string m_value;
};
xeus::xjson mime_bundle_repr(const html& h)
{
auto bundle = xeus::xjson::object();
bundle["text/html"] = h.m_value;
return bundle;
}
That could be a first option. Another option could be to use https://github.com/QuantStack/xwidgets, it has an html
widget class (https://github.com/QuantStack/xwidgets/blob/master/include/xwidgets/xhtml.hpp). That would be a more "interactive" option, because you can update the HTML value dynamically from C++ and the visual output will update itself automatically.
Thanks @martinRenou ! By any chance, is there an example for xhtml?
Yes! In this Notebook: https://github.com/QuantStack/xwidgets/blob/master/notebooks/xwidgets.ipynb if you look for HTML on the page you will see it
This worked!
Thanks a lot!
One final question. In the image, I had to write the entire html styling code. Is it possible to load it from a file? My plan is to maintain a central styling file which can be loaded by all the c++ notebooks.
Maybe look for ways to load a file into an std::string
, something like https://stackoverflow.com/questions/2602013/read-whole-ascii-file-into-c-stdstring
Thanks for the reference! I was able to load the html style in a string buffer.str()
Then I did this:
Am I missing something? I am pretty sure I am
I am not sure xhtml(
at the beginning and )xhtml
at the end are needed, can you try removing them?
You are amazing! It worked!
Thanks a lot for your help!
Ahah, happy to help :) I'm closing this. Don't hesitate to ask other questions though.
Does xw::html
work for css and html only? It doesn't seem to run javascript although my notebook is trusted
Hi everyone
Is it possible to load HTML styling in a Xeus Cling kernel notebook? For example, I am doing something like this in python:
Is there a Xeus Cling equivalent for this? Or is there a word around?
Thanks in advance
Vishwesh