{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>/*\n",
       " * Override Jupyter's default css inside elements with the hrepr class.\n",
       " */\n",
       "\n",
       ".rendered_html .hrepr table {\n",
       "\tmargin-top: 0px;\n",
       "\tmargin-bottom: 0px;\n",
       "\ttable-layout: auto;\n",
       "}\n",
       "\n",
       ".rendered_html tr, .rendered_html th, .rendered_html td {\n",
       "\tpadding: 2px;\n",
       "\ttext-align: left;\n",
       "}\n",
       "</style><style>\n",
       ":root, :host {\n",
       "\t--instance-color: #00a;\n",
       "\t--dict-color: #00a;\n",
       "\t--tuple-color: #080;\n",
       "\t--list-color: #080;\n",
       "\t--set-color: #080;\n",
       "\t--frozenset-color: #88f;\n",
       "\t--error-color: #f00;\n",
       "\t--struct-border: 2px;\n",
       "}\n",
       "\n",
       "/* Scalar/string formatting */\n",
       "\n",
       ".hreprv-True, .hreprv-False, .hreprv-None, .hreprt-int, .hreprt-float {\n",
       "\tfont-weight: bold;\n",
       "}\n",
       "\n",
       ".hreprt-int, .hreprt-float {\n",
       "\tcolor: #88f;\n",
       "}\n",
       "\n",
       ".hreprt-str {\n",
       "\tcolor: #666;\n",
       "\twhite-space: pre-wrap;\n",
       "}\n",
       "\n",
       ".hreprt-str:before {\n",
       "\tcontent: \"“\";\n",
       "\tcolor: #888;\n",
       "}\n",
       "\n",
       ".hreprt-str:after {\n",
       "\tcontent: \"”\";\n",
       "\tcolor: #888;\n",
       "}\n",
       "\n",
       ".hreprt-bytes {\n",
       "\tcolor: #666;\n",
       "\tfont-family: monospace;\n",
       "\twhite-space: pre-wrap;\n",
       "}\n",
       "\n",
       ".hreprt-bytes:before {\n",
       "\tcontent: \"b“\";\n",
       "}\n",
       "\n",
       ".hreprt-bytes:after {\n",
       "\tcontent: \"”\";\n",
       "}\n",
       "\n",
       ".hreprv-True {\n",
       "\tcolor: green;\n",
       "}\n",
       "\n",
       ".hreprv-False {\n",
       "\tcolor: red;\n",
       "}\n",
       "\n",
       ".hreprv-None {\n",
       "\tcolor: grey;\n",
       "}\n",
       "\n",
       ".hreprk-class > .hrepr-defn-key {\n",
       "\tcolor: blue;\n",
       "}\n",
       "\n",
       ".hreprk-module > .hrepr-defn-key {\n",
       "\tcolor: purple;\n",
       "}\n",
       "\n",
       ".hreprk-function > .hrepr-defn-key,\n",
       ".hreprk-builtin > .hrepr-defn-key,\n",
       ".hreprk-method > .hrepr-defn-key,\n",
       ".hreprk-descriptor > .hrepr-defn-key {\n",
       "\tcolor: #080;\n",
       "}\n",
       "\n",
       ".hrepr-defn-key {\n",
       "\tfont-weight: bold;\n",
       "}\n",
       "\n",
       "\n",
       "/* Generic layouts */\n",
       "\n",
       ".hreprl-h, .hreprl-s {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: row;\n",
       "\tflex-wrap: wrap;\n",
       "}\n",
       "\n",
       ".hreprl-v {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: column;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h,\n",
       ".hrepr-body.hreprl-v {\n",
       "\tgap: 4px;\n",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h {\n",
       "\talign-items: center;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-v > *,\n",
       ".hrepr-body.hreprl-h > * {\n",
       "\tbackground: white;\n",
       "\tdisplay: inline-flex;\n",
       "\tplace-items: center;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h > div > .hrepr-ellipsis,\n",
       ".hrepr-body.hreprl-v > div > .hrepr-ellipsis {\n",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h > div > .hrepr-ellipsis {\n",
       "\tpadding-left: 5px;\n",
       "\tpadding-right: 5px;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-v > div > .hrepr-ellipsis {\n",
       "\tpadding-top: 5px;\n",
       "\tpadding-bottom: 5px;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-s > * {\n",
       "\tpadding: 1px;\n",
       "}\n",
       "\n",
       ".hrepr-bracketed {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: row;\n",
       "\tplace-items: center;\n",
       "\tbackground: black;\n",
       "\tborder: var(--struct-border) solid black;\n",
       "\tbox-sizing: border-box;\n",
       "}\n",
       "\n",
       ".hrepr-bracketed > .hrepr-open {\n",
       "\tpadding-right: var(--struct-border);\n",
       "}\n",
       ".hrepr-bracketed > .hrepr-close {\n",
       "\tpadding-left: var(--struct-border);\n",
       "}\n",
       ".hrepr-bracketed > .hrepr-open,\n",
       ".hrepr-bracketed > .hrepr-close,\n",
       ".hrepr-instance > .hrepr-title,\n",
       ".hreprl-s {\n",
       "\tcolor: white;\n",
       "\tfont-weight: bold;\n",
       "}\n",
       "\n",
       ".hrepr-instance {\n",
       "\tbackground: var(--instance-color);\n",
       "\tborder: var(--struct-border) solid var(--instance-color);\n",
       "\tbox-sizing: border-box;\n",
       "}\n",
       ".hrepr-instance > .hrepr-title {\n",
       "\tcolor: white;\n",
       "\tfont-weight: bold;\n",
       "}\n",
       ".hrepr-instance.hreprl-v > .hrepr-title {\n",
       "\tpadding-bottom: var(--struct-border);\n",
       "}\n",
       ".hrepr-instance.hreprl-h > .hrepr-title,\n",
       ".hrepr-instance.hreprl-s > .hrepr-title {\n",
       "\tpadding-right: var(--struct-border);\n",
       "\tplace-self: center;\n",
       "}\n",
       ".hrepr-instance.hrepr-error {\n",
       "\tbackground: var(--error-color);\n",
       "\tborder: var(--struct-border) solid var(--error-color);\n",
       "}\n",
       "\n",
       "\n",
       "/* Colors for structures. */\n",
       "\n",
       ".hreprt-dict {\n",
       "\tbackground: var(--dict-color);\n",
       "\tborder-color: var(--dict-color);\n",
       "}\n",
       "\n",
       ".hreprt-list {\n",
       "\tbackground: var(--list-color);\n",
       "\tborder-color: var(--list-color);\n",
       "}\n",
       "\n",
       ".hreprt-tuple {\n",
       "\tbackground: var(--tuple-color);\n",
       "\tborder-color: var(--tuple-color);\n",
       "}\n",
       "\n",
       ".hreprt-set {\n",
       "\tbackground: var(--set-color);\n",
       "\tborder-color: var(--set-color);\n",
       "}\n",
       "\n",
       ".hreprt-frozenset {\n",
       "\tbackground: var(--frozenset-color);\n",
       "\tborder-color: var(--frozenset-color);\n",
       "}\n",
       "\n",
       "table.hrepr-body {\n",
       "\tborder-collapse: collapse;\n",
       "\twidth: 100%;\n",
       "}\n",
       "\n",
       "table.hrepr-body > tbody > tr:nth-child(even) {\n",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       "table.hrepr-body > tbody > tr:nth-child(odd) {\n",
       "\tbackground: #fff;\n",
       "}\n",
       "\n",
       "\n",
       "/* References */\n",
       "\n",
       ".hrepr-ref {\n",
       "\tfont-weight: bold;\n",
       "\tcolor: magenta;\n",
       "}\n",
       "\n",
       ".hrepr-refbox {\n",
       "\tdisplay: inline-flex;\n",
       "\tposition: relative;\n",
       "\tplace-items: center;\n",
       "}\n",
       "</style><div class=\"hrepr\"><div class=\"hreprt-dict hrepr-bracketed\"><div class=\"hrepr-open\">{</div><table class=\"hrepr-body\"><tr><td><span class=\"hreprt-str\">strings</span></td><td><span class=\"hrepr-delim\">: </span></td><td><span class=\"hreprt-str\">Hello this is hrepr</span></td></tr><tr><td><span class=\"hreprt-str\">numbers</span></td><td><span class=\"hrepr-delim\">: </span></td><td><div class=\"hreprt-list hrepr-bracketed\"><div class=\"hrepr-open\">[</div><div class=\"hreprl-h hrepr-body\"><div><span class=\"hreprt-int\">1</span></div><div><span class=\"hreprt-int\">-2</span></div><div><span class=\"hreprt-float\">3.0</span></div></div><div class=\"hrepr-close\">]</div></div></td></tr><tr><td><span class=\"hreprt-str\">booleans</span></td><td><span class=\"hrepr-delim\">: </span></td><td><div class=\"hreprt-tuple hrepr-bracketed\"><div class=\"hrepr-open\">(</div><div class=\"hreprl-h hrepr-body\"><div><span class=\"hreprv-True\">True</span></div><div><span class=\"hreprv-False\">False</span></div></div><div class=\"hrepr-close\">)</div></div></td></tr><tr><td><span class=\"hreprt-str\">none</span></td><td><span class=\"hrepr-delim\">: </span></td><td><span class=\"hreprv-None\">None</span></td></tr></table><div class=\"hrepr-close\">}</div></div></div></div>"
      ],
      "text/plain": [
       "<div class=\"hreprt-dict hrepr-bracketed\"><div class=\"hrepr-open\">{</div><table class=\"hrepr-body\"><tr><td><span class=\"hreprt-str\">strings</span></td><td><span class=\"hrepr-delim\">: </span></td><td><span class=\"hreprt-str\">Hello this is hrepr</span></td></tr><tr><td><span class=\"hreprt-str\">numbers</span></td><td><span class=\"hrepr-delim\">: </span></td><td><div class=\"hreprt-list hrepr-bracketed\"><div class=\"hrepr-open\">[</div><div class=\"hreprl-h hrepr-body\"><div><span class=\"hreprt-int\">1</span></div><div><span class=\"hreprt-int\">-2</span></div><div><span class=\"hreprt-float\">3.0</span></div></div><div class=\"hrepr-close\">]</div></div></td></tr><tr><td><span class=\"hreprt-str\">booleans</span></td><td><span class=\"hrepr-delim\">: </span></td><td><div class=\"hreprt-tuple hrepr-bracketed\"><div class=\"hrepr-open\">(</div><div class=\"hreprl-h hrepr-body\"><div><span class=\"hreprv-True\">True</span></div><div><span class=\"hreprv-False\">False</span></div></div><div class=\"hrepr-close\">)</div></div></td></tr><tr><td><span class=\"hreprt-str\">none</span></td><td><span class=\"hrepr-delim\">: </span></td><td><span class=\"hreprv-None\">None</span></td></tr></table><div class=\"hrepr-close\">}</div></div>"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from hrepr import hrepr\n",
    "\n",
    "hrepr({\n",
    "    'strings': \"Hello this is hrepr\",\n",
    "    'numbers': [1, -2, 3.0],\n",
    "    'booleans': (True, False),\n",
    "    'none': None\n",
    "})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>/*\n",
       " * Override Jupyter's default css inside elements with the hrepr class.\n",
       " */\n",
       "\n",
       ".rendered_html .hrepr table {\n",
       "\tmargin-top: 0px;\n",
       "\tmargin-bottom: 0px;\n",
       "\ttable-layout: auto;\n",
       "}\n",
       "\n",
       ".rendered_html tr, .rendered_html th, .rendered_html td {\n",
       "\tpadding: 2px;\n",
       "\ttext-align: left;\n",
       "}\n",
       "</style><style>\n",
       ":root, :host {\n",
       "\t--instance-color: #00a;\n",
       "\t--dict-color: #00a;\n",
       "\t--tuple-color: #080;\n",
       "\t--list-color: #080;\n",
       "\t--set-color: #080;\n",
       "\t--frozenset-color: #88f;\n",
       "\t--error-color: #f00;\n",
       "\t--struct-border: 2px;\n",
       "}\n",
       "\n",
       "/* Scalar/string formatting */\n",
       "\n",
       ".hreprv-True, .hreprv-False, .hreprv-None, .hreprt-int, .hreprt-float {\n",
       "\tfont-weight: bold;\n",
       "}\n",
       "\n",
       ".hreprt-int, .hreprt-float {\n",
       "\tcolor: #88f;\n",
       "}\n",
       "\n",
       ".hreprt-str {\n",
       "\tcolor: #666;\n",
       "\twhite-space: pre-wrap;\n",
       "}\n",
       "\n",
       ".hreprt-str:before {\n",
       "\tcontent: \"“\";\n",
       "\tcolor: #888;\n",
       "}\n",
       "\n",
       ".hreprt-str:after {\n",
       "\tcontent: \"”\";\n",
       "\tcolor: #888;\n",
       "}\n",
       "\n",
       ".hreprt-bytes {\n",
       "\tcolor: #666;\n",
       "\tfont-family: monospace;\n",
       "\twhite-space: pre-wrap;\n",
       "}\n",
       "\n",
       ".hreprt-bytes:before {\n",
       "\tcontent: \"b“\";\n",
       "}\n",
       "\n",
       ".hreprt-bytes:after {\n",
       "\tcontent: \"”\";\n",
       "}\n",
       "\n",
       ".hreprv-True {\n",
       "\tcolor: green;\n",
       "}\n",
       "\n",
       ".hreprv-False {\n",
       "\tcolor: red;\n",
       "}\n",
       "\n",
       ".hreprv-None {\n",
       "\tcolor: grey;\n",
       "}\n",
       "\n",
       ".hreprk-class > .hrepr-defn-key {\n",
       "\tcolor: blue;\n",
       "}\n",
       "\n",
       ".hreprk-module > .hrepr-defn-key {\n",
       "\tcolor: purple;\n",
       "}\n",
       "\n",
       ".hreprk-function > .hrepr-defn-key,\n",
       ".hreprk-builtin > .hrepr-defn-key,\n",
       ".hreprk-method > .hrepr-defn-key,\n",
       ".hreprk-descriptor > .hrepr-defn-key {\n",
       "\tcolor: #080;\n",
       "}\n",
       "\n",
       ".hrepr-defn-key {\n",
       "\tfont-weight: bold;\n",
       "}\n",
       "\n",
       "\n",
       "/* Generic layouts */\n",
       "\n",
       ".hreprl-h, .hreprl-s {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: row;\n",
       "\tflex-wrap: wrap;\n",
       "}\n",
       "\n",
       ".hreprl-v {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: column;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h,\n",
       ".hrepr-body.hreprl-v {\n",
       "\tgap: 4px;\n",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h {\n",
       "\talign-items: center;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-v > *,\n",
       ".hrepr-body.hreprl-h > * {\n",
       "\tbackground: white;\n",
       "\tdisplay: inline-flex;\n",
       "\tplace-items: center;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h > div > .hrepr-ellipsis,\n",
       ".hrepr-body.hreprl-v > div > .hrepr-ellipsis {\n",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h > div > .hrepr-ellipsis {\n",
       "\tpadding-left: 5px;\n",
       "\tpadding-right: 5px;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-v > div > .hrepr-ellipsis {\n",
       "\tpadding-top: 5px;\n",
       "\tpadding-bottom: 5px;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-s > * {\n",
       "\tpadding: 1px;\n",
       "}\n",
       "\n",
       ".hrepr-bracketed {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: row;\n",
       "\tplace-items: center;\n",
       "\tbackground: black;\n",
       "\tborder: var(--struct-border) solid black;\n",
       "\tbox-sizing: border-box;\n",
       "}\n",
       "\n",
       ".hrepr-bracketed > .hrepr-open {\n",
       "\tpadding-right: var(--struct-border);\n",
       "}\n",
       ".hrepr-bracketed > .hrepr-close {\n",
       "\tpadding-left: var(--struct-border);\n",
       "}\n",
       ".hrepr-bracketed > .hrepr-open,\n",
       ".hrepr-bracketed > .hrepr-close,\n",
       ".hrepr-instance > .hrepr-title,\n",
       ".hreprl-s {\n",
       "\tcolor: white;\n",
       "\tfont-weight: bold;\n",
       "}\n",
       "\n",
       ".hrepr-instance {\n",
       "\tbackground: var(--instance-color);\n",
       "\tborder: var(--struct-border) solid var(--instance-color);\n",
       "\tbox-sizing: border-box;\n",
       "}\n",
       ".hrepr-instance > .hrepr-title {\n",
       "\tcolor: white;\n",
       "\tfont-weight: bold;\n",
       "}\n",
       ".hrepr-instance.hreprl-v > .hrepr-title {\n",
       "\tpadding-bottom: var(--struct-border);\n",
       "}\n",
       ".hrepr-instance.hreprl-h > .hrepr-title,\n",
       ".hrepr-instance.hreprl-s > .hrepr-title {\n",
       "\tpadding-right: var(--struct-border);\n",
       "\tplace-self: center;\n",
       "}\n",
       ".hrepr-instance.hrepr-error {\n",
       "\tbackground: var(--error-color);\n",
       "\tborder: var(--struct-border) solid var(--error-color);\n",
       "}\n",
       "\n",
       "\n",
       "/* Colors for structures. */\n",
       "\n",
       ".hreprt-dict {\n",
       "\tbackground: var(--dict-color);\n",
       "\tborder-color: var(--dict-color);\n",
       "}\n",
       "\n",
       ".hreprt-list {\n",
       "\tbackground: var(--list-color);\n",
       "\tborder-color: var(--list-color);\n",
       "}\n",
       "\n",
       ".hreprt-tuple {\n",
       "\tbackground: var(--tuple-color);\n",
       "\tborder-color: var(--tuple-color);\n",
       "}\n",
       "\n",
       ".hreprt-set {\n",
       "\tbackground: var(--set-color);\n",
       "\tborder-color: var(--set-color);\n",
       "}\n",
       "\n",
       ".hreprt-frozenset {\n",
       "\tbackground: var(--frozenset-color);\n",
       "\tborder-color: var(--frozenset-color);\n",
       "}\n",
       "\n",
       "table.hrepr-body {\n",
       "\tborder-collapse: collapse;\n",
       "\twidth: 100%;\n",
       "}\n",
       "\n",
       "table.hrepr-body > tbody > tr:nth-child(even) {\n",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       "table.hrepr-body > tbody > tr:nth-child(odd) {\n",
       "\tbackground: #fff;\n",
       "}\n",
       "\n",
       "\n",
       "/* References */\n",
       "\n",
       ".hrepr-ref {\n",
       "\tfont-weight: bold;\n",
       "\tcolor: magenta;\n",
       "}\n",
       "\n",
       ".hrepr-refbox {\n",
       "\tdisplay: inline-flex;\n",
       "\tposition: relative;\n",
       "\tplace-items: center;\n",
       "}\n",
       "</style><div class=\"hrepr\"><div class=\"hrepr-instance hreprl-v hreprt-Point\"><div class=\"hrepr-title\">Point</div><table class=\"hrepr-body\"><tr><td><span class=\"hreprt-symbol\">x</span></td><td><span class=\"hrepr-delim\">=</span></td><td><span class=\"hreprt-int\">1</span></td></tr><tr><td><span class=\"hreprt-symbol\">y</span></td><td><span class=\"hrepr-delim\">=</span></td><td><div class=\"hrepr-instance hreprl-v hreprt-Point\"><div class=\"hrepr-title\">Point</div><table class=\"hrepr-body\"><tr><td><span class=\"hreprt-symbol\">x</span></td><td><span class=\"hrepr-delim\">=</span></td><td><span class=\"hreprt-int\">2</span></td></tr><tr><td><span class=\"hreprt-symbol\">y</span></td><td><span class=\"hrepr-delim\">=</span></td><td><span class=\"hreprt-int\">3</span></td></tr></table></div></td></tr></table></div></div></div>"
      ],
      "text/plain": [
       "<div class=\"hrepr-instance hreprl-v hreprt-Point\"><div class=\"hrepr-title\">Point</div><table class=\"hrepr-body\"><tr><td><span class=\"hreprt-symbol\">x</span></td><td><span class=\"hrepr-delim\">=</span></td><td><span class=\"hreprt-int\">1</span></td></tr><tr><td><span class=\"hreprt-symbol\">y</span></td><td><span class=\"hrepr-delim\">=</span></td><td><div class=\"hrepr-instance hreprl-v hreprt-Point\"><div class=\"hrepr-title\">Point</div><table class=\"hrepr-body\"><tr><td><span class=\"hreprt-symbol\">x</span></td><td><span class=\"hrepr-delim\">=</span></td><td><span class=\"hreprt-int\">2</span></td></tr><tr><td><span class=\"hreprt-symbol\">y</span></td><td><span class=\"hrepr-delim\">=</span></td><td><span class=\"hreprt-int\">3</span></td></tr></table></div></td></tr></table></div>"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Dataclasses are supported natively\n",
    "from dataclasses import dataclass\n",
    "\n",
    "@dataclass\n",
    "class Point:\n",
    "    x: int\n",
    "    y: int\n",
    "\n",
    "hrepr(Point(1, Point(2, 3)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>/*\n",
       " * Override Jupyter's default css inside elements with the hrepr class.\n",
       " */\n",
       "\n",
       ".rendered_html .hrepr table {\n",
       "\tmargin-top: 0px;\n",
       "\tmargin-bottom: 0px;\n",
       "\ttable-layout: auto;\n",
       "}\n",
       "\n",
       ".rendered_html tr, .rendered_html th, .rendered_html td {\n",
       "\tpadding: 2px;\n",
       "\ttext-align: left;\n",
       "}\n",
       "</style><style>\n",
       ":root, :host {\n",
       "\t--instance-color: #00a;\n",
       "\t--dict-color: #00a;\n",
       "\t--tuple-color: #080;\n",
       "\t--list-color: #080;\n",
       "\t--set-color: #080;\n",
       "\t--frozenset-color: #88f;\n",
       "\t--error-color: #f00;\n",
       "\t--struct-border: 2px;\n",
       "}\n",
       "\n",
       "/* Scalar/string formatting */\n",
       "\n",
       ".hreprv-True, .hreprv-False, .hreprv-None, .hreprt-int, .hreprt-float {\n",
       "\tfont-weight: bold;\n",
       "}\n",
       "\n",
       ".hreprt-int, .hreprt-float {\n",
       "\tcolor: #88f;\n",
       "}\n",
       "\n",
       ".hreprt-str {\n",
       "\tcolor: #666;\n",
       "\twhite-space: pre-wrap;\n",
       "}\n",
       "\n",
       ".hreprt-str:before {\n",
       "\tcontent: \"“\";\n",
       "\tcolor: #888;\n",
       "}\n",
       "\n",
       ".hreprt-str:after {\n",
       "\tcontent: \"”\";\n",
       "\tcolor: #888;\n",
       "}\n",
       "\n",
       ".hreprt-bytes {\n",
       "\tcolor: #666;\n",
       "\tfont-family: monospace;\n",
       "\twhite-space: pre-wrap;\n",
       "}\n",
       "\n",
       ".hreprt-bytes:before {\n",
       "\tcontent: \"b“\";\n",
       "}\n",
       "\n",
       ".hreprt-bytes:after {\n",
       "\tcontent: \"”\";\n",
       "}\n",
       "\n",
       ".hreprv-True {\n",
       "\tcolor: green;\n",
       "}\n",
       "\n",
       ".hreprv-False {\n",
       "\tcolor: red;\n",
       "}\n",
       "\n",
       ".hreprv-None {\n",
       "\tcolor: grey;\n",
       "}\n",
       "\n",
       ".hreprk-class > .hrepr-defn-key {\n",
       "\tcolor: blue;\n",
       "}\n",
       "\n",
       ".hreprk-module > .hrepr-defn-key {\n",
       "\tcolor: purple;\n",
       "}\n",
       "\n",
       ".hreprk-function > .hrepr-defn-key,\n",
       ".hreprk-builtin > .hrepr-defn-key,\n",
       ".hreprk-method > .hrepr-defn-key,\n",
       ".hreprk-descriptor > .hrepr-defn-key {\n",
       "\tcolor: #080;\n",
       "}\n",
       "\n",
       ".hrepr-defn-key {\n",
       "\tfont-weight: bold;\n",
       "}\n",
       "\n",
       "\n",
       "/* Generic layouts */\n",
       "\n",
       ".hreprl-h, .hreprl-s {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: row;\n",
       "\tflex-wrap: wrap;\n",
       "}\n",
       "\n",
       ".hreprl-v {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: column;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h,\n",
       ".hrepr-body.hreprl-v {\n",
       "\tgap: 4px;\n",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h {\n",
       "\talign-items: center;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-v > *,\n",
       ".hrepr-body.hreprl-h > * {\n",
       "\tbackground: white;\n",
       "\tdisplay: inline-flex;\n",
       "\tplace-items: center;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h > div > .hrepr-ellipsis,\n",
       ".hrepr-body.hreprl-v > div > .hrepr-ellipsis {\n",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h > div > .hrepr-ellipsis {\n",
       "\tpadding-left: 5px;\n",
       "\tpadding-right: 5px;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-v > div > .hrepr-ellipsis {\n",
       "\tpadding-top: 5px;\n",
       "\tpadding-bottom: 5px;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-s > * {\n",
       "\tpadding: 1px;\n",
       "}\n",
       "\n",
       ".hrepr-bracketed {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: row;\n",
       "\tplace-items: center;\n",
       "\tbackground: black;\n",
       "\tborder: var(--struct-border) solid black;\n",
       "\tbox-sizing: border-box;\n",
       "}\n",
       "\n",
       ".hrepr-bracketed > .hrepr-open {\n",
       "\tpadding-right: var(--struct-border);\n",
       "}\n",
       ".hrepr-bracketed > .hrepr-close {\n",
       "\tpadding-left: var(--struct-border);\n",
       "}\n",
       ".hrepr-bracketed > .hrepr-open,\n",
       ".hrepr-bracketed > .hrepr-close,\n",
       ".hrepr-instance > .hrepr-title,\n",
       ".hreprl-s {\n",
       "\tcolor: white;\n",
       "\tfont-weight: bold;\n",
       "}\n",
       "\n",
       ".hrepr-instance {\n",
       "\tbackground: var(--instance-color);\n",
       "\tborder: var(--struct-border) solid var(--instance-color);\n",
       "\tbox-sizing: border-box;\n",
       "}\n",
       ".hrepr-instance > .hrepr-title {\n",
       "\tcolor: white;\n",
       "\tfont-weight: bold;\n",
       "}\n",
       ".hrepr-instance.hreprl-v > .hrepr-title {\n",
       "\tpadding-bottom: var(--struct-border);\n",
       "}\n",
       ".hrepr-instance.hreprl-h > .hrepr-title,\n",
       ".hrepr-instance.hreprl-s > .hrepr-title {\n",
       "\tpadding-right: var(--struct-border);\n",
       "\tplace-self: center;\n",
       "}\n",
       ".hrepr-instance.hrepr-error {\n",
       "\tbackground: var(--error-color);\n",
       "\tborder: var(--struct-border) solid var(--error-color);\n",
       "}\n",
       "\n",
       "\n",
       "/* Colors for structures. */\n",
       "\n",
       ".hreprt-dict {\n",
       "\tbackground: var(--dict-color);\n",
       "\tborder-color: var(--dict-color);\n",
       "}\n",
       "\n",
       ".hreprt-list {\n",
       "\tbackground: var(--list-color);\n",
       "\tborder-color: var(--list-color);\n",
       "}\n",
       "\n",
       ".hreprt-tuple {\n",
       "\tbackground: var(--tuple-color);\n",
       "\tborder-color: var(--tuple-color);\n",
       "}\n",
       "\n",
       ".hreprt-set {\n",
       "\tbackground: var(--set-color);\n",
       "\tborder-color: var(--set-color);\n",
       "}\n",
       "\n",
       ".hreprt-frozenset {\n",
       "\tbackground: var(--frozenset-color);\n",
       "\tborder-color: var(--frozenset-color);\n",
       "}\n",
       "\n",
       "table.hrepr-body {\n",
       "\tborder-collapse: collapse;\n",
       "\twidth: 100%;\n",
       "}\n",
       "\n",
       "table.hrepr-body > tbody > tr:nth-child(even) {\n",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       "table.hrepr-body > tbody > tr:nth-child(odd) {\n",
       "\tbackground: #fff;\n",
       "}\n",
       "\n",
       "\n",
       "/* References */\n",
       "\n",
       ".hrepr-ref {\n",
       "\tfont-weight: bold;\n",
       "\tcolor: magenta;\n",
       "}\n",
       "\n",
       ".hrepr-refbox {\n",
       "\tdisplay: inline-flex;\n",
       "\tposition: relative;\n",
       "\tplace-items: center;\n",
       "}\n",
       "</style><div class=\"hrepr\"><div class=\"hrepr-instance hreprl-v hreprt-Point\"><div class=\"hrepr-title\">Point</div><table class=\"hrepr-body\"><tr><td><span class=\"hreprt-symbol\">x</span></td><td><span class=\"hrepr-delim\">=</span></td><td><span class=\"hreprt-int\">1</span></td></tr><tr><td><span class=\"hreprt-symbol\">y</span></td><td><span class=\"hrepr-delim\">=</span></td><td><div class=\"hrepr-instance hreprl-s hreprt-Point\"><div class=\"hrepr-title\">Point</div><div class=\"hrepr-body hreprl-s\">...</div></div></td></tr></table></div></div></div>"
      ],
      "text/plain": [
       "<div class=\"hrepr-instance hreprl-v hreprt-Point\"><div class=\"hrepr-title\">Point</div><table class=\"hrepr-body\"><tr><td><span class=\"hreprt-symbol\">x</span></td><td><span class=\"hrepr-delim\">=</span></td><td><span class=\"hreprt-int\">1</span></td></tr><tr><td><span class=\"hreprt-symbol\">y</span></td><td><span class=\"hrepr-delim\">=</span></td><td><div class=\"hrepr-instance hreprl-s hreprt-Point\"><div class=\"hrepr-title\">Point</div><div class=\"hrepr-body hreprl-s\">...</div></div></td></tr></table></div>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# You can control the nesting depth\n",
    "hrepr(Point(1, Point(2, 3)), max_depth=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>/*\n",
       " * Override Jupyter's default css inside elements with the hrepr class.\n",
       " */\n",
       "\n",
       ".rendered_html .hrepr table {\n",
       "\tmargin-top: 0px;\n",
       "\tmargin-bottom: 0px;\n",
       "\ttable-layout: auto;\n",
       "}\n",
       "\n",
       ".rendered_html tr, .rendered_html th, .rendered_html td {\n",
       "\tpadding: 2px;\n",
       "\ttext-align: left;\n",
       "}\n",
       "</style><div class=\"hrepr\"><div><style>.nice { font-weight: bold; }</style><ul style=\"list-style-type:circle\"><li>You can generate HTML directly</li><li>Syntax: <code>H.&lt;tag&gt;[&lt;class&gt;](&lt;child&gt;..., &lt;attr&gt;=&lt;value&gt;...)</code></li><li class=\"nice\">Isn&#x27;t this nice?</li></ul></div></div></div>"
      ],
      "text/plain": [
       "<div><style>.nice { font-weight: bold; }</style><ul style=\"list-style-type:circle\"><li>You can generate HTML directly</li><li>Syntax: <code>H.&lt;tag&gt;[&lt;class&gt;](&lt;child&gt;..., &lt;attr&gt;=&lt;value&gt;...)</code></li><li class=\"nice\">Isn&#x27;t this nice?</li></ul></div>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from hrepr import H\n",
    "\n",
    "H.div(\n",
    "    H.style(\".nice { font-weight: bold; }\"),\n",
    "    H.ul(\n",
    "        H.li(\"You can generate HTML directly\"),\n",
    "        H.li(\"Syntax: \", H.code(\"H.<tag>[<class>](<child>..., <attr>=<value>...)\")),\n",
    "        H.li[\"nice\"](\"Isn't this nice?\"),\n",
    "        style=\"list-style-type:circle\"\n",
    "    )\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>/*\n",
       " * Override Jupyter's default css inside elements with the hrepr class.\n",
       " */\n",
       "\n",
       ".rendered_html .hrepr table {\n",
       "\tmargin-top: 0px;\n",
       "\tmargin-bottom: 0px;\n",
       "\ttable-layout: auto;\n",
       "}\n",
       "\n",
       ".rendered_html tr, .rendered_html th, .rendered_html td {\n",
       "\tpadding: 2px;\n",
       "\ttext-align: left;\n",
       "}\n",
       "</style><style>\n",
       ":root, :host {\n",
       "\t--instance-color: #00a;\n",
       "\t--dict-color: #00a;\n",
       "\t--tuple-color: #080;\n",
       "\t--list-color: #080;\n",
       "\t--set-color: #080;\n",
       "\t--frozenset-color: #88f;\n",
       "\t--error-color: #f00;\n",
       "\t--struct-border: 2px;\n",
       "}\n",
       "\n",
       "/* Scalar/string formatting */\n",
       "\n",
       ".hreprv-True, .hreprv-False, .hreprv-None, .hreprt-int, .hreprt-float {\n",
       "\tfont-weight: bold;\n",
       "}\n",
       "\n",
       ".hreprt-int, .hreprt-float {\n",
       "\tcolor: #88f;\n",
       "}\n",
       "\n",
       ".hreprt-str {\n",
       "\tcolor: #666;\n",
       "\twhite-space: pre-wrap;\n",
       "}\n",
       "\n",
       ".hreprt-str:before {\n",
       "\tcontent: \"“\";\n",
       "\tcolor: #888;\n",
       "}\n",
       "\n",
       ".hreprt-str:after {\n",
       "\tcontent: \"”\";\n",
       "\tcolor: #888;\n",
       "}\n",
       "\n",
       ".hreprt-bytes {\n",
       "\tcolor: #666;\n",
       "\tfont-family: monospace;\n",
       "\twhite-space: pre-wrap;\n",
       "}\n",
       "\n",
       ".hreprt-bytes:before {\n",
       "\tcontent: \"b“\";\n",
       "}\n",
       "\n",
       ".hreprt-bytes:after {\n",
       "\tcontent: \"”\";\n",
       "}\n",
       "\n",
       ".hreprv-True {\n",
       "\tcolor: green;\n",
       "}\n",
       "\n",
       ".hreprv-False {\n",
       "\tcolor: red;\n",
       "}\n",
       "\n",
       ".hreprv-None {\n",
       "\tcolor: grey;\n",
       "}\n",
       "\n",
       ".hreprk-class > .hrepr-defn-key {\n",
       "\tcolor: blue;\n",
       "}\n",
       "\n",
       ".hreprk-module > .hrepr-defn-key {\n",
       "\tcolor: purple;\n",
       "}\n",
       "\n",
       ".hreprk-function > .hrepr-defn-key,\n",
       ".hreprk-builtin > .hrepr-defn-key,\n",
       ".hreprk-method > .hrepr-defn-key,\n",
       ".hreprk-descriptor > .hrepr-defn-key {\n",
       "\tcolor: #080;\n",
       "}\n",
       "\n",
       ".hrepr-defn-key {\n",
       "\tfont-weight: bold;\n",
       "}\n",
       "\n",
       "\n",
       "/* Generic layouts */\n",
       "\n",
       ".hreprl-h, .hreprl-s {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: row;\n",
       "\tflex-wrap: wrap;\n",
       "}\n",
       "\n",
       ".hreprl-v {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: column;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h,\n",
       ".hrepr-body.hreprl-v {\n",
       "\tgap: 4px;\n",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h {\n",
       "\talign-items: center;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-v > *,\n",
       ".hrepr-body.hreprl-h > * {\n",
       "\tbackground: white;\n",
       "\tdisplay: inline-flex;\n",
       "\tplace-items: center;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h > div > .hrepr-ellipsis,\n",
       ".hrepr-body.hreprl-v > div > .hrepr-ellipsis {\n",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h > div > .hrepr-ellipsis {\n",
       "\tpadding-left: 5px;\n",
       "\tpadding-right: 5px;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-v > div > .hrepr-ellipsis {\n",
       "\tpadding-top: 5px;\n",
       "\tpadding-bottom: 5px;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-s > * {\n",
       "\tpadding: 1px;\n",
       "}\n",
       "\n",
       ".hrepr-bracketed {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: row;\n",
       "\tplace-items: center;\n",
       "\tbackground: black;\n",
       "\tborder: var(--struct-border) solid black;\n",
       "\tbox-sizing: border-box;\n",
       "}\n",
       "\n",
       ".hrepr-bracketed > .hrepr-open {\n",
       "\tpadding-right: var(--struct-border);\n",
       "}\n",
       ".hrepr-bracketed > .hrepr-close {\n",
       "\tpadding-left: var(--struct-border);\n",
       "}\n",
       ".hrepr-bracketed > .hrepr-open,\n",
       ".hrepr-bracketed > .hrepr-close,\n",
       ".hrepr-instance > .hrepr-title,\n",
       ".hreprl-s {\n",
       "\tcolor: white;\n",
       "\tfont-weight: bold;\n",
       "}\n",
       "\n",
       ".hrepr-instance {\n",
       "\tbackground: var(--instance-color);\n",
       "\tborder: var(--struct-border) solid var(--instance-color);\n",
       "\tbox-sizing: border-box;\n",
       "}\n",
       ".hrepr-instance > .hrepr-title {\n",
       "\tcolor: white;\n",
       "\tfont-weight: bold;\n",
       "}\n",
       ".hrepr-instance.hreprl-v > .hrepr-title {\n",
       "\tpadding-bottom: var(--struct-border);\n",
       "}\n",
       ".hrepr-instance.hreprl-h > .hrepr-title,\n",
       ".hrepr-instance.hreprl-s > .hrepr-title {\n",
       "\tpadding-right: var(--struct-border);\n",
       "\tplace-self: center;\n",
       "}\n",
       ".hrepr-instance.hrepr-error {\n",
       "\tbackground: var(--error-color);\n",
       "\tborder: var(--struct-border) solid var(--error-color);\n",
       "}\n",
       "\n",
       "\n",
       "/* Colors for structures. */\n",
       "\n",
       ".hreprt-dict {\n",
       "\tbackground: var(--dict-color);\n",
       "\tborder-color: var(--dict-color);\n",
       "}\n",
       "\n",
       ".hreprt-list {\n",
       "\tbackground: var(--list-color);\n",
       "\tborder-color: var(--list-color);\n",
       "}\n",
       "\n",
       ".hreprt-tuple {\n",
       "\tbackground: var(--tuple-color);\n",
       "\tborder-color: var(--tuple-color);\n",
       "}\n",
       "\n",
       ".hreprt-set {\n",
       "\tbackground: var(--set-color);\n",
       "\tborder-color: var(--set-color);\n",
       "}\n",
       "\n",
       ".hreprt-frozenset {\n",
       "\tbackground: var(--frozenset-color);\n",
       "\tborder-color: var(--frozenset-color);\n",
       "}\n",
       "\n",
       "table.hrepr-body {\n",
       "\tborder-collapse: collapse;\n",
       "\twidth: 100%;\n",
       "}\n",
       "\n",
       "table.hrepr-body > tbody > tr:nth-child(even) {\n",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       "table.hrepr-body > tbody > tr:nth-child(odd) {\n",
       "\tbackground: #fff;\n",
       "}\n",
       "\n",
       "\n",
       "/* References */\n",
       "\n",
       ".hrepr-ref {\n",
       "\tfont-weight: bold;\n",
       "\tcolor: magenta;\n",
       "}\n",
       "\n",
       ".hrepr-refbox {\n",
       "\tdisplay: inline-flex;\n",
       "\tposition: relative;\n",
       "\tplace-items: center;\n",
       "}\n",
       "</style><div class=\"hrepr\"><div class=\"hreprt-list hrepr-bracketed\"><div class=\"hrepr-open\">[</div><div class=\"hreprl-h hrepr-body\"><div><div style=\"\n",
       "        background: rgb(0, 0, 0);\n",
       "        width: 20px;\n",
       "        height: 20px;\n",
       "        margin: 3px;\n",
       "        \"></div></div><div><div style=\"\n",
       "        background: rgb(32, 0, 0);\n",
       "        width: 20px;\n",
       "        height: 20px;\n",
       "        margin: 3px;\n",
       "        \"></div></div><div><div style=\"\n",
       "        background: rgb(64, 0, 0);\n",
       "        width: 20px;\n",
       "        height: 20px;\n",
       "        margin: 3px;\n",
       "        \"></div></div><div><div style=\"\n",
       "        background: rgb(96, 0, 0);\n",
       "        width: 20px;\n",
       "        height: 20px;\n",
       "        margin: 3px;\n",
       "        \"></div></div><div><div style=\"\n",
       "        background: rgb(128, 0, 0);\n",
       "        width: 20px;\n",
       "        height: 20px;\n",
       "        margin: 3px;\n",
       "        \"></div></div><div><div style=\"\n",
       "        background: rgb(160, 0, 0);\n",
       "        width: 20px;\n",
       "        height: 20px;\n",
       "        margin: 3px;\n",
       "        \"></div></div><div><div style=\"\n",
       "        background: rgb(192, 0, 0);\n",
       "        width: 20px;\n",
       "        height: 20px;\n",
       "        margin: 3px;\n",
       "        \"></div></div><div><div style=\"\n",
       "        background: rgb(224, 0, 0);\n",
       "        width: 20px;\n",
       "        height: 20px;\n",
       "        margin: 3px;\n",
       "        \"></div></div><div><div style=\"\n",
       "        background: rgb(256, 0, 0);\n",
       "        width: 20px;\n",
       "        height: 20px;\n",
       "        margin: 3px;\n",
       "        \"></div></div></div><div class=\"hrepr-close\">]</div></div></div></div>"
      ],
      "text/plain": [
       "<div class=\"hreprt-list hrepr-bracketed\"><div class=\"hrepr-open\">[</div><div class=\"hreprl-h hrepr-body\"><div><div style=\"\n",
       "        background: rgb(0, 0, 0);\n",
       "        width: 20px;\n",
       "        height: 20px;\n",
       "        margin: 3px;\n",
       "        \"></div></div><div><div style=\"\n",
       "        background: rgb(32, 0, 0);\n",
       "        width: 20px;\n",
       "        height: 20px;\n",
       "        margin: 3px;\n",
       "        \"></div></div><div><div style=\"\n",
       "        background: rgb(64, 0, 0);\n",
       "        width: 20px;\n",
       "        height: 20px;\n",
       "        margin: 3px;\n",
       "        \"></div></div><div><div style=\"\n",
       "        background: rgb(96, 0, 0);\n",
       "        width: 20px;\n",
       "        height: 20px;\n",
       "        margin: 3px;\n",
       "        \"></div></div><div><div style=\"\n",
       "        background: rgb(128, 0, 0);\n",
       "        width: 20px;\n",
       "        height: 20px;\n",
       "        margin: 3px;\n",
       "        \"></div></div><div><div style=\"\n",
       "        background: rgb(160, 0, 0);\n",
       "        width: 20px;\n",
       "        height: 20px;\n",
       "        margin: 3px;\n",
       "        \"></div></div><div><div style=\"\n",
       "        background: rgb(192, 0, 0);\n",
       "        width: 20px;\n",
       "        height: 20px;\n",
       "        margin: 3px;\n",
       "        \"></div></div><div><div style=\"\n",
       "        background: rgb(224, 0, 0);\n",
       "        width: 20px;\n",
       "        height: 20px;\n",
       "        margin: 3px;\n",
       "        \"></div></div><div><div style=\"\n",
       "        background: rgb(256, 0, 0);\n",
       "        width: 20px;\n",
       "        height: 20px;\n",
       "        margin: 3px;\n",
       "        \"></div></div></div><div class=\"hrepr-close\">]</div></div>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "class Color:\n",
    "    def __init__(self, r, g, b):\n",
    "        self.r = r\n",
    "        self.g = g\n",
    "        self.b = b\n",
    "\n",
    "    def __hrepr__(self, H, hrepr):\n",
    "        size = hrepr.config.swatch_size or 25\n",
    "        style = f\"\"\"\n",
    "        background: rgb({self.r}, {self.g}, {self.b});\n",
    "        width: {size}px;\n",
    "        height: {size}px;\n",
    "        margin: 3px;\n",
    "        \"\"\"\n",
    "        return H.div(style=style)\n",
    "\n",
    "hrepr([Color(i*32, 0, 0) for i in range(9)],\n",
    "      swatch_size=20)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>/*\n",
       " * Override Jupyter's default css inside elements with the hrepr class.\n",
       " */\n",
       "\n",
       ".rendered_html .hrepr table {\n",
       "\tmargin-top: 0px;\n",
       "\tmargin-bottom: 0px;\n",
       "\ttable-layout: auto;\n",
       "}\n",
       "\n",
       ".rendered_html tr, .rendered_html th, .rendered_html td {\n",
       "\tpadding: 2px;\n",
       "\ttext-align: left;\n",
       "}\n",
       "</style><style>\n",
       "            .person { background: magenta !important; border-color: magenta !important;  }\n",
       "            .person-short { font-weight: bold; color: green; }\n",
       "        </style><style>\n",
       ":root, :host {\n",
       "\t--instance-color: #00a;\n",
       "\t--dict-color: #00a;\n",
       "\t--tuple-color: #080;\n",
       "\t--list-color: #080;\n",
       "\t--set-color: #080;\n",
       "\t--frozenset-color: #88f;\n",
       "\t--error-color: #f00;\n",
       "\t--struct-border: 2px;\n",
       "}\n",
       "\n",
       "/* Scalar/string formatting */\n",
       "\n",
       ".hreprv-True, .hreprv-False, .hreprv-None, .hreprt-int, .hreprt-float {\n",
       "\tfont-weight: bold;\n",
       "}\n",
       "\n",
       ".hreprt-int, .hreprt-float {\n",
       "\tcolor: #88f;\n",
       "}\n",
       "\n",
       ".hreprt-str {\n",
       "\tcolor: #666;\n",
       "\twhite-space: pre-wrap;\n",
       "}\n",
       "\n",
       ".hreprt-str:before {\n",
       "\tcontent: \"“\";\n",
       "\tcolor: #888;\n",
       "}\n",
       "\n",
       ".hreprt-str:after {\n",
       "\tcontent: \"”\";\n",
       "\tcolor: #888;\n",
       "}\n",
       "\n",
       ".hreprt-bytes {\n",
       "\tcolor: #666;\n",
       "\tfont-family: monospace;\n",
       "\twhite-space: pre-wrap;\n",
       "}\n",
       "\n",
       ".hreprt-bytes:before {\n",
       "\tcontent: \"b“\";\n",
       "}\n",
       "\n",
       ".hreprt-bytes:after {\n",
       "\tcontent: \"”\";\n",
       "}\n",
       "\n",
       ".hreprv-True {\n",
       "\tcolor: green;\n",
       "}\n",
       "\n",
       ".hreprv-False {\n",
       "\tcolor: red;\n",
       "}\n",
       "\n",
       ".hreprv-None {\n",
       "\tcolor: grey;\n",
       "}\n",
       "\n",
       ".hreprk-class > .hrepr-defn-key {\n",
       "\tcolor: blue;\n",
       "}\n",
       "\n",
       ".hreprk-module > .hrepr-defn-key {\n",
       "\tcolor: purple;\n",
       "}\n",
       "\n",
       ".hreprk-function > .hrepr-defn-key,\n",
       ".hreprk-builtin > .hrepr-defn-key,\n",
       ".hreprk-method > .hrepr-defn-key,\n",
       ".hreprk-descriptor > .hrepr-defn-key {\n",
       "\tcolor: #080;\n",
       "}\n",
       "\n",
       ".hrepr-defn-key {\n",
       "\tfont-weight: bold;\n",
       "}\n",
       "\n",
       "\n",
       "/* Generic layouts */\n",
       "\n",
       ".hreprl-h, .hreprl-s {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: row;\n",
       "\tflex-wrap: wrap;\n",
       "}\n",
       "\n",
       ".hreprl-v {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: column;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h,\n",
       ".hrepr-body.hreprl-v {\n",
       "\tgap: 4px;\n",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h {\n",
       "\talign-items: center;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-v > *,\n",
       ".hrepr-body.hreprl-h > * {\n",
       "\tbackground: white;\n",
       "\tdisplay: inline-flex;\n",
       "\tplace-items: center;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h > div > .hrepr-ellipsis,\n",
       ".hrepr-body.hreprl-v > div > .hrepr-ellipsis {\n",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h > div > .hrepr-ellipsis {\n",
       "\tpadding-left: 5px;\n",
       "\tpadding-right: 5px;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-v > div > .hrepr-ellipsis {\n",
       "\tpadding-top: 5px;\n",
       "\tpadding-bottom: 5px;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-s > * {\n",
       "\tpadding: 1px;\n",
       "}\n",
       "\n",
       ".hrepr-bracketed {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: row;\n",
       "\tplace-items: center;\n",
       "\tbackground: black;\n",
       "\tborder: var(--struct-border) solid black;\n",
       "\tbox-sizing: border-box;\n",
       "}\n",
       "\n",
       ".hrepr-bracketed > .hrepr-open {\n",
       "\tpadding-right: var(--struct-border);\n",
       "}\n",
       ".hrepr-bracketed > .hrepr-close {\n",
       "\tpadding-left: var(--struct-border);\n",
       "}\n",
       ".hrepr-bracketed > .hrepr-open,\n",
       ".hrepr-bracketed > .hrepr-close,\n",
       ".hrepr-instance > .hrepr-title,\n",
       ".hreprl-s {\n",
       "\tcolor: white;\n",
       "\tfont-weight: bold;\n",
       "}\n",
       "\n",
       ".hrepr-instance {\n",
       "\tbackground: var(--instance-color);\n",
       "\tborder: var(--struct-border) solid var(--instance-color);\n",
       "\tbox-sizing: border-box;\n",
       "}\n",
       ".hrepr-instance > .hrepr-title {\n",
       "\tcolor: white;\n",
       "\tfont-weight: bold;\n",
       "}\n",
       ".hrepr-instance.hreprl-v > .hrepr-title {\n",
       "\tpadding-bottom: var(--struct-border);\n",
       "}\n",
       ".hrepr-instance.hreprl-h > .hrepr-title,\n",
       ".hrepr-instance.hreprl-s > .hrepr-title {\n",
       "\tpadding-right: var(--struct-border);\n",
       "\tplace-self: center;\n",
       "}\n",
       ".hrepr-instance.hrepr-error {\n",
       "\tbackground: var(--error-color);\n",
       "\tborder: var(--struct-border) solid var(--error-color);\n",
       "}\n",
       "\n",
       "\n",
       "/* Colors for structures. */\n",
       "\n",
       ".hreprt-dict {\n",
       "\tbackground: var(--dict-color);\n",
       "\tborder-color: var(--dict-color);\n",
       "}\n",
       "\n",
       ".hreprt-list {\n",
       "\tbackground: var(--list-color);\n",
       "\tborder-color: var(--list-color);\n",
       "}\n",
       "\n",
       ".hreprt-tuple {\n",
       "\tbackground: var(--tuple-color);\n",
       "\tborder-color: var(--tuple-color);\n",
       "}\n",
       "\n",
       ".hreprt-set {\n",
       "\tbackground: var(--set-color);\n",
       "\tborder-color: var(--set-color);\n",
       "}\n",
       "\n",
       ".hreprt-frozenset {\n",
       "\tbackground: var(--frozenset-color);\n",
       "\tborder-color: var(--frozenset-color);\n",
       "}\n",
       "\n",
       "table.hrepr-body {\n",
       "\tborder-collapse: collapse;\n",
       "\twidth: 100%;\n",
       "}\n",
       "\n",
       "table.hrepr-body > tbody > tr:nth-child(even) {\n",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       "table.hrepr-body > tbody > tr:nth-child(odd) {\n",
       "\tbackground: #fff;\n",
       "}\n",
       "\n",
       "\n",
       "/* References */\n",
       "\n",
       ".hrepr-ref {\n",
       "\tfont-weight: bold;\n",
       "\tcolor: magenta;\n",
       "}\n",
       "\n",
       ".hrepr-refbox {\n",
       "\tdisplay: inline-flex;\n",
       "\tposition: relative;\n",
       "\tplace-items: center;\n",
       "}\n",
       "</style><div class=\"hrepr\"><div class=\"hrepr-instance hreprl-v hreprt-person\"><div class=\"hrepr-title\">Alice</div><table class=\"hrepr-body\"><tr><td><span class=\"hreprt-symbol\">age</span></td><td><span class=\"hrepr-delim\"> ↦ </span></td><td><span class=\"hreprt-int\">46</span></td></tr><tr><td><span class=\"hreprt-symbol\">job</span></td><td><span class=\"hrepr-delim\"> ↦ </span></td><td><span class=\"hreprt-str\">chef</span></td></tr></table></div></div></div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div><style>/*\n",
       " * Override Jupyter's default css inside elements with the hrepr class.\n",
       " */\n",
       "\n",
       ".rendered_html .hrepr table {\n",
       "\tmargin-top: 0px;\n",
       "\tmargin-bottom: 0px;\n",
       "\ttable-layout: auto;\n",
       "}\n",
       "\n",
       ".rendered_html tr, .rendered_html th, .rendered_html td {\n",
       "\tpadding: 2px;\n",
       "\ttext-align: left;\n",
       "}\n",
       "</style><style>\n",
       "            .person { background: magenta !important; border-color: magenta !important;  }\n",
       "            .person-short { font-weight: bold; color: green; }\n",
       "        </style><style>\n",
       ":root, :host {\n",
       "\t--instance-color: #00a;\n",
       "\t--dict-color: #00a;\n",
       "\t--tuple-color: #080;\n",
       "\t--list-color: #080;\n",
       "\t--set-color: #080;\n",
       "\t--frozenset-color: #88f;\n",
       "\t--error-color: #f00;\n",
       "\t--struct-border: 2px;\n",
       "}\n",
       "\n",
       "/* Scalar/string formatting */\n",
       "\n",
       ".hreprv-True, .hreprv-False, .hreprv-None, .hreprt-int, .hreprt-float {\n",
       "\tfont-weight: bold;\n",
       "}\n",
       "\n",
       ".hreprt-int, .hreprt-float {\n",
       "\tcolor: #88f;\n",
       "}\n",
       "\n",
       ".hreprt-str {\n",
       "\tcolor: #666;\n",
       "\twhite-space: pre-wrap;\n",
       "}\n",
       "\n",
       ".hreprt-str:before {\n",
       "\tcontent: \"“\";\n",
       "\tcolor: #888;\n",
       "}\n",
       "\n",
       ".hreprt-str:after {\n",
       "\tcontent: \"”\";\n",
       "\tcolor: #888;\n",
       "}\n",
       "\n",
       ".hreprt-bytes {\n",
       "\tcolor: #666;\n",
       "\tfont-family: monospace;\n",
       "\twhite-space: pre-wrap;\n",
       "}\n",
       "\n",
       ".hreprt-bytes:before {\n",
       "\tcontent: \"b“\";\n",
       "}\n",
       "\n",
       ".hreprt-bytes:after {\n",
       "\tcontent: \"”\";\n",
       "}\n",
       "\n",
       ".hreprv-True {\n",
       "\tcolor: green;\n",
       "}\n",
       "\n",
       ".hreprv-False {\n",
       "\tcolor: red;\n",
       "}\n",
       "\n",
       ".hreprv-None {\n",
       "\tcolor: grey;\n",
       "}\n",
       "\n",
       ".hreprk-class > .hrepr-defn-key {\n",
       "\tcolor: blue;\n",
       "}\n",
       "\n",
       ".hreprk-module > .hrepr-defn-key {\n",
       "\tcolor: purple;\n",
       "}\n",
       "\n",
       ".hreprk-function > .hrepr-defn-key,\n",
       ".hreprk-builtin > .hrepr-defn-key,\n",
       ".hreprk-method > .hrepr-defn-key,\n",
       ".hreprk-descriptor > .hrepr-defn-key {\n",
       "\tcolor: #080;\n",
       "}\n",
       "\n",
       ".hrepr-defn-key {\n",
       "\tfont-weight: bold;\n",
       "}\n",
       "\n",
       "\n",
       "/* Generic layouts */\n",
       "\n",
       ".hreprl-h, .hreprl-s {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: row;\n",
       "\tflex-wrap: wrap;\n",
       "}\n",
       "\n",
       ".hreprl-v {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: column;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h,\n",
       ".hrepr-body.hreprl-v {\n",
       "\tgap: 4px;\n",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h {\n",
       "\talign-items: center;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-v > *,\n",
       ".hrepr-body.hreprl-h > * {\n",
       "\tbackground: white;\n",
       "\tdisplay: inline-flex;\n",
       "\tplace-items: center;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h > div > .hrepr-ellipsis,\n",
       ".hrepr-body.hreprl-v > div > .hrepr-ellipsis {\n",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h > div > .hrepr-ellipsis {\n",
       "\tpadding-left: 5px;\n",
       "\tpadding-right: 5px;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-v > div > .hrepr-ellipsis {\n",
       "\tpadding-top: 5px;\n",
       "\tpadding-bottom: 5px;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-s > * {\n",
       "\tpadding: 1px;\n",
       "}\n",
       "\n",
       ".hrepr-bracketed {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: row;\n",
       "\tplace-items: center;\n",
       "\tbackground: black;\n",
       "\tborder: var(--struct-border) solid black;\n",
       "\tbox-sizing: border-box;\n",
       "}\n",
       "\n",
       ".hrepr-bracketed > .hrepr-open {\n",
       "\tpadding-right: var(--struct-border);\n",
       "}\n",
       ".hrepr-bracketed > .hrepr-close {\n",
       "\tpadding-left: var(--struct-border);\n",
       "}\n",
       ".hrepr-bracketed > .hrepr-open,\n",
       ".hrepr-bracketed > .hrepr-close,\n",
       ".hrepr-instance > .hrepr-title,\n",
       ".hreprl-s {\n",
       "\tcolor: white;\n",
       "\tfont-weight: bold;\n",
       "}\n",
       "\n",
       ".hrepr-instance {\n",
       "\tbackground: var(--instance-color);\n",
       "\tborder: var(--struct-border) solid var(--instance-color);\n",
       "\tbox-sizing: border-box;\n",
       "}\n",
       ".hrepr-instance > .hrepr-title {\n",
       "\tcolor: white;\n",
       "\tfont-weight: bold;\n",
       "}\n",
       ".hrepr-instance.hreprl-v > .hrepr-title {\n",
       "\tpadding-bottom: var(--struct-border);\n",
       "}\n",
       ".hrepr-instance.hreprl-h > .hrepr-title,\n",
       ".hrepr-instance.hreprl-s > .hrepr-title {\n",
       "\tpadding-right: var(--struct-border);\n",
       "\tplace-self: center;\n",
       "}\n",
       ".hrepr-instance.hrepr-error {\n",
       "\tbackground: var(--error-color);\n",
       "\tborder: var(--struct-border) solid var(--error-color);\n",
       "}\n",
       "\n",
       "\n",
       "/* Colors for structures. */\n",
       "\n",
       ".hreprt-dict {\n",
       "\tbackground: var(--dict-color);\n",
       "\tborder-color: var(--dict-color);\n",
       "}\n",
       "\n",
       ".hreprt-list {\n",
       "\tbackground: var(--list-color);\n",
       "\tborder-color: var(--list-color);\n",
       "}\n",
       "\n",
       ".hreprt-tuple {\n",
       "\tbackground: var(--tuple-color);\n",
       "\tborder-color: var(--tuple-color);\n",
       "}\n",
       "\n",
       ".hreprt-set {\n",
       "\tbackground: var(--set-color);\n",
       "\tborder-color: var(--set-color);\n",
       "}\n",
       "\n",
       ".hreprt-frozenset {\n",
       "\tbackground: var(--frozenset-color);\n",
       "\tborder-color: var(--frozenset-color);\n",
       "}\n",
       "\n",
       "table.hrepr-body {\n",
       "\tborder-collapse: collapse;\n",
       "\twidth: 100%;\n",
       "}\n",
       "\n",
       "table.hrepr-body > tbody > tr:nth-child(even) {\n",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       "table.hrepr-body > tbody > tr:nth-child(odd) {\n",
       "\tbackground: #fff;\n",
       "}\n",
       "\n",
       "\n",
       "/* References */\n",
       "\n",
       ".hrepr-ref {\n",
       "\tfont-weight: bold;\n",
       "\tcolor: magenta;\n",
       "}\n",
       "\n",
       ".hrepr-refbox {\n",
       "\tdisplay: inline-flex;\n",
       "\tposition: relative;\n",
       "\tplace-items: center;\n",
       "}\n",
       "</style><div class=\"hrepr\"><atom class=\"person-short\">Alice</atom></div></div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Another custom class example\n",
    "from IPython.display import display_html\n",
    "\n",
    "class Person:\n",
    "    def __init__(self, name, age, job):\n",
    "        self.name = name\n",
    "        self.age = age\n",
    "        self.job = job\n",
    "\n",
    "    @classmethod\n",
    "    def __hrepr_resources__(cls, H):\n",
    "        # Loaded only once for all instances of the class. Use this classmethod to\n",
    "        # define custom styles and load scripts or JavaScript libraries. You can return\n",
    "        # a list of resources.\n",
    "        # Note: you might need to add \"!important\" next to some rules if they conflict\n",
    "        # with defaults from hrepr's own CSS.\n",
    "        return H.style(\"\"\"\n",
    "            .person { background: magenta !important; border-color: magenta !important;  }\n",
    "            .person-short { font-weight: bold; color: green; }\n",
    "        \"\"\")\n",
    "\n",
    "    def __hrepr__(self, H, hrepr):\n",
    "        # hrepr.make.instance is a helper to show a table with a header that\n",
    "        # describes some kind of object\n",
    "        return hrepr.make.instance(\n",
    "            title=self.name,\n",
    "            fields=[[\"age\", self.age], [\"job\", self.job]],\n",
    "            delimiter=\" ↦ \",\n",
    "            type=\"person\",\n",
    "        )\n",
    "\n",
    "    def __hrepr_short__(self, H, hrepr):\n",
    "        # This method is called when we hit the depth limit. It should produce an HTML\n",
    "        # element with a small size, ideally constant. Do NOT render instance members\n",
    "        # like age or job here: short means short.\n",
    "        # H.atom is really mostly like H.span, but the textual representation of H.atom(x)\n",
    "        # through pprint is \"x\" whereas H.span(x) would be \"<span>x</span>\".\n",
    "        return H.atom[\"person-short\"](self.name)\n",
    "\n",
    "alice = Person('Alice', 46, 'chef')\n",
    "\n",
    "# Triggers __hrepr__\n",
    "display_html(hrepr(alice))\n",
    "\n",
    "# Triggers __hrepr_short__ at given depth\n",
    "display_html(hrepr(alice, max_depth=0))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>/*\n",
       " * Override Jupyter's default css inside elements with the hrepr class.\n",
       " */\n",
       "\n",
       ".rendered_html .hrepr table {\n",
       "\tmargin-top: 0px;\n",
       "\tmargin-bottom: 0px;\n",
       "\ttable-layout: auto;\n",
       "}\n",
       "\n",
       ".rendered_html tr, .rendered_html th, .rendered_html td {\n",
       "\tpadding: 2px;\n",
       "\ttext-align: left;\n",
       "}\n",
       "</style><style>\n",
       ":root, :host {\n",
       "\t--instance-color: #00a;\n",
       "\t--dict-color: #00a;\n",
       "\t--tuple-color: #080;\n",
       "\t--list-color: #080;\n",
       "\t--set-color: #080;\n",
       "\t--frozenset-color: #88f;\n",
       "\t--error-color: #f00;\n",
       "\t--struct-border: 2px;\n",
       "}\n",
       "\n",
       "/* Scalar/string formatting */\n",
       "\n",
       ".hreprv-True, .hreprv-False, .hreprv-None, .hreprt-int, .hreprt-float {\n",
       "\tfont-weight: bold;\n",
       "}\n",
       "\n",
       ".hreprt-int, .hreprt-float {\n",
       "\tcolor: #88f;\n",
       "}\n",
       "\n",
       ".hreprt-str {\n",
       "\tcolor: #666;\n",
       "\twhite-space: pre-wrap;\n",
       "}\n",
       "\n",
       ".hreprt-str:before {\n",
       "\tcontent: \"“\";\n",
       "\tcolor: #888;\n",
       "}\n",
       "\n",
       ".hreprt-str:after {\n",
       "\tcontent: \"”\";\n",
       "\tcolor: #888;\n",
       "}\n",
       "\n",
       ".hreprt-bytes {\n",
       "\tcolor: #666;\n",
       "\tfont-family: monospace;\n",
       "\twhite-space: pre-wrap;\n",
       "}\n",
       "\n",
       ".hreprt-bytes:before {\n",
       "\tcontent: \"b“\";\n",
       "}\n",
       "\n",
       ".hreprt-bytes:after {\n",
       "\tcontent: \"”\";\n",
       "}\n",
       "\n",
       ".hreprv-True {\n",
       "\tcolor: green;\n",
       "}\n",
       "\n",
       ".hreprv-False {\n",
       "\tcolor: red;\n",
       "}\n",
       "\n",
       ".hreprv-None {\n",
       "\tcolor: grey;\n",
       "}\n",
       "\n",
       ".hreprk-class > .hrepr-defn-key {\n",
       "\tcolor: blue;\n",
       "}\n",
       "\n",
       ".hreprk-module > .hrepr-defn-key {\n",
       "\tcolor: purple;\n",
       "}\n",
       "\n",
       ".hreprk-function > .hrepr-defn-key,\n",
       ".hreprk-builtin > .hrepr-defn-key,\n",
       ".hreprk-method > .hrepr-defn-key,\n",
       ".hreprk-descriptor > .hrepr-defn-key {\n",
       "\tcolor: #080;\n",
       "}\n",
       "\n",
       ".hrepr-defn-key {\n",
       "\tfont-weight: bold;\n",
       "}\n",
       "\n",
       "\n",
       "/* Generic layouts */\n",
       "\n",
       ".hreprl-h, .hreprl-s {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: row;\n",
       "\tflex-wrap: wrap;\n",
       "}\n",
       "\n",
       ".hreprl-v {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: column;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h,\n",
       ".hrepr-body.hreprl-v {\n",
       "\tgap: 4px;\n",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h {\n",
       "\talign-items: center;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-v > *,\n",
       ".hrepr-body.hreprl-h > * {\n",
       "\tbackground: white;\n",
       "\tdisplay: inline-flex;\n",
       "\tplace-items: center;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h > div > .hrepr-ellipsis,\n",
       ".hrepr-body.hreprl-v > div > .hrepr-ellipsis {\n",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h > div > .hrepr-ellipsis {\n",
       "\tpadding-left: 5px;\n",
       "\tpadding-right: 5px;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-v > div > .hrepr-ellipsis {\n",
       "\tpadding-top: 5px;\n",
       "\tpadding-bottom: 5px;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-s > * {\n",
       "\tpadding: 1px;\n",
       "}\n",
       "\n",
       ".hrepr-bracketed {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: row;\n",
       "\tplace-items: center;\n",
       "\tbackground: black;\n",
       "\tborder: var(--struct-border) solid black;\n",
       "\tbox-sizing: border-box;\n",
       "}\n",
       "\n",
       ".hrepr-bracketed > .hrepr-open {\n",
       "\tpadding-right: var(--struct-border);\n",
       "}\n",
       ".hrepr-bracketed > .hrepr-close {\n",
       "\tpadding-left: var(--struct-border);\n",
       "}\n",
       ".hrepr-bracketed > .hrepr-open,\n",
       ".hrepr-bracketed > .hrepr-close,\n",
       ".hrepr-instance > .hrepr-title,\n",
       ".hreprl-s {\n",
       "\tcolor: white;\n",
       "\tfont-weight: bold;\n",
       "}\n",
       "\n",
       ".hrepr-instance {\n",
       "\tbackground: var(--instance-color);\n",
       "\tborder: var(--struct-border) solid var(--instance-color);\n",
       "\tbox-sizing: border-box;\n",
       "}\n",
       ".hrepr-instance > .hrepr-title {\n",
       "\tcolor: white;\n",
       "\tfont-weight: bold;\n",
       "}\n",
       ".hrepr-instance.hreprl-v > .hrepr-title {\n",
       "\tpadding-bottom: var(--struct-border);\n",
       "}\n",
       ".hrepr-instance.hreprl-h > .hrepr-title,\n",
       ".hrepr-instance.hreprl-s > .hrepr-title {\n",
       "\tpadding-right: var(--struct-border);\n",
       "\tplace-self: center;\n",
       "}\n",
       ".hrepr-instance.hrepr-error {\n",
       "\tbackground: var(--error-color);\n",
       "\tborder: var(--struct-border) solid var(--error-color);\n",
       "}\n",
       "\n",
       "\n",
       "/* Colors for structures. */\n",
       "\n",
       ".hreprt-dict {\n",
       "\tbackground: var(--dict-color);\n",
       "\tborder-color: var(--dict-color);\n",
       "}\n",
       "\n",
       ".hreprt-list {\n",
       "\tbackground: var(--list-color);\n",
       "\tborder-color: var(--list-color);\n",
       "}\n",
       "\n",
       ".hreprt-tuple {\n",
       "\tbackground: var(--tuple-color);\n",
       "\tborder-color: var(--tuple-color);\n",
       "}\n",
       "\n",
       ".hreprt-set {\n",
       "\tbackground: var(--set-color);\n",
       "\tborder-color: var(--set-color);\n",
       "}\n",
       "\n",
       ".hreprt-frozenset {\n",
       "\tbackground: var(--frozenset-color);\n",
       "\tborder-color: var(--frozenset-color);\n",
       "}\n",
       "\n",
       "table.hrepr-body {\n",
       "\tborder-collapse: collapse;\n",
       "\twidth: 100%;\n",
       "}\n",
       "\n",
       "table.hrepr-body > tbody > tr:nth-child(even) {\n",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       "table.hrepr-body > tbody > tr:nth-child(odd) {\n",
       "\tbackground: #fff;\n",
       "}\n",
       "\n",
       "\n",
       "/* References */\n",
       "\n",
       ".hrepr-ref {\n",
       "\tfont-weight: bold;\n",
       "\tcolor: magenta;\n",
       "}\n",
       "\n",
       ".hrepr-refbox {\n",
       "\tdisplay: inline-flex;\n",
       "\tposition: relative;\n",
       "\tplace-items: center;\n",
       "}\n",
       "</style><div class=\"hrepr\"><div class=\"hrepr-refbox\"><span class=\"hrepr-ref\">#1=</span><div class=\"hreprt-list hrepr-bracketed\"><div class=\"hrepr-open\">[</div><div class=\"hreprl-h hrepr-body\"><div><span class=\"hreprt-int\">1</span></div><div><span class=\"hreprt-int\">2</span></div><div><span class=\"hreprt-int\">3</span></div><div><div class=\"hrepr-refbox\"><span class=\"hrepr-ref\">⟳1=</span><div class=\"hreprt-list hrepr-bracketed\"><div class=\"hrepr-open\">[</div><div class=\"hreprl-s hrepr-body\"><div>...</div></div><div class=\"hrepr-close\">]</div></div></div></div></div><div class=\"hrepr-close\">]</div></div></div></div></div>"
      ],
      "text/plain": [
       "<div class=\"hrepr-refbox\"><span class=\"hrepr-ref\">#1=</span><div class=\"hreprt-list hrepr-bracketed\"><div class=\"hrepr-open\">[</div><div class=\"hreprl-h hrepr-body\"><div><span class=\"hreprt-int\">1</span></div><div><span class=\"hreprt-int\">2</span></div><div><span class=\"hreprt-int\">3</span></div><div><div class=\"hrepr-refbox\"><span class=\"hrepr-ref\">⟳1=</span><div class=\"hreprt-list hrepr-bracketed\"><div class=\"hrepr-open\">[</div><div class=\"hreprl-s hrepr-body\"><div>...</div></div><div class=\"hrepr-close\">]</div></div></div></div></div><div class=\"hrepr-close\">]</div></div></div>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Circular references: hrepr keeps track of circular references and displays\n",
    "# them in a special way.\n",
    "\n",
    "li = [1, 2, 3]\n",
    "li.append(li)\n",
    "hrepr(li)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>/*\n",
       " * Override Jupyter's default css inside elements with the hrepr class.\n",
       " */\n",
       "\n",
       ".rendered_html .hrepr table {\n",
       "\tmargin-top: 0px;\n",
       "\tmargin-bottom: 0px;\n",
       "\ttable-layout: auto;\n",
       "}\n",
       "\n",
       ".rendered_html tr, .rendered_html th, .rendered_html td {\n",
       "\tpadding: 2px;\n",
       "\ttext-align: left;\n",
       "}\n",
       "</style><div class=\"hrepr\"><h4>Normal</h4></div></div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div><style>/*\n",
       " * Override Jupyter's default css inside elements with the hrepr class.\n",
       " */\n",
       "\n",
       ".rendered_html .hrepr table {\n",
       "\tmargin-top: 0px;\n",
       "\tmargin-bottom: 0px;\n",
       "\ttable-layout: auto;\n",
       "}\n",
       "\n",
       ".rendered_html tr, .rendered_html th, .rendered_html td {\n",
       "\tpadding: 2px;\n",
       "\ttext-align: left;\n",
       "}\n",
       "</style><style>\n",
       ":root, :host {\n",
       "\t--instance-color: #00a;\n",
       "\t--dict-color: #00a;\n",
       "\t--tuple-color: #080;\n",
       "\t--list-color: #080;\n",
       "\t--set-color: #080;\n",
       "\t--frozenset-color: #88f;\n",
       "\t--error-color: #f00;\n",
       "\t--struct-border: 2px;\n",
       "}\n",
       "\n",
       "/* Scalar/string formatting */\n",
       "\n",
       ".hreprv-True, .hreprv-False, .hreprv-None, .hreprt-int, .hreprt-float {\n",
       "\tfont-weight: bold;\n",
       "}\n",
       "\n",
       ".hreprt-int, .hreprt-float {\n",
       "\tcolor: #88f;\n",
       "}\n",
       "\n",
       ".hreprt-str {\n",
       "\tcolor: #666;\n",
       "\twhite-space: pre-wrap;\n",
       "}\n",
       "\n",
       ".hreprt-str:before {\n",
       "\tcontent: \"“\";\n",
       "\tcolor: #888;\n",
       "}\n",
       "\n",
       ".hreprt-str:after {\n",
       "\tcontent: \"”\";\n",
       "\tcolor: #888;\n",
       "}\n",
       "\n",
       ".hreprt-bytes {\n",
       "\tcolor: #666;\n",
       "\tfont-family: monospace;\n",
       "\twhite-space: pre-wrap;\n",
       "}\n",
       "\n",
       ".hreprt-bytes:before {\n",
       "\tcontent: \"b“\";\n",
       "}\n",
       "\n",
       ".hreprt-bytes:after {\n",
       "\tcontent: \"”\";\n",
       "}\n",
       "\n",
       ".hreprv-True {\n",
       "\tcolor: green;\n",
       "}\n",
       "\n",
       ".hreprv-False {\n",
       "\tcolor: red;\n",
       "}\n",
       "\n",
       ".hreprv-None {\n",
       "\tcolor: grey;\n",
       "}\n",
       "\n",
       ".hreprk-class > .hrepr-defn-key {\n",
       "\tcolor: blue;\n",
       "}\n",
       "\n",
       ".hreprk-module > .hrepr-defn-key {\n",
       "\tcolor: purple;\n",
       "}\n",
       "\n",
       ".hreprk-function > .hrepr-defn-key,\n",
       ".hreprk-builtin > .hrepr-defn-key,\n",
       ".hreprk-method > .hrepr-defn-key,\n",
       ".hreprk-descriptor > .hrepr-defn-key {\n",
       "\tcolor: #080;\n",
       "}\n",
       "\n",
       ".hrepr-defn-key {\n",
       "\tfont-weight: bold;\n",
       "}\n",
       "\n",
       "\n",
       "/* Generic layouts */\n",
       "\n",
       ".hreprl-h, .hreprl-s {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: row;\n",
       "\tflex-wrap: wrap;\n",
       "}\n",
       "\n",
       ".hreprl-v {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: column;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h,\n",
       ".hrepr-body.hreprl-v {\n",
       "\tgap: 4px;\n",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h {\n",
       "\talign-items: center;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-v > *,\n",
       ".hrepr-body.hreprl-h > * {\n",
       "\tbackground: white;\n",
       "\tdisplay: inline-flex;\n",
       "\tplace-items: center;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h > div > .hrepr-ellipsis,\n",
       ".hrepr-body.hreprl-v > div > .hrepr-ellipsis {\n",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h > div > .hrepr-ellipsis {\n",
       "\tpadding-left: 5px;\n",
       "\tpadding-right: 5px;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-v > div > .hrepr-ellipsis {\n",
       "\tpadding-top: 5px;\n",
       "\tpadding-bottom: 5px;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-s > * {\n",
       "\tpadding: 1px;\n",
       "}\n",
       "\n",
       ".hrepr-bracketed {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: row;\n",
       "\tplace-items: center;\n",
       "\tbackground: black;\n",
       "\tborder: var(--struct-border) solid black;\n",
       "\tbox-sizing: border-box;\n",
       "}\n",
       "\n",
       ".hrepr-bracketed > .hrepr-open {\n",
       "\tpadding-right: var(--struct-border);\n",
       "}\n",
       ".hrepr-bracketed > .hrepr-close {\n",
       "\tpadding-left: var(--struct-border);\n",
       "}\n",
       ".hrepr-bracketed > .hrepr-open,\n",
       ".hrepr-bracketed > .hrepr-close,\n",
       ".hrepr-instance > .hrepr-title,\n",
       ".hreprl-s {\n",
       "\tcolor: white;\n",
       "\tfont-weight: bold;\n",
       "}\n",
       "\n",
       ".hrepr-instance {\n",
       "\tbackground: var(--instance-color);\n",
       "\tborder: var(--struct-border) solid var(--instance-color);\n",
       "\tbox-sizing: border-box;\n",
       "}\n",
       ".hrepr-instance > .hrepr-title {\n",
       "\tcolor: white;\n",
       "\tfont-weight: bold;\n",
       "}\n",
       ".hrepr-instance.hreprl-v > .hrepr-title {\n",
       "\tpadding-bottom: var(--struct-border);\n",
       "}\n",
       ".hrepr-instance.hreprl-h > .hrepr-title,\n",
       ".hrepr-instance.hreprl-s > .hrepr-title {\n",
       "\tpadding-right: var(--struct-border);\n",
       "\tplace-self: center;\n",
       "}\n",
       ".hrepr-instance.hrepr-error {\n",
       "\tbackground: var(--error-color);\n",
       "\tborder: var(--struct-border) solid var(--error-color);\n",
       "}\n",
       "\n",
       "\n",
       "/* Colors for structures. */\n",
       "\n",
       ".hreprt-dict {\n",
       "\tbackground: var(--dict-color);\n",
       "\tborder-color: var(--dict-color);\n",
       "}\n",
       "\n",
       ".hreprt-list {\n",
       "\tbackground: var(--list-color);\n",
       "\tborder-color: var(--list-color);\n",
       "}\n",
       "\n",
       ".hreprt-tuple {\n",
       "\tbackground: var(--tuple-color);\n",
       "\tborder-color: var(--tuple-color);\n",
       "}\n",
       "\n",
       ".hreprt-set {\n",
       "\tbackground: var(--set-color);\n",
       "\tborder-color: var(--set-color);\n",
       "}\n",
       "\n",
       ".hreprt-frozenset {\n",
       "\tbackground: var(--frozenset-color);\n",
       "\tborder-color: var(--frozenset-color);\n",
       "}\n",
       "\n",
       "table.hrepr-body {\n",
       "\tborder-collapse: collapse;\n",
       "\twidth: 100%;\n",
       "}\n",
       "\n",
       "table.hrepr-body > tbody > tr:nth-child(even) {\n",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       "table.hrepr-body > tbody > tr:nth-child(odd) {\n",
       "\tbackground: #fff;\n",
       "}\n",
       "\n",
       "\n",
       "/* References */\n",
       "\n",
       ".hrepr-ref {\n",
       "\tfont-weight: bold;\n",
       "\tcolor: magenta;\n",
       "}\n",
       "\n",
       ".hrepr-refbox {\n",
       "\tdisplay: inline-flex;\n",
       "\tposition: relative;\n",
       "\tplace-items: center;\n",
       "}\n",
       "</style><style>\n",
       "            .person { background: magenta !important; border-color: magenta !important;  }\n",
       "            .person-short { font-weight: bold; color: green; }\n",
       "        </style><div class=\"hrepr\"><div class=\"hreprt-list hrepr-bracketed\"><div class=\"hrepr-open\">[</div><div class=\"hreprl-h hrepr-body\"><div><div class=\"hrepr-refbox\"><span class=\"hrepr-ref\">#1=</span><div class=\"hrepr-instance hreprl-v hreprt-person\"><div class=\"hrepr-title\">Alice</div><table class=\"hrepr-body\"><tr><td><span class=\"hreprt-symbol\">age</span></td><td><span class=\"hrepr-delim\"> ↦ </span></td><td><span class=\"hreprt-int\">46</span></td></tr><tr><td><span class=\"hreprt-symbol\">job</span></td><td><span class=\"hrepr-delim\"> ↦ </span></td><td><span class=\"hreprt-str\">chef</span></td></tr></table></div></div></div><div><div class=\"hrepr-refbox\"><span class=\"hrepr-ref\">#1=</span><atom class=\"person-short\">Alice</atom></div></div><div><div class=\"hrepr-refbox\"><span class=\"hrepr-ref\">#1=</span><atom class=\"person-short\">Alice</atom></div></div></div><div class=\"hrepr-close\">]</div></div></div></div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div><style>/*\n",
       " * Override Jupyter's default css inside elements with the hrepr class.\n",
       " */\n",
       "\n",
       ".rendered_html .hrepr table {\n",
       "\tmargin-top: 0px;\n",
       "\tmargin-bottom: 0px;\n",
       "\ttable-layout: auto;\n",
       "}\n",
       "\n",
       ".rendered_html tr, .rendered_html th, .rendered_html td {\n",
       "\tpadding: 2px;\n",
       "\ttext-align: left;\n",
       "}\n",
       "</style><div class=\"hrepr\"><h4>shortrefs=True</h4></div></div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div><style>/*\n",
       " * Override Jupyter's default css inside elements with the hrepr class.\n",
       " */\n",
       "\n",
       ".rendered_html .hrepr table {\n",
       "\tmargin-top: 0px;\n",
       "\tmargin-bottom: 0px;\n",
       "\ttable-layout: auto;\n",
       "}\n",
       "\n",
       ".rendered_html tr, .rendered_html th, .rendered_html td {\n",
       "\tpadding: 2px;\n",
       "\ttext-align: left;\n",
       "}\n",
       "</style><style>\n",
       ":root, :host {\n",
       "\t--instance-color: #00a;\n",
       "\t--dict-color: #00a;\n",
       "\t--tuple-color: #080;\n",
       "\t--list-color: #080;\n",
       "\t--set-color: #080;\n",
       "\t--frozenset-color: #88f;\n",
       "\t--error-color: #f00;\n",
       "\t--struct-border: 2px;\n",
       "}\n",
       "\n",
       "/* Scalar/string formatting */\n",
       "\n",
       ".hreprv-True, .hreprv-False, .hreprv-None, .hreprt-int, .hreprt-float {\n",
       "\tfont-weight: bold;\n",
       "}\n",
       "\n",
       ".hreprt-int, .hreprt-float {\n",
       "\tcolor: #88f;\n",
       "}\n",
       "\n",
       ".hreprt-str {\n",
       "\tcolor: #666;\n",
       "\twhite-space: pre-wrap;\n",
       "}\n",
       "\n",
       ".hreprt-str:before {\n",
       "\tcontent: \"“\";\n",
       "\tcolor: #888;\n",
       "}\n",
       "\n",
       ".hreprt-str:after {\n",
       "\tcontent: \"”\";\n",
       "\tcolor: #888;\n",
       "}\n",
       "\n",
       ".hreprt-bytes {\n",
       "\tcolor: #666;\n",
       "\tfont-family: monospace;\n",
       "\twhite-space: pre-wrap;\n",
       "}\n",
       "\n",
       ".hreprt-bytes:before {\n",
       "\tcontent: \"b“\";\n",
       "}\n",
       "\n",
       ".hreprt-bytes:after {\n",
       "\tcontent: \"”\";\n",
       "}\n",
       "\n",
       ".hreprv-True {\n",
       "\tcolor: green;\n",
       "}\n",
       "\n",
       ".hreprv-False {\n",
       "\tcolor: red;\n",
       "}\n",
       "\n",
       ".hreprv-None {\n",
       "\tcolor: grey;\n",
       "}\n",
       "\n",
       ".hreprk-class > .hrepr-defn-key {\n",
       "\tcolor: blue;\n",
       "}\n",
       "\n",
       ".hreprk-module > .hrepr-defn-key {\n",
       "\tcolor: purple;\n",
       "}\n",
       "\n",
       ".hreprk-function > .hrepr-defn-key,\n",
       ".hreprk-builtin > .hrepr-defn-key,\n",
       ".hreprk-method > .hrepr-defn-key,\n",
       ".hreprk-descriptor > .hrepr-defn-key {\n",
       "\tcolor: #080;\n",
       "}\n",
       "\n",
       ".hrepr-defn-key {\n",
       "\tfont-weight: bold;\n",
       "}\n",
       "\n",
       "\n",
       "/* Generic layouts */\n",
       "\n",
       ".hreprl-h, .hreprl-s {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: row;\n",
       "\tflex-wrap: wrap;\n",
       "}\n",
       "\n",
       ".hreprl-v {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: column;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h,\n",
       ".hrepr-body.hreprl-v {\n",
       "\tgap: 4px;\n",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h {\n",
       "\talign-items: center;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-v > *,\n",
       ".hrepr-body.hreprl-h > * {\n",
       "\tbackground: white;\n",
       "\tdisplay: inline-flex;\n",
       "\tplace-items: center;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h > div > .hrepr-ellipsis,\n",
       ".hrepr-body.hreprl-v > div > .hrepr-ellipsis {\n",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h > div > .hrepr-ellipsis {\n",
       "\tpadding-left: 5px;\n",
       "\tpadding-right: 5px;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-v > div > .hrepr-ellipsis {\n",
       "\tpadding-top: 5px;\n",
       "\tpadding-bottom: 5px;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-s > * {\n",
       "\tpadding: 1px;\n",
       "}\n",
       "\n",
       ".hrepr-bracketed {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: row;\n",
       "\tplace-items: center;\n",
       "\tbackground: black;\n",
       "\tborder: var(--struct-border) solid black;\n",
       "\tbox-sizing: border-box;\n",
       "}\n",
       "\n",
       ".hrepr-bracketed > .hrepr-open {\n",
       "\tpadding-right: var(--struct-border);\n",
       "}\n",
       ".hrepr-bracketed > .hrepr-close {\n",
       "\tpadding-left: var(--struct-border);\n",
       "}\n",
       ".hrepr-bracketed > .hrepr-open,\n",
       ".hrepr-bracketed > .hrepr-close,\n",
       ".hrepr-instance > .hrepr-title,\n",
       ".hreprl-s {\n",
       "\tcolor: white;\n",
       "\tfont-weight: bold;\n",
       "}\n",
       "\n",
       ".hrepr-instance {\n",
       "\tbackground: var(--instance-color);\n",
       "\tborder: var(--struct-border) solid var(--instance-color);\n",
       "\tbox-sizing: border-box;\n",
       "}\n",
       ".hrepr-instance > .hrepr-title {\n",
       "\tcolor: white;\n",
       "\tfont-weight: bold;\n",
       "}\n",
       ".hrepr-instance.hreprl-v > .hrepr-title {\n",
       "\tpadding-bottom: var(--struct-border);\n",
       "}\n",
       ".hrepr-instance.hreprl-h > .hrepr-title,\n",
       ".hrepr-instance.hreprl-s > .hrepr-title {\n",
       "\tpadding-right: var(--struct-border);\n",
       "\tplace-self: center;\n",
       "}\n",
       ".hrepr-instance.hrepr-error {\n",
       "\tbackground: var(--error-color);\n",
       "\tborder: var(--struct-border) solid var(--error-color);\n",
       "}\n",
       "\n",
       "\n",
       "/* Colors for structures. */\n",
       "\n",
       ".hreprt-dict {\n",
       "\tbackground: var(--dict-color);\n",
       "\tborder-color: var(--dict-color);\n",
       "}\n",
       "\n",
       ".hreprt-list {\n",
       "\tbackground: var(--list-color);\n",
       "\tborder-color: var(--list-color);\n",
       "}\n",
       "\n",
       ".hreprt-tuple {\n",
       "\tbackground: var(--tuple-color);\n",
       "\tborder-color: var(--tuple-color);\n",
       "}\n",
       "\n",
       ".hreprt-set {\n",
       "\tbackground: var(--set-color);\n",
       "\tborder-color: var(--set-color);\n",
       "}\n",
       "\n",
       ".hreprt-frozenset {\n",
       "\tbackground: var(--frozenset-color);\n",
       "\tborder-color: var(--frozenset-color);\n",
       "}\n",
       "\n",
       "table.hrepr-body {\n",
       "\tborder-collapse: collapse;\n",
       "\twidth: 100%;\n",
       "}\n",
       "\n",
       "table.hrepr-body > tbody > tr:nth-child(even) {\n",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       "table.hrepr-body > tbody > tr:nth-child(odd) {\n",
       "\tbackground: #fff;\n",
       "}\n",
       "\n",
       "\n",
       "/* References */\n",
       "\n",
       ".hrepr-ref {\n",
       "\tfont-weight: bold;\n",
       "\tcolor: magenta;\n",
       "}\n",
       "\n",
       ".hrepr-refbox {\n",
       "\tdisplay: inline-flex;\n",
       "\tposition: relative;\n",
       "\tplace-items: center;\n",
       "}\n",
       "</style><style>\n",
       "            .person { background: magenta !important; border-color: magenta !important;  }\n",
       "            .person-short { font-weight: bold; color: green; }\n",
       "        </style><div class=\"hrepr\"><div class=\"hreprt-list hrepr-bracketed\"><div class=\"hrepr-open\">[</div><div class=\"hreprl-h hrepr-body\"><div><div class=\"hrepr-refbox\"><span class=\"hrepr-ref\">#1=</span><div class=\"hrepr-instance hreprl-v hreprt-person\"><div class=\"hrepr-title\">Alice</div><table class=\"hrepr-body\"><tr><td><span class=\"hreprt-symbol\">age</span></td><td><span class=\"hrepr-delim\"> ↦ </span></td><td><span class=\"hreprt-int\">46</span></td></tr><tr><td><span class=\"hreprt-symbol\">job</span></td><td><span class=\"hrepr-delim\"> ↦ </span></td><td><span class=\"hreprt-str\">chef</span></td></tr></table></div></div></div><div><span class=\"hrepr-ref\">#1</span></div><div><span class=\"hrepr-ref\">#1</span></div></div><div class=\"hrepr-close\">]</div></div></div></div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div><style>/*\n",
       " * Override Jupyter's default css inside elements with the hrepr class.\n",
       " */\n",
       "\n",
       ".rendered_html .hrepr table {\n",
       "\tmargin-top: 0px;\n",
       "\tmargin-bottom: 0px;\n",
       "\ttable-layout: auto;\n",
       "}\n",
       "\n",
       ".rendered_html tr, .rendered_html th, .rendered_html td {\n",
       "\tpadding: 2px;\n",
       "\ttext-align: left;\n",
       "}\n",
       "</style><div class=\"hrepr\"><h4>norefs=True</h4></div></div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div><style>/*\n",
       " * Override Jupyter's default css inside elements with the hrepr class.\n",
       " */\n",
       "\n",
       ".rendered_html .hrepr table {\n",
       "\tmargin-top: 0px;\n",
       "\tmargin-bottom: 0px;\n",
       "\ttable-layout: auto;\n",
       "}\n",
       "\n",
       ".rendered_html tr, .rendered_html th, .rendered_html td {\n",
       "\tpadding: 2px;\n",
       "\ttext-align: left;\n",
       "}\n",
       "</style><style>\n",
       ":root, :host {\n",
       "\t--instance-color: #00a;\n",
       "\t--dict-color: #00a;\n",
       "\t--tuple-color: #080;\n",
       "\t--list-color: #080;\n",
       "\t--set-color: #080;\n",
       "\t--frozenset-color: #88f;\n",
       "\t--error-color: #f00;\n",
       "\t--struct-border: 2px;\n",
       "}\n",
       "\n",
       "/* Scalar/string formatting */\n",
       "\n",
       ".hreprv-True, .hreprv-False, .hreprv-None, .hreprt-int, .hreprt-float {\n",
       "\tfont-weight: bold;\n",
       "}\n",
       "\n",
       ".hreprt-int, .hreprt-float {\n",
       "\tcolor: #88f;\n",
       "}\n",
       "\n",
       ".hreprt-str {\n",
       "\tcolor: #666;\n",
       "\twhite-space: pre-wrap;\n",
       "}\n",
       "\n",
       ".hreprt-str:before {\n",
       "\tcontent: \"“\";\n",
       "\tcolor: #888;\n",
       "}\n",
       "\n",
       ".hreprt-str:after {\n",
       "\tcontent: \"”\";\n",
       "\tcolor: #888;\n",
       "}\n",
       "\n",
       ".hreprt-bytes {\n",
       "\tcolor: #666;\n",
       "\tfont-family: monospace;\n",
       "\twhite-space: pre-wrap;\n",
       "}\n",
       "\n",
       ".hreprt-bytes:before {\n",
       "\tcontent: \"b“\";\n",
       "}\n",
       "\n",
       ".hreprt-bytes:after {\n",
       "\tcontent: \"”\";\n",
       "}\n",
       "\n",
       ".hreprv-True {\n",
       "\tcolor: green;\n",
       "}\n",
       "\n",
       ".hreprv-False {\n",
       "\tcolor: red;\n",
       "}\n",
       "\n",
       ".hreprv-None {\n",
       "\tcolor: grey;\n",
       "}\n",
       "\n",
       ".hreprk-class > .hrepr-defn-key {\n",
       "\tcolor: blue;\n",
       "}\n",
       "\n",
       ".hreprk-module > .hrepr-defn-key {\n",
       "\tcolor: purple;\n",
       "}\n",
       "\n",
       ".hreprk-function > .hrepr-defn-key,\n",
       ".hreprk-builtin > .hrepr-defn-key,\n",
       ".hreprk-method > .hrepr-defn-key,\n",
       ".hreprk-descriptor > .hrepr-defn-key {\n",
       "\tcolor: #080;\n",
       "}\n",
       "\n",
       ".hrepr-defn-key {\n",
       "\tfont-weight: bold;\n",
       "}\n",
       "\n",
       "\n",
       "/* Generic layouts */\n",
       "\n",
       ".hreprl-h, .hreprl-s {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: row;\n",
       "\tflex-wrap: wrap;\n",
       "}\n",
       "\n",
       ".hreprl-v {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: column;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h,\n",
       ".hrepr-body.hreprl-v {\n",
       "\tgap: 4px;\n",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h {\n",
       "\talign-items: center;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-v > *,\n",
       ".hrepr-body.hreprl-h > * {\n",
       "\tbackground: white;\n",
       "\tdisplay: inline-flex;\n",
       "\tplace-items: center;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h > div > .hrepr-ellipsis,\n",
       ".hrepr-body.hreprl-v > div > .hrepr-ellipsis {\n",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-h > div > .hrepr-ellipsis {\n",
       "\tpadding-left: 5px;\n",
       "\tpadding-right: 5px;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-v > div > .hrepr-ellipsis {\n",
       "\tpadding-top: 5px;\n",
       "\tpadding-bottom: 5px;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-s > * {\n",
       "\tpadding: 1px;\n",
       "}\n",
       "\n",
       ".hrepr-bracketed {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: row;\n",
       "\tplace-items: center;\n",
       "\tbackground: black;\n",
       "\tborder: var(--struct-border) solid black;\n",
       "\tbox-sizing: border-box;\n",
       "}\n",
       "\n",
       ".hrepr-bracketed > .hrepr-open {\n",
       "\tpadding-right: var(--struct-border);\n",
       "}\n",
       ".hrepr-bracketed > .hrepr-close {\n",
       "\tpadding-left: var(--struct-border);\n",
       "}\n",
       ".hrepr-bracketed > .hrepr-open,\n",
       ".hrepr-bracketed > .hrepr-close,\n",
       ".hrepr-instance > .hrepr-title,\n",
       ".hreprl-s {\n",
       "\tcolor: white;\n",
       "\tfont-weight: bold;\n",
       "}\n",
       "\n",
       ".hrepr-instance {\n",
       "\tbackground: var(--instance-color);\n",
       "\tborder: var(--struct-border) solid var(--instance-color);\n",
       "\tbox-sizing: border-box;\n",
       "}\n",
       ".hrepr-instance > .hrepr-title {\n",
       "\tcolor: white;\n",
       "\tfont-weight: bold;\n",
       "}\n",
       ".hrepr-instance.hreprl-v > .hrepr-title {\n",
       "\tpadding-bottom: var(--struct-border);\n",
       "}\n",
       ".hrepr-instance.hreprl-h > .hrepr-title,\n",
       ".hrepr-instance.hreprl-s > .hrepr-title {\n",
       "\tpadding-right: var(--struct-border);\n",
       "\tplace-self: center;\n",
       "}\n",
       ".hrepr-instance.hrepr-error {\n",
       "\tbackground: var(--error-color);\n",
       "\tborder: var(--struct-border) solid var(--error-color);\n",
       "}\n",
       "\n",
       "\n",
       "/* Colors for structures. */\n",
       "\n",
       ".hreprt-dict {\n",
       "\tbackground: var(--dict-color);\n",
       "\tborder-color: var(--dict-color);\n",
       "}\n",
       "\n",
       ".hreprt-list {\n",
       "\tbackground: var(--list-color);\n",
       "\tborder-color: var(--list-color);\n",
       "}\n",
       "\n",
       ".hreprt-tuple {\n",
       "\tbackground: var(--tuple-color);\n",
       "\tborder-color: var(--tuple-color);\n",
       "}\n",
       "\n",
       ".hreprt-set {\n",
       "\tbackground: var(--set-color);\n",
       "\tborder-color: var(--set-color);\n",
       "}\n",
       "\n",
       ".hreprt-frozenset {\n",
       "\tbackground: var(--frozenset-color);\n",
       "\tborder-color: var(--frozenset-color);\n",
       "}\n",
       "\n",
       "table.hrepr-body {\n",
       "\tborder-collapse: collapse;\n",
       "\twidth: 100%;\n",
       "}\n",
       "\n",
       "table.hrepr-body > tbody > tr:nth-child(even) {\n",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       "table.hrepr-body > tbody > tr:nth-child(odd) {\n",
       "\tbackground: #fff;\n",
       "}\n",
       "\n",
       "\n",
       "/* References */\n",
       "\n",
       ".hrepr-ref {\n",
       "\tfont-weight: bold;\n",
       "\tcolor: magenta;\n",
       "}\n",
       "\n",
       ".hrepr-refbox {\n",
       "\tdisplay: inline-flex;\n",
       "\tposition: relative;\n",
       "\tplace-items: center;\n",
       "}\n",
       "</style><style>\n",
       "            .person { background: magenta !important; border-color: magenta !important;  }\n",
       "            .person-short { font-weight: bold; color: green; }\n",
       "        </style><div class=\"hrepr\"><div class=\"hreprt-list hrepr-bracketed\"><div class=\"hrepr-open\">[</div><div class=\"hreprl-h hrepr-body\"><div><div class=\"hrepr-instance hreprl-v hreprt-person\"><div class=\"hrepr-title\">Alice</div><table class=\"hrepr-body\"><tr><td><span class=\"hreprt-symbol\">age</span></td><td><span class=\"hrepr-delim\"> ↦ </span></td><td><span class=\"hreprt-int\">46</span></td></tr><tr><td><span class=\"hreprt-symbol\">job</span></td><td><span class=\"hrepr-delim\"> ↦ </span></td><td><span class=\"hreprt-str\">chef</span></td></tr></table></div></div><div><div class=\"hrepr-instance hreprl-v hreprt-person\"><div class=\"hrepr-title\">Alice</div><table class=\"hrepr-body\"><tr><td><span class=\"hreprt-symbol\">age</span></td><td><span class=\"hrepr-delim\"> ↦ </span></td><td><span class=\"hreprt-int\">46</span></td></tr><tr><td><span class=\"hreprt-symbol\">job</span></td><td><span class=\"hrepr-delim\"> ↦ </span></td><td><span class=\"hreprt-str\">chef</span></td></tr></table></div></div><div><div class=\"hrepr-instance hreprl-v hreprt-person\"><div class=\"hrepr-title\">Alice</div><table class=\"hrepr-body\"><tr><td><span class=\"hreprt-symbol\">age</span></td><td><span class=\"hrepr-delim\"> ↦ </span></td><td><span class=\"hreprt-int\">46</span></td></tr><tr><td><span class=\"hreprt-symbol\">job</span></td><td><span class=\"hrepr-delim\"> ↦ </span></td><td><span class=\"hreprt-str\">chef</span></td></tr></table></div></div></div><div class=\"hrepr-close\">]</div></div></div></div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# By default, hrepr uses references to point out objects with the same id (that\n",
    "# is to say, objects that are such that `obj1 is obj2`, not merely equal ones).\n",
    "# Customize this behavior with shortrefs and norefs:\n",
    "\n",
    "display_html(H.h4(\"Normal\"), hrepr([alice, alice, alice]))\n",
    "display_html(H.h4(\"shortrefs=True\"), hrepr([alice, alice, alice], shortrefs=True))\n",
    "display_html(H.h4(\"norefs=True\"), hrepr([alice, alice, alice], norefs=True))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
