diff --git a/HowTos/EmbedExternalResources/EmbedExternalResources.ipynb b/HowTos/EmbedExternalResources/EmbedExternalResources.ipynb index e79744a..e45d681 100644 --- a/HowTos/EmbedExternalResources/EmbedExternalResources.ipynb +++ b/HowTos/EmbedExternalResources/EmbedExternalResources.ipynb @@ -1,460 +1,479 @@ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Embed external resources in your notebook\n", "\n", "**What are external resources?**\n", "\n", "External resources are content/resources (videos, images, etc.) that are hosted on services other than Noto.\n", "\n", "**What is embeding?**\n", "\n", "Embeding is making this external content available from your notebooks, only by providing a reference (a URL, a Youtube video id, data). The external content does not need to be copied into the notebook or your repository.\n", "\n", "Note that, **in some cases**, the external content will be stored in the output cell of your notebook." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Introduction\n", "\n", - "In this section, we will demonstrate how to embed most commom contents in your notebooks ; most of these examples come from [this](http://louistiao.me/posts/demos/ipython-notebook-demo/) page.\n", + "In this section, we will demonstrate how to embed most commom contents in your notebooks using Python ; most of these examples come from [this](http://louistiao.me/posts/demos/ipython-notebook-demo/) page.\n", "\n", "## IPython's Rich Display System\n", "\n", "To render external content, we will use IPython (the library at the base of Jupyter kernels). In Python, objects can declare their textual representation using the `__repr__` method. IPython expands on this idea and allows objects to declare other, richer representations including:\n", "\n", "* HTML\n", "* JSON\n", "* PNG\n", "* JPEG\n", "* SVG\n", "* $\\LaTeX$\n", "\n", "A single object can declare some or all of these representations; all are handled by IPython's display system. This Notebook shows how you can use this display system to incorporate a broad range of content into your Notebooks.\n", "\n", "# About the `display()` function\n", "The `display()` function is a general purpose tool for displaying different representations of objects. Think of it as a `print()` fonction for these rich representations." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from IPython.display import display" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A few points:\n", "\n", "* Calling `display()` on an object will send all possible representations to the Notebook.\n", "* These representations are stored in the Notebook document (as part of the output cells).\n", "* In general the Notebook will use the **richest** available representation.\n", "\n", "If you want to display a particular representation, there are specific functions for that:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from IPython.display import display_pretty, display_html, display_jpeg, display_png, display_json, display_latex, display_svg, display_pdf" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Examples\n", "\n", "Each example is self sufficient; you can just copy and reuse the content of each cell.\n", "\n", "## Videos\n", "\n", - "Embedding a remote video looks like that:" + "Embedding a remote video using Python code looks like that:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from IPython.display import Video\n", "Video('http://www.html5videoplayer.net/videos/toystory.mp4')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And this is a YouTube video, embedded via its video ID (`'IPrU6VsLl8c'`)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from IPython.display import YouTubeVideo\n", "YouTubeVideo('IPrU6VsLl8c', 600, 337)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Of course, videos can also be embedded into Markdown cells using the HTML 5 tag: `