{
 "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--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;\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;\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",
       "/* 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",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-v > *,\n",
       ".hrepr-body.hreprl-h > * {\n",
       "\tmargin: 2px;\n",
       "\tpadding: 1px;\n",
       "\tbackground: white;\n",
       "\tdisplay: inline-flex;\n",
       "\tplace-items: center;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-s > * {\n",
       "\tpadding: 1px;\n",
       "}\n",
       "\n",
       ".hrepr-bracketed {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: row;\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",
       "}\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",
       "}\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",
       "\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\"><span class=\"hreprt-int\">123</span></div></div>"
      ],
      "text/plain": [
       "<span class=\"hreprt-int\">123</span>"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from hrepr import hrepr\n",
    "hrepr(123)"
   ]
  },
  {
   "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--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;\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;\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",
       "/* 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",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-v > *,\n",
       ".hrepr-body.hreprl-h > * {\n",
       "\tmargin: 2px;\n",
       "\tpadding: 1px;\n",
       "\tbackground: white;\n",
       "\tdisplay: inline-flex;\n",
       "\tplace-items: center;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-s > * {\n",
       "\tpadding: 1px;\n",
       "}\n",
       "\n",
       ".hrepr-bracketed {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: row;\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",
       "}\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",
       "}\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",
       "\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\">a</span></td><td class=\"hrepr-delim\">: </td><td><span class=\"hreprt-int\">1</span></td></tr><tr><td><span class=\"hreprt-str\">b</span></td><td class=\"hrepr-delim\">: </td><td><span class=\"hreprt-int\">2</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\">a</span></td><td class=\"hrepr-delim\">: </td><td><span class=\"hreprt-int\">1</span></td></tr><tr><td><span class=\"hreprt-str\">b</span></td><td class=\"hrepr-delim\">: </td><td><span class=\"hreprt-int\">2</span></td></tr></table><div class=\"hrepr-close\">}</div></div>"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hrepr({\"a\": 1, \"b\": 2})"
   ]
  },
  {
   "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--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;\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;\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",
       "/* 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",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-v > *,\n",
       ".hrepr-body.hreprl-h > * {\n",
       "\tmargin: 2px;\n",
       "\tpadding: 1px;\n",
       "\tbackground: white;\n",
       "\tdisplay: inline-flex;\n",
       "\tplace-items: center;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-s > * {\n",
       "\tpadding: 1px;\n",
       "}\n",
       "\n",
       ".hrepr-bracketed {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: row;\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",
       "}\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",
       "}\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",
       "\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\"><span class=\"hreprt-int\">123</span><span class=\"hreprt-int\">456</span></div></div>"
      ],
      "text/plain": [
       "<span class=\"hreprt-int\">123</span><span class=\"hreprt-int\">456</span>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hrepr(123, 456)"
   ]
  },
  {
   "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><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--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;\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;\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",
       "/* 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",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-v > *,\n",
       ".hrepr-body.hreprl-h > * {\n",
       "\tmargin: 2px;\n",
       "\tpadding: 1px;\n",
       "\tbackground: white;\n",
       "\tdisplay: inline-flex;\n",
       "\tplace-items: center;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-s > * {\n",
       "\tpadding: 1px;\n",
       "}\n",
       "\n",
       ".hrepr-bracketed {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: row;\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",
       "}\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",
       "}\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",
       "\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><span class=\"hreprt-int\">1</span></div><div><span class=\"hreprt-int\">2</span></div><div><span class=\"hreprt-int\">3</span></div><div><span class=\"hreprt-int\">4</span></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><span class=\"hreprt-int\">1</span></div><div><span class=\"hreprt-int\">2</span></div><div><span class=\"hreprt-int\">3</span></div><div><span class=\"hreprt-int\">4</span></div></div><div class=\"hrepr-close\">]</div></div>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hrepr([1, 2, 3, 4])"
   ]
  },
  {
   "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--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;\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;\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",
       "/* 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",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-v > *,\n",
       ".hrepr-body.hreprl-h > * {\n",
       "\tmargin: 2px;\n",
       "\tpadding: 1px;\n",
       "\tbackground: white;\n",
       "\tdisplay: inline-flex;\n",
       "\tplace-items: center;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-s > * {\n",
       "\tpadding: 1px;\n",
       "}\n",
       "\n",
       ".hrepr-bracketed {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: row;\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",
       "}\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",
       "}\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",
       "\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\"><span class=\"hreprs-range\">&lt;range&gt;</span></div></div>"
      ],
      "text/plain": [
       "<span class=\"hreprs-range\">&lt;range&gt;</span>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hrepr(range(10))"
   ]
  },
  {
   "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",
       ":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--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;\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;\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",
       "/* 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",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-v > *,\n",
       ".hrepr-body.hreprl-h > * {\n",
       "\tmargin: 2px;\n",
       "\tpadding: 1px;\n",
       "\tbackground: white;\n",
       "\tdisplay: inline-flex;\n",
       "\tplace-items: center;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-s > * {\n",
       "\tpadding: 1px;\n",
       "}\n",
       "\n",
       ".hrepr-bracketed {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: row;\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",
       "}\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",
       "}\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",
       "\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><span class=\"hreprt-str\">__bool__</span></div><div><span class=\"hreprt-str\">__class__</span></div><div><span class=\"hreprt-str\">__contains__</span></div><div><span class=\"hreprt-str\">__delattr__</span></div><div><span class=\"hreprt-str\">__dir__</span></div><div><span class=\"hreprt-str\">__doc__</span></div><div><span class=\"hreprt-str\">__eq__</span></div><div><span class=\"hreprt-str\">__format__</span></div><div><span class=\"hreprt-str\">__ge__</span></div><div><span class=\"hreprt-str\">__getattribute__</span></div><div><span class=\"hreprt-str\">__getitem__</span></div><div><span class=\"hreprt-str\">__gt__</span></div><div><span class=\"hreprt-str\">__hash__</span></div><div><span class=\"hreprt-str\">__init__</span></div><div><span class=\"hreprt-str\">__init_subclass__</span></div><div><span class=\"hreprt-str\">__iter__</span></div><div><span class=\"hreprt-str\">__le__</span></div><div><span class=\"hreprt-str\">__len__</span></div><div><span class=\"hreprt-str\">__lt__</span></div><div><span class=\"hreprt-str\">__ne__</span></div><div><span class=\"hreprt-str\">__new__</span></div><div><span class=\"hreprt-str\">__reduce__</span></div><div><span class=\"hreprt-str\">__reduce_ex__</span></div><div><span class=\"hreprt-str\">__repr__</span></div><div><span class=\"hreprt-str\">__reversed__</span></div><div><span class=\"hreprt-str\">__setattr__</span></div><div><span class=\"hreprt-str\">__sizeof__</span></div><div><span class=\"hreprt-str\">__str__</span></div><div><span class=\"hreprt-str\">__subclasshook__</span></div><div><span class=\"hreprt-str\">count</span></div><div><span class=\"hreprt-str\">index</span></div><div><span class=\"hreprt-str\">start</span></div><div><span class=\"hreprt-str\">step</span></div><div><span class=\"hreprt-str\">stop</span></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><span class=\"hreprt-str\">__bool__</span></div><div><span class=\"hreprt-str\">__class__</span></div><div><span class=\"hreprt-str\">__contains__</span></div><div><span class=\"hreprt-str\">__delattr__</span></div><div><span class=\"hreprt-str\">__dir__</span></div><div><span class=\"hreprt-str\">__doc__</span></div><div><span class=\"hreprt-str\">__eq__</span></div><div><span class=\"hreprt-str\">__format__</span></div><div><span class=\"hreprt-str\">__ge__</span></div><div><span class=\"hreprt-str\">__getattribute__</span></div><div><span class=\"hreprt-str\">__getitem__</span></div><div><span class=\"hreprt-str\">__gt__</span></div><div><span class=\"hreprt-str\">__hash__</span></div><div><span class=\"hreprt-str\">__init__</span></div><div><span class=\"hreprt-str\">__init_subclass__</span></div><div><span class=\"hreprt-str\">__iter__</span></div><div><span class=\"hreprt-str\">__le__</span></div><div><span class=\"hreprt-str\">__len__</span></div><div><span class=\"hreprt-str\">__lt__</span></div><div><span class=\"hreprt-str\">__ne__</span></div><div><span class=\"hreprt-str\">__new__</span></div><div><span class=\"hreprt-str\">__reduce__</span></div><div><span class=\"hreprt-str\">__reduce_ex__</span></div><div><span class=\"hreprt-str\">__repr__</span></div><div><span class=\"hreprt-str\">__reversed__</span></div><div><span class=\"hreprt-str\">__setattr__</span></div><div><span class=\"hreprt-str\">__sizeof__</span></div><div><span class=\"hreprt-str\">__str__</span></div><div><span class=\"hreprt-str\">__subclasshook__</span></div><div><span class=\"hreprt-str\">count</span></div><div><span class=\"hreprt-str\">index</span></div><div><span class=\"hreprt-str\">start</span></div><div><span class=\"hreprt-str\">step</span></div><div><span class=\"hreprt-str\">stop</span></div></div><div class=\"hrepr-close\">]</div></div>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hrepr(dir(range(10)))"
   ]
  },
  {
   "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--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;\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;\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",
       "/* 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",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-v > *,\n",
       ".hrepr-body.hreprl-h > * {\n",
       "\tmargin: 2px;\n",
       "\tpadding: 1px;\n",
       "\tbackground: white;\n",
       "\tdisplay: inline-flex;\n",
       "\tplace-items: center;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-s > * {\n",
       "\tpadding: 1px;\n",
       "}\n",
       "\n",
       ".hrepr-bracketed {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: row;\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",
       "}\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",
       "}\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",
       "\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\"><span class=\"hreprs-Exception\">&lt;Exception&gt;</span></div></div>"
      ],
      "text/plain": [
       "<span class=\"hreprs-Exception\">&lt;Exception&gt;</span>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hrepr(Exception(\"bah\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "from hrepr import hrepr\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",
    "        # Note: you might need to add \"!important\" next to some rules if\n",
    "        # they conflict with defaults from hrepr's own CSS.\n",
    "        return H.style(\"\"\"\n",
    "            .person {\n",
    "                background: magenta !important;\n",
    "                border-color: magenta !important;\n",
    "            }\n",
    "            .person-short { font-weight: bold; color: green; }\n",
    "        \"\"\")\n",
    "\n",
    "    def __hrepr__(self, H, hrepr):\n",
    "        # H.instance is a special kind of tag to format data like an instance.\n",
    "        # Notice how we call the hrepr parameter on self.age and self.job to\n",
    "        # format them.\n",
    "        return H.instance[\"person\"](\n",
    "            H.pair(\"age\", hrepr(self.age), delimiter=\" ↦ \"),\n",
    "            H.pair(\"job\", hrepr(self.job), delimiter=\" ↦ \"),\n",
    "            # The \"type\" represents the header for the \"instance\"\n",
    "            type=self.name,\n",
    "            # \"vertical=True\" means we'll display the pairs as a table with\n",
    "            # the delimiters aligned, instead of sticking them horizontally\n",
    "            # next to each other\n",
    "            vertical=True,\n",
    "        )\n",
    "\n",
    "    def __hrepr_short__(self, H, hrepr):\n",
    "        # H.atom is really mostly like H.span, but the textual representation\n",
    "        # of H.atom(x) through pprint is \"x\" whereas H.span(x) would be \n",
    "        # \"<span>x</span>\".\n",
    "        return H.atom[\"person-short\"](self.name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "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 {\n",
       "                background: magenta !important;\n",
       "                border-color: magenta !important;\n",
       "            }\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--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;\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;\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",
       "/* 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",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-v > *,\n",
       ".hrepr-body.hreprl-h > * {\n",
       "\tmargin: 2px;\n",
       "\tpadding: 1px;\n",
       "\tbackground: white;\n",
       "\tdisplay: inline-flex;\n",
       "\tplace-items: center;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-s > * {\n",
       "\tpadding: 1px;\n",
       "}\n",
       "\n",
       ".hrepr-bracketed {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: row;\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",
       "}\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",
       "}\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",
       "\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=\"person hreprt-Amanda hreprl-v hrepr-instance\"><div class=\"hrepr-title\">Amanda</div><table class=\"hrepr-body\"><tr><td>age</td><td class=\"hrepr-delim\"> ↦ </td><td><span class=\"hreprt-int\">35</span></td></tr><tr><td>job</td><td class=\"hrepr-delim\"> ↦ </td><td><span class=\"hreprt-str\">gardener</span></td></tr></table></div></div></div>"
      ],
      "text/plain": [
       "<div class=\"person hreprt-Amanda hreprl-v hrepr-instance\"><div class=\"hrepr-title\">Amanda</div><table class=\"hrepr-body\"><tr><td>age</td><td class=\"hrepr-delim\"> ↦ </td><td><span class=\"hreprt-int\">35</span></td></tr><tr><td>job</td><td class=\"hrepr-delim\"> ↦ </td><td><span class=\"hreprt-str\">gardener</span></td></tr></table></div>"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "amanda = Person(\"Amanda\", 35, \"gardener\")\n",
    "hrepr(amanda)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "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 {\n",
       "                background: magenta !important;\n",
       "                border-color: magenta !important;\n",
       "            }\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--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;\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;\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",
       "/* 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",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-v > *,\n",
       ".hrepr-body.hreprl-h > * {\n",
       "\tmargin: 2px;\n",
       "\tpadding: 1px;\n",
       "\tbackground: white;\n",
       "\tdisplay: inline-flex;\n",
       "\tplace-items: center;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-s > * {\n",
       "\tpadding: 1px;\n",
       "}\n",
       "\n",
       ".hrepr-bracketed {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: row;\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",
       "}\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",
       "}\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",
       "\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\"><span class=\"person-short\">Amanda</span></div></div>"
      ],
      "text/plain": [
       "<span class=\"person-short\">Amanda</span>"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hrepr(amanda, max_depth=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Amanda(age ↦ 35, job ↦ 'gardener')\n",
      "Amanda\n"
     ]
    }
   ],
   "source": [
    "from hrepr import pprint\n",
    "pprint(amanda)\n",
    "pprint(amanda, max_depth=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "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 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": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "li = [1, 2, 3]\n",
    "li.append(li)\n",
    "hrepr(li)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "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--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;\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;\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",
       "/* 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",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-v > *,\n",
       ".hrepr-body.hreprl-h > * {\n",
       "\tmargin: 2px;\n",
       "\tpadding: 1px;\n",
       "\tbackground: white;\n",
       "\tdisplay: inline-flex;\n",
       "\tplace-items: center;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-s > * {\n",
       "\tpadding: 1px;\n",
       "}\n",
       "\n",
       ".hrepr-bracketed {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: row;\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",
       "}\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",
       "}\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",
       "\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 {\n",
       "                background: magenta !important;\n",
       "                border-color: magenta !important;\n",
       "            }\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=\"person hreprt-Amanda hreprl-v hrepr-instance\"><div class=\"hrepr-title\">Amanda</div><table class=\"hrepr-body\"><tr><td>age</td><td class=\"hrepr-delim\"> ↦ </td><td><span class=\"hreprt-int\">35</span></td></tr><tr><td>job</td><td class=\"hrepr-delim\"> ↦ </td><td><span class=\"hreprt-str\">gardener</span></td></tr></table></div></div></div><div><div class=\"hrepr-refbox\"><span class=\"hrepr-ref\">#1=</span><span class=\"person-short\">Amanda</span></div></div><div><div class=\"hrepr-refbox\"><span class=\"hrepr-ref\">#1=</span><span class=\"person-short\">Amanda</span></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 class=\"hrepr-refbox\"><span class=\"hrepr-ref\">#1=</span><div class=\"person hreprt-Amanda hreprl-v hrepr-instance\"><div class=\"hrepr-title\">Amanda</div><table class=\"hrepr-body\"><tr><td>age</td><td class=\"hrepr-delim\"> ↦ </td><td><span class=\"hreprt-int\">35</span></td></tr><tr><td>job</td><td class=\"hrepr-delim\"> ↦ </td><td><span class=\"hreprt-str\">gardener</span></td></tr></table></div></div></div><div><div class=\"hrepr-refbox\"><span class=\"hrepr-ref\">#1=</span><span class=\"person-short\">Amanda</span></div></div><div><div class=\"hrepr-refbox\"><span class=\"hrepr-ref\">#1=</span><span class=\"person-short\">Amanda</span></div></div></div><div class=\"hrepr-close\">]</div></div>"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hrepr([amanda, amanda, amanda])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "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--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;\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;\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",
       "/* 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",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-v > *,\n",
       ".hrepr-body.hreprl-h > * {\n",
       "\tmargin: 2px;\n",
       "\tpadding: 1px;\n",
       "\tbackground: white;\n",
       "\tdisplay: inline-flex;\n",
       "\tplace-items: center;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-s > * {\n",
       "\tpadding: 1px;\n",
       "}\n",
       "\n",
       ".hrepr-bracketed {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: row;\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",
       "}\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",
       "}\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",
       "\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 {\n",
       "                background: magenta !important;\n",
       "                border-color: magenta !important;\n",
       "            }\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=\"person hreprt-Amanda hreprl-v hrepr-instance\"><div class=\"hrepr-title\">Amanda</div><table class=\"hrepr-body\"><tr><td>age</td><td class=\"hrepr-delim\"> ↦ </td><td><span class=\"hreprt-int\">35</span></td></tr><tr><td>job</td><td class=\"hrepr-delim\"> ↦ </td><td><span class=\"hreprt-str\">gardener</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>"
      ],
      "text/plain": [
       "<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=\"person hreprt-Amanda hreprl-v hrepr-instance\"><div class=\"hrepr-title\">Amanda</div><table class=\"hrepr-body\"><tr><td>age</td><td class=\"hrepr-delim\"> ↦ </td><td><span class=\"hreprt-int\">35</span></td></tr><tr><td>job</td><td class=\"hrepr-delim\"> ↦ </td><td><span class=\"hreprt-str\">gardener</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>"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hrepr([amanda, amanda, amanda], shortrefs=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "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--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;\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;\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",
       "/* 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",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-v > *,\n",
       ".hrepr-body.hreprl-h > * {\n",
       "\tmargin: 2px;\n",
       "\tpadding: 1px;\n",
       "\tbackground: white;\n",
       "\tdisplay: inline-flex;\n",
       "\tplace-items: center;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-s > * {\n",
       "\tpadding: 1px;\n",
       "}\n",
       "\n",
       ".hrepr-bracketed {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: row;\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",
       "}\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",
       "}\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",
       "\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 {\n",
       "                background: magenta !important;\n",
       "                border-color: magenta !important;\n",
       "            }\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=\"person hreprt-Amanda hreprl-v hrepr-instance\"><div class=\"hrepr-title\">Amanda</div><table class=\"hrepr-body\"><tr><td>age</td><td class=\"hrepr-delim\"> ↦ </td><td><span class=\"hreprt-int\">35</span></td></tr><tr><td>job</td><td class=\"hrepr-delim\"> ↦ </td><td><span class=\"hreprt-str\">gardener</span></td></tr></table></div></div><div><div class=\"person hreprt-Amanda hreprl-v hrepr-instance\"><div class=\"hrepr-title\">Amanda</div><table class=\"hrepr-body\"><tr><td>age</td><td class=\"hrepr-delim\"> ↦ </td><td><span class=\"hreprt-int\">35</span></td></tr><tr><td>job</td><td class=\"hrepr-delim\"> ↦ </td><td><span class=\"hreprt-str\">gardener</span></td></tr></table></div></div><div><div class=\"person hreprt-Amanda hreprl-v hrepr-instance\"><div class=\"hrepr-title\">Amanda</div><table class=\"hrepr-body\"><tr><td>age</td><td class=\"hrepr-delim\"> ↦ </td><td><span class=\"hreprt-int\">35</span></td></tr><tr><td>job</td><td class=\"hrepr-delim\"> ↦ </td><td><span class=\"hreprt-str\">gardener</span></td></tr></table></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 class=\"person hreprt-Amanda hreprl-v hrepr-instance\"><div class=\"hrepr-title\">Amanda</div><table class=\"hrepr-body\"><tr><td>age</td><td class=\"hrepr-delim\"> ↦ </td><td><span class=\"hreprt-int\">35</span></td></tr><tr><td>job</td><td class=\"hrepr-delim\"> ↦ </td><td><span class=\"hreprt-str\">gardener</span></td></tr></table></div></div><div><div class=\"person hreprt-Amanda hreprl-v hrepr-instance\"><div class=\"hrepr-title\">Amanda</div><table class=\"hrepr-body\"><tr><td>age</td><td class=\"hrepr-delim\"> ↦ </td><td><span class=\"hreprt-int\">35</span></td></tr><tr><td>job</td><td class=\"hrepr-delim\"> ↦ </td><td><span class=\"hreprt-str\">gardener</span></td></tr></table></div></div><div><div class=\"person hreprt-Amanda hreprl-v hrepr-instance\"><div class=\"hrepr-title\">Amanda</div><table class=\"hrepr-body\"><tr><td>age</td><td class=\"hrepr-delim\"> ↦ </td><td><span class=\"hreprt-int\">35</span></td></tr><tr><td>job</td><td class=\"hrepr-delim\"> ↦ </td><td><span class=\"hreprt-str\">gardener</span></td></tr></table></div></div></div><div class=\"hrepr-close\">]</div></div>"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hrepr([amanda, amanda, amanda], norefs=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Amanda(age ↦ 35, job ↦ 'gardener')\n"
     ]
    }
   ],
   "source": [
    "from hrepr import pprint\n",
    "pprint(amanda)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[\n",
      "    #1=Amanda(\n",
      "        age ↦ 35, \n",
      "        job ↦ 'gardener'\n",
      "    ), \n",
      "    #1=Amanda, \n",
      "    #1=Amanda\n",
      "]\n"
     ]
    }
   ],
   "source": [
    "pprint([amanda, amanda, amanda], max_col=10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from hrepr import hrepr\n",
    "import json\n",
    "\n",
    "class Plot:\n",
    "    def __init__(self, data):\n",
    "        self.data = data\n",
    "\n",
    "    @classmethod\n",
    "    def __hrepr_resources__(cls, H):\n",
    "        return H.require(\n",
    "            name=\"plotly\",\n",
    "            src=\"https://cdn.plot.ly/plotly-latest.min.js\",\n",
    "        )\n",
    "\n",
    "    def __hrepr__(self, H, hrepr):\n",
    "        data = {\n",
    "            \"x\": list(range(len(self.data))),\n",
    "            \"y\": list(self.data),\n",
    "        }\n",
    "        return H.script(\n",
    "            f\"plotly.newPlot(plotdiv, [{json.dumps(data)}]);\",\n",
    "            require=\"plotly\",\n",
    "            create_div=\"plotdiv\",\n",
    "        )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "scrolled": false
   },
   "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><script type=\"text/javascript\" src=\"https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js\"></script><script>requirejs.config({paths: {plotly: \"https://cdn.plot.ly/plotly-latest.min.js?noext\"}});</script><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--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;\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;\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",
       "/* 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",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-v > *,\n",
       ".hrepr-body.hreprl-h > * {\n",
       "\tmargin: 2px;\n",
       "\tpadding: 1px;\n",
       "\tbackground: white;\n",
       "\tdisplay: inline-flex;\n",
       "\tplace-items: center;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-s > * {\n",
       "\tpadding: 1px;\n",
       "}\n",
       "\n",
       ".hrepr-bracketed {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: row;\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",
       "}\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",
       "}\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",
       "\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 id=\"_hrepr_0\"></div><script>require(['plotly'], function (plotly) {(function () {let plotdiv = document.getElementById('_hrepr_0');plotly.newPlot(plotdiv, [{\"x\": [0, 1, 2, 3], \"y\": [4, 5, -3, 21]}]);})();});</script></div></div>"
      ],
      "text/plain": [
       "<div id=\"_hrepr_0\"></div><script>require(['plotly'], function (plotly) {(function () {let plotdiv = document.getElementById('_hrepr_0');plotly.newPlot(plotdiv, [{\"x\": [0, 1, 2, 3], \"y\": [4, 5, -3, 21]}]);})();});</script>"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hrepr(Plot([4, 5, -3, 21]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [],
   "source": [
    "from hrepr import hrepr, Hrepr\n",
    "from ovld import ovld, has_attribute\n",
    "\n",
    "class MyMixin(Hrepr):\n",
    "    # Change the representation of integers\n",
    "\n",
    "    def hrepr_resources(self, cls: int):\n",
    "        return self.H.style(\".my-integer { color: fuchsia; }\")\n",
    "\n",
    "    def hrepr(self, n: int):\n",
    "        return self.H.span[\"my-integer\"](\"The number \", str(n))\n",
    "\n",
    "    # Specially handle any object with a \"quack\" method\n",
    "\n",
    "    def hrepr(self, duck: has_attribute(\"quack\")):\n",
    "        return self.H.span(\"🦆\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "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--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;\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;\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",
       "/* 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",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-v > *,\n",
       ".hrepr-body.hreprl-h > * {\n",
       "\tmargin: 2px;\n",
       "\tpadding: 1px;\n",
       "\tbackground: white;\n",
       "\tdisplay: inline-flex;\n",
       "\tplace-items: center;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-s > * {\n",
       "\tpadding: 1px;\n",
       "}\n",
       "\n",
       ".hrepr-bracketed {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: row;\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",
       "}\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",
       "}\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",
       "\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>.my-integer { color: fuchsia; }</style><div class=\"hrepr\"><div class=\"hrepr-bracketed hreprt-list\"><div class=\"hrepr-open\">[</div><div class=\"hreprl-h hrepr-body\"><div><span class=\"my-integer\">The number 1</span></div><div><span class=\"my-integer\">The number 2</span></div><div><span>🦆</span></div><div><span class=\"my-integer\">The number 4</span></div></div><div class=\"hrepr-close\">]</div></div></div></div>"
      ],
      "text/plain": [
       "<div class=\"hrepr-bracketed hreprt-list\"><div class=\"hrepr-open\">[</div><div class=\"hreprl-h hrepr-body\"><div><span class=\"my-integer\">The number 1</span></div><div><span class=\"my-integer\">The number 2</span></div><div><span>🦆</span></div><div><span class=\"my-integer\">The number 4</span></div></div><div class=\"hrepr-close\">]</div></div>"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "class Farfetchd:\n",
    "    def quack(self):\n",
    "        return \"DUX\"\n",
    "\n",
    "hrepr([1, 2, Farfetchd(), 4], mixins=MyMixin)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [],
   "source": [
    "from hrepr import H\n",
    "\n",
    "style = H.style(\".highlight { border: 3px solid red !important; }\")\n",
    "\n",
    "def highlight(x):\n",
    "    def postprocess(element, obj, hrepr):\n",
    "        if obj == x:\n",
    "            # Adds the \"highlight\" class and attaches a style\n",
    "            return element[\"highlight\"].fill(resources=style)\n",
    "        else:\n",
    "            return element\n",
    "\n",
    "    return postprocess"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "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--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;\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;\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",
       "/* 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",
       "\tbackground: #ddd;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-v > *,\n",
       ".hrepr-body.hreprl-h > * {\n",
       "\tmargin: 2px;\n",
       "\tpadding: 1px;\n",
       "\tbackground: white;\n",
       "\tdisplay: inline-flex;\n",
       "\tplace-items: center;\n",
       "}\n",
       "\n",
       ".hrepr-body.hreprl-s > * {\n",
       "\tpadding: 1px;\n",
       "}\n",
       "\n",
       ".hrepr-bracketed {\n",
       "\tdisplay: inline-flex;\n",
       "\tflex-direction: row;\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",
       "}\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",
       "}\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",
       "\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>.highlight { border: 3px solid red !important; }</style><div class=\"hrepr\"><div class=\"hrepr-bracketed hreprt-list\"><div class=\"hrepr-open\">[</div><div class=\"hreprl-h hrepr-body\"><div><span class=\"hreprt-int\">1</span></div><div><span class=\"highlight hreprt-int\">2</span></div><div><div class=\"hrepr-bracketed hreprt-list\"><div class=\"hrepr-open\">[</div><div class=\"hreprl-h hrepr-body\"><div><span class=\"hreprt-int\">3</span></div><div><span class=\"hreprt-int\">4</span></div><div><span class=\"highlight hreprt-int\">2</span></div></div><div class=\"hrepr-close\">]</div></div></div></div><div class=\"hrepr-close\">]</div></div></div></div>"
      ],
      "text/plain": [
       "<div class=\"hrepr-bracketed hreprt-list\"><div class=\"hrepr-open\">[</div><div class=\"hreprl-h hrepr-body\"><div><span class=\"hreprt-int\">1</span></div><div><span class=\"highlight hreprt-int\">2</span></div><div><div class=\"hrepr-bracketed hreprt-list\"><div class=\"hrepr-open\">[</div><div class=\"hreprl-h hrepr-body\"><div><span class=\"hreprt-int\">3</span></div><div><span class=\"hreprt-int\">4</span></div><div><span class=\"highlight hreprt-int\">2</span></div></div><div class=\"hrepr-close\">]</div></div></div></div><div class=\"hrepr-close\">]</div></div>"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hrepr([1, 2, [3, 4, 2]], postprocess=highlight(2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "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.7.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
