Skip to content
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

Custom html/css? #40

Closed
holyjak opened this issue Aug 11, 2015 · 7 comments
Closed

Custom html/css? #40

holyjak opened this issue Aug 11, 2015 · 7 comments

Comments

@holyjak
Copy link

holyjak commented Aug 11, 2015

I am new to Jupyter notebooks and cannot figure out how to include custom HTML in a notebook. Namely I would like to add some CSS styles to use later on (I am successfully using ijavascript with RISE to create live slide shows and want to center things etc.).

I can google out some solutions but they apply to ipython (relying on executing python code). Some suggest using <style> in a markdown cell but that doesn't seem to work for me.

Could you please extend the documentation with tips in this regard?

Thanks a lot!

@n-riesco
Copy link
Owner

To help me understand, please, could you give me an example of what you're trying to do?

Have you seen this documentation? It includes an example to inject HTML into an output cell.

@n-riesco
Copy link
Owner

Not sure whether this may help you: a kernel spec may include custom.css and custom.js. See IPEP25.

@holyjak
Copy link
Author

holyjak commented Aug 12, 2015

Thanks for the quick response!

I don't know how it is possible but I have overlooked the documentation. I guess the $$html$$ could perhaps work though CSS styles should be inside <head>, which this doesn't enable.

What I am trying to achieve: I have this notebook that I use with RISE to produce live presentation slides. I would like to center the 2nd line, i.e. "Jakub Holý - Iterate conference 8/2015". So I want to have either

.my-centered { text-align: center }

// And later, on the slide/cell:
<p class="my-centered">Jakub Holý - Iterate conference 8/2015</p>

(using a class rather then style so that I can use it on multiple elements) or just this

.text_cell_render p  { text-align: center }

The question is where to put it.

Regarding custom.(css|js), I think those would only be useful if they could be in the notebook directory, i.e. for that notebook, not all.

Thank you!

@n-riesco
Copy link
Owner

This should do the trick using IJavascript:

$$html$$ = '<script>document.styleSheets[0].insertRule(".rendered_html .my-centered { text-align: center; }", 0);</script>';

But I would also ask this question on the Jupyter mailing list. There may be a recommended way to add a custom.css to a notebook.

@n-riesco
Copy link
Owner

This message from the mailing list may be relevant:

https://groups.google.com/d/msg/jupyter/Hak-Xjwro3k/_NznabngCwAJ

@n-riesco
Copy link
Owner

@jakubholynet I'm closing this issue. If the comments above don't help, please, feel free to reopen this issue.

@holyjak
Copy link
Author

holyjak commented Aug 19, 2015

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants