Apr 18, 2026 5.4 KB octet-stream
{
  "nbformat": 4,
  "nbformat_minor": 5,
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "name": "python",
      "version": "3.12.0"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Mixed Output Types\n",
        "\n",
        "Testing all output types: text, HTML, images (base64), SVG, and errors."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "execution_count": 1,
      "source": [
        "# stream output — multiple prints\n",
        "for i in range(5):\n",
        "    print(f\"Step {i + 1}: processing...\")\n",
        "print(\"Done!\")"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Step 1: processing...\n",
            "Step 2: processing...\n",
            "Step 3: processing...\n",
            "Step 4: processing...\n",
            "Step 5: processing...\n",
            "Done!\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## SVG Output\n",
        "\n",
        "Inline SVG rendering (like matplotlib with SVG backend):"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "execution_count": 2,
      "source": [
        "from IPython.display import SVG, display\n",
        "\n",
        "svg = '''<svg width=\"300\" height=\"200\" xmlns=\"http://www.w3.org/2000/svg\">\n",
        "  <rect x=\"10\" y=\"10\" width=\"80\" height=\"180\" fill=\"#4CAF50\" rx=\"4\"/>\n",
        "  <rect x=\"110\" y=\"60\" width=\"80\" height=\"130\" fill=\"#2196F3\" rx=\"4\"/>\n",
        "  <rect x=\"210\" y=\"100\" width=\"80\" height=\"90\" fill=\"#FF9800\" rx=\"4\"/>\n",
        "  <text x=\"50\" y=\"205\" text-anchor=\"middle\" font-size=\"12\">A</text>\n",
        "  <text x=\"150\" y=\"205\" text-anchor=\"middle\" font-size=\"12\">B</text>\n",
        "  <text x=\"250\" y=\"205\" text-anchor=\"middle\" font-size=\"12\">C</text>\n",
        "</svg>'''\n",
        "display(SVG(svg))"
      ],
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "image/svg+xml": "<svg width=\"300\" height=\"200\" xmlns=\"http://www.w3.org/2000/svg\">\n  <rect x=\"10\" y=\"10\" width=\"80\" height=\"180\" fill=\"#4CAF50\" rx=\"4\"/>\n  <rect x=\"110\" y=\"60\" width=\"80\" height=\"130\" fill=\"#2196F3\" rx=\"4\"/>\n  <rect x=\"210\" y=\"100\" width=\"80\" height=\"90\" fill=\"#FF9800\" rx=\"4\"/>\n  <text x=\"50\" y=\"205\" text-anchor=\"middle\" font-size=\"12\">A</text>\n  <text x=\"150\" y=\"205\" text-anchor=\"middle\" font-size=\"12\">B</text>\n  <text x=\"250\" y=\"205\" text-anchor=\"middle\" font-size=\"12\">C</text>\n</svg>",
            "text/plain": "<IPython.core.display.SVG object>"
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Rich HTML Output\n",
        "\n",
        "Custom HTML via `display(HTML(...))`:"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "execution_count": 3,
      "source": [
        "from IPython.display import HTML\n",
        "\n",
        "HTML('''\n",
        "<div style=\"padding: 16px; border: 1px solid #ddd; border-radius: 8px; max-width: 400px;\">\n",
        "  <h3 style=\"margin: 0 0 8px 0;\">System Status</h3>\n",
        "  <table style=\"width: 100%; border-collapse: collapse;\">\n",
        "    <tr><td>CPU</td><td style=\"text-align: right; color: green;\">12%</td></tr>\n",
        "    <tr><td>Memory</td><td style=\"text-align: right; color: orange;\">67%</td></tr>\n",
        "    <tr><td>Disk</td><td style=\"text-align: right; color: green;\">34%</td></tr>\n",
        "    <tr><td>Network</td><td style=\"text-align: right; color: green;\">2.4 Mbps</td></tr>\n",
        "  </table>\n",
        "</div>\n",
        "''')"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 3,
          "data": {
            "text/html": "\n<div style=\"padding: 16px; border: 1px solid #ddd; border-radius: 8px; max-width: 400px;\">\n  <h3 style=\"margin: 0 0 8px 0;\">System Status</h3>\n  <table style=\"width: 100%; border-collapse: collapse;\">\n    <tr><td>CPU</td><td style=\"text-align: right; color: green;\">12%</td></tr>\n    <tr><td>Memory</td><td style=\"text-align: right; color: orange;\">67%</td></tr>\n    <tr><td>Disk</td><td style=\"text-align: right; color: green;\">34%</td></tr>\n    <tr><td>Network</td><td style=\"text-align: right; color: green;\">2.4 Mbps</td></tr>\n  </table>\n</div>\n",
            "text/plain": "<IPython.core.display.HTML object>"
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Empty Cell\n",
        "\n",
        "An unexecuted code cell:"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "execution_count": null,
      "source": [
        "# TODO: implement this later"
      ],
      "outputs": []
    },
    {
      "cell_type": "raw",
      "metadata": {},
      "source": [
        "This is a raw cell.\n",
        "It is rendered as plain text without any formatting.\n",
        "Useful for LaTeX or other markup that shouldn't be processed."
      ]
    }
  ]
}