diff --git a/nb/nbmeta-00-01__exploration.ipynb b/nb/nbmeta-00-01__exploration.ipynb new file mode 100644 index 0000000..7b111c4 --- /dev/null +++ b/nb/nbmeta-00-01__exploration.ipynb @@ -0,0 +1,560 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: dominate in /home/wturner/-wrk/-ce27/mathclock/lib/python2.7/site-packages\r\n" + ] + } + ], + "source": [ + "!pip install dominate" + ] + }, + { + "cell_type": "code", + "execution_count": 170, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "
\n", + "

HTML

this\n", + "
that
\n", + "
that2
\n", + "
    \n", + "
  • 0
  • \n", + "
  • 1
  • \n", + "
  • 2
  • \n", + "
\n", + "
\n", + "
\n", + "
\n", + "

HTML (source)

\n", + " <div>this\n", + " <div id="that">that</div>\n", + " <div id="that">that2</div>\n", + " <ul>\n", + " <li>0</li>\n", + " <li>1</li>\n", + " <li>2</li>\n", + " </ul>\n", + "</div>\n", + "
\n", + "
\n", + "

HTML (highlighted)

<div>this\n",
+       "  <div id="that">that</div>\n",
+       "  <div id="that">that2</div>\n",
+       "  <ul>\n",
+       "    <li>0</li>\n",
+       "    <li>1</li>\n",
+       "    <li>2</li>\n",
+       "  </ul>\n",
+       "</div>\n",
+       "
\n", + "\n", + "
\n", + "
" + ], + "text/plain": [ + "<__main__.ReprHTML at 0x7f8f680817d0>" + ] + }, + "execution_count": 170, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import dominate\n", + "import dominate.util\n", + "tags = dominate.tags\n", + "div, h3, code, span, a = tags.div, tags.h3, tags.code, tags.span, tags.a\n", + "text, raw = dominate.util.text, dominate.util.raw\n", + "\n", + "with div(\"this\") as this:\n", + " this.add(div(\"that\", id=\"that\"))\n", + " div(\"that2\", id=\"that\")\n", + " with tags.ul():\n", + " [tags.li(n) for n in range(3)]\n", + "\n", + "\n", + "from pygments import highlight\n", + "from pygments.lexers import HtmlLexer\n", + "from pygments.formatters import HtmlFormatter\n", + " \n", + "def highlight_html(html):\n", + " return highlight(\n", + " html,\n", + " HtmlLexer(),\n", + " HtmlFormatter(noclasses=True))\n", + "\n", + "class ReprHTMLConf:\n", + " print_html = False\n", + " print_highlight = False\n", + " \n", + "class ReprHTML(object):\n", + " def __init__(self, obj):\n", + " self.obj = obj\n", + " \n", + " def __getattr__(self, attr):\n", + " if attr.startswith('_repr'):\n", + " if attr in ReprHTML:\n", + " return object.__getattribute__(self, attr)\n", + " return self.obj.__getattr__(self.obj, attr)\n", + " \n", + " def _repr_html_(self, obj=None):\n", + " if obj is None:\n", + " obj = self.obj\n", + " if hasattr(obj, '_repr_html_'):\n", + " obj_html = obj._repr_html_()\n", + " else:\n", + " obj_html = obj\n", + " doc = div([\n", + " div([h3('HTML'),\n", + " text(obj_html, escape=False),\n", + " #raw(obj_html)\n", + " ]),\n", + " div([h3('HTML (source)'),\n", + " code(\n", + " text(obj_html, escape=True))]),\n", + " div([h3('HTML (highlighted)'),\n", + " text(\n", + " highlight_html(obj_html),\n", + " escape=False)])\n", + " ])\n", + " doc_html = doc.render() # XXX: XSS\n", + " if ReprHTMLConf.print_html:\n", + " if ReprHTMLConf.print_highlight:\n", + " print(doc_html)\n", + " else:\n", + " print(obj_html)\n", + " return doc_html\n", + "\n", + "#ReprHTMLConf.print_html = True\n", + "ReprHTML(this.render())" + ] + }, + { + "cell_type": "code", + "execution_count": 189, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n" + ] + }, + { + "ename": "Exception", + "evalue": "", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mException\u001b[0m Traceback (most recent call last)", + "\u001b[1;32m/home/wturner/.local/lib/python2.7/site-packages/IPython/core/formatters.pyc\u001b[0m in \u001b[0;36m__call__\u001b[1;34m(self, obj)\u001b[0m\n\u001b[0;32m 339\u001b[0m \u001b[0mmethod\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0m_safe_get_formatter_method\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mobj\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mprint_method\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 340\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mmethod\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0mNone\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 341\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mmethod\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 342\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mNone\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 343\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;32m\u001b[0m in \u001b[0;36m_repr_html_\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 42\u001b[0m \u001b[0mobj_html\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mstr\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mobj\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 43\u001b[0m \u001b[1;32mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtype\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mobj_html\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 44\u001b[1;33m \u001b[0mmeta_html\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmeta_to_html\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 45\u001b[0m \u001b[1;32mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtype\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmeta_html\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 46\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[1;34mu'\\n'\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mjoin\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mobj_html\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmeta_to_html\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;32m\u001b[0m in \u001b[0;36mmeta_to_html\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 31\u001b[0m \u001b[1;32mraise\u001b[0m \u001b[0mException\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 32\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mul\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 33\u001b[1;33m \u001b[0mitems_ul\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mmetahtml\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmeta\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mdoc\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 34\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mdoc\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrender\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 35\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;32m\u001b[0m in \u001b[0;36mmetahtml\u001b[1;34m(items, doc)\u001b[0m\n\u001b[0;32m 25\u001b[0m \u001b[0mspan\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtext\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mvalue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mproperty\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 26\u001b[0m \u001b[1;32melif\u001b[0m \u001b[0mhasattr\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mvalue\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'items'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 27\u001b[1;33m \u001b[0mmetahtml\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mvalue\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mul\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 28\u001b[0m \u001b[1;32melif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mvalue\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mMeta\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 29\u001b[0m \u001b[0mmetahtml\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mvalue\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mobj\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;32m\u001b[0m in \u001b[0;36mmetahtml\u001b[1;34m(items, doc)\u001b[0m\n\u001b[0;32m 29\u001b[0m \u001b[0mmetahtml\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mvalue\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mobj\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 30\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 31\u001b[1;33m \u001b[1;32mraise\u001b[0m \u001b[0mException\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 32\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mul\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 33\u001b[0m \u001b[0mitems_ul\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mmetahtml\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmeta\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mdoc\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;31mException\u001b[0m: " + ] + }, + { + "data": { + "text/plain": [ + "<__main__.Meta at 0x7f8f6a395590>" + ] + }, + "execution_count": 189, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "_jsonldstr = \"\"\"\n", + " {\"@context\": {\n", + " \"schema\": \"http://schema.org/\",\n", + " \"jupyter\": \"https://jupyter.org/ns/v4/#\",\n", + " \"_base\": \"http://localhost:8000/ns/v1#\"\n", + " },\n", + " \"@type\": [\n", + " \"jupyter:JupyterNotebook\",\n", + " \"schema:ScholarlyArticle\",\n", + " \"schema:DataCatalog\"\n", + " ],\n", + " \"@id\": \"http://localhost:8888/notebooks/nb/nbmeta-00-01__exploration.ipynb\",\n", + " \"name\": \"Notebook Name\",\n", + " \"author\": [{\n", + " \"@type\": \"schema:Person\",\n", + " \"givenName\": \"Wesley\",\n", + " \"familyName\": \"Turner\",\n", + " \"url\": \"https://westurner.org/\"\n", + " }],\n", + " \"dateCreated\": \"2017-01-30\",\n", + " \"about\": [\n", + " {\"url\": [\"https://en.wikipedia.org/wiki/JSONLD\"] },\n", + " {\"url\": \"https://pypi.org/project/pipfile/\", \"name\": \"Pipfile and Pipfile.lock\"}\n", + " ]\n", + "}\n", + "\"\"\"\n", + "import json\n", + "import collections\n", + "\n", + "\n", + "from pygments import highlight\n", + "from pygments.lexers import JavascriptLexer\n", + "from pygments.formatters import HtmlFormatter\n", + " \n", + "def highlight_jsonld(jsonldstr):\n", + " return highlight(\n", + " jsonldstr,\n", + " JavascriptLexer(),\n", + " HtmlFormatter(noclasses=True))\n", + "\n", + "Meta(ReprHTML(\n", + " highlight_jsonld(_jsonldstr)),\n", + " thing=json.loads(_jsonldstr, object_hook=collections.OrderedDict))" + ] + }, + { + "cell_type": "code", + "execution_count": 220, + "metadata": { + "collapsed": false, + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n" + ] + }, + { + "data": { + "text/html": [ + "
\n", + "
\n", + "

HTML

this\n", + "
that
\n", + "
that2
\n", + "
    \n", + "
  • 0
  • \n", + "
  • 1
  • \n", + "
  • 2
  • \n", + "
\n", + "
\n", + "
\n", + " \n", + "
\n", + "
\n", + "
\n", + "

HTML (source)

\n", + " <div>this\n", + " <div id="that">that</div>\n", + " <div id="that">that2</div>\n", + " <ul>\n", + " <li>0</li>\n", + " <li>1</li>\n", + " <li>2</li>\n", + " </ul>\n", + "</div>\n", + "<div typeof="schema:CreativeWork jupyter:JupyterNotebook">\n", + " <ul>\n", + " <li property="http://schema.org/url">\n", + " <a href="http://schema.org/url" property="rdf:Predicate">http://schema.org/url</a>\n", + " <span property="http://schema.org/url">http://localhost:8888/notebooks/nb/...ipynb</span>\n", + " </li>\n", + " <li property="http://schema.org/author">\n", + " <a href="http://schema.org/author" property="rdf:Predicate">http://schema.org/author</a>\n", + " <ul>\n", + " <li>\n", + " <ul>\n", + " <li property="rdf:type">\n", + " <a href="rdf:type" property="rdf:Predicate">rdf:type</a>\n", + " <span property="rdf:type">rdf:type</span>\n", + " </li>\n", + " <li property="http://schema.org/givenName">\n", + " <a href="http://schema.org/givenName" property="rdf:Predicate">http://schema.org/givenName</a>\n", + " <span property="http://schema.org/givenName">http://schema.org/givenName</span>\n", + " </li>\n", + " </ul>\n", + " </li>\n", + " </ul>\n", + " </li>\n", + " </ul>\n", + "</div>\n", + "
\n", + "
\n", + "

HTML (highlighted)

<div>this\n",
+       "  <div id="that">that</div>\n",
+       "  <div id="that">that2</div>\n",
+       "  <ul>\n",
+       "    <li>0</li>\n",
+       "    <li>1</li>\n",
+       "    <li>2</li>\n",
+       "  </ul>\n",
+       "</div>\n",
+       "<div typeof="schema:CreativeWork jupyter:JupyterNotebook">\n",
+       "  <ul>\n",
+       "    <li property="http://schema.org/url">\n",
+       "      <a href="http://schema.org/url" property="rdf:Predicate">http://schema.org/url</a>\n",
+       "      <span property="http://schema.org/url">http://localhost:8888/notebooks/nb/...ipynb</span>\n",
+       "    </li>\n",
+       "    <li property="http://schema.org/author">\n",
+       "      <a href="http://schema.org/author" property="rdf:Predicate">http://schema.org/author</a>\n",
+       "      <ul>\n",
+       "        <li>\n",
+       "          <ul>\n",
+       "            <li property="rdf:type">\n",
+       "              <a href="rdf:type" property="rdf:Predicate">rdf:type</a>\n",
+       "              <span property="rdf:type">rdf:type</span>\n",
+       "            </li>\n",
+       "            <li property="http://schema.org/givenName">\n",
+       "              <a href="http://schema.org/givenName" property="rdf:Predicate">http://schema.org/givenName</a>\n",
+       "              <span property="http://schema.org/givenName">http://schema.org/givenName</span>\n",
+       "            </li>\n",
+       "          </ul>\n",
+       "        </li>\n",
+       "      </ul>\n",
+       "    </li>\n",
+       "  </ul>\n",
+       "</div>\n",
+       "
\n", + "\n", + "
\n", + "
" + ], + "text/plain": [ + "<__main__.ReprHTML at 0x7f8f596cc050>" + ] + }, + "execution_count": 220, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "\n", + "\n", + "from collections import OrderedDict\n", + "class Meta(object):\n", + " def __init__(self, obj, meta=None, **kwargs):\n", + " self.obj = obj\n", + " if meta is None:\n", + " meta = OrderedDict()\n", + " meta.update(kwargs) # TODO\n", + " self.meta = meta\n", + " \n", + " def __getattr__(self, attr):\n", + " if 1: # attr.startswith('_repr'):\n", + " if hasattr(Meta, attr):\n", + " return object.__getattribute__(self, attr)\n", + " return self.obj.__getattribute__(attr)\n", + " \n", + " def meta_to_html(self):\n", + " with div(typeof='schema:CreativeWork jupyter:JupyterNotebook') as doc:\n", + " def metahtml(items, cur_node):\n", + " with cur_node as doc:\n", + " with tags.ul() as ul_node:\n", + " for key, value in items:\n", + " with tags.li(property=key) as li_node:\n", + " li_node.add(a(key, href=key, property=\"rdf:Predicate\"))\n", + " if isinstance(value, basestring):\n", + " span(text(value), property=key)\n", + " elif hasattr(value, 'items'):\n", + " metahtml(value.items(), li_node)\n", + " elif isinstance(value, Meta):\n", + " metahtml(value.obj, li_node) # TODO: value.obj ->\n", + " elif hasattr(value, '__iter__'):\n", + " #elif isinstance(value, (list, tuple)):\n", + " with tags.ul() as _ul_node:\n", + " with tags.li() as _li_node:\n", + " # TODO: BUG: XXX\n", + " for _value in value:\n", + " _items = OrderedDict(\n", + " (__value, __value) for __value in _value).items()\n", + " metahtml(_items, _li_node) # TODO\n", + " elif hasattr(value, '_repr_html_'):\n", + " text(value._repr_html_(), escape=False)\n", + " #if isinstance(value, dominator.tag)\n", + " elif hasattr(value, 'render'):\n", + " text(value.render(), escape=False)\n", + " #TODO: markupsafe __html__ (\"?)\n", + " else:\n", + " raise Exception((type(value), value))\n", + " return cur_node\n", + " doc_ = metahtml(self.meta.items(), doc)\n", + " return doc.render()\n", + " \n", + " def _repr_html_(self):\n", + " obj = self.obj\n", + "\n", + " if hasattr(obj, '_repr_html_'):\n", + " obj_html = obj._repr_html_()\n", + " else:\n", + " obj_html = str(obj)\n", + " print(type(obj_html))\n", + " meta_html = self.meta_to_html()\n", + " print(type(meta_html))\n", + " return u'\\n'.join((obj_html, self.meta_to_html()))\n", + "\n", + "\n", + "ns = OrderedDict()\n", + "schema = ns['schema'] = {\n", + " \"url\": \"http://schema.org/url\",\n", + " \"author\": \"http://schema.org/author\",\n", + " \"givenName\": \"http://schema.org/givenName\",\n", + " \"Person\": \"http://schema.org/Person\"\n", + "}\n", + "rdf = ns['rdf'] = {\"a\": \"rdf:type\"}\n", + "ReprHTML(\n", + " Meta(this.render(),\n", + " meta=OrderedDict([\n", + " (schema['url'], \"http://localhost:8888/notebooks/nb/...ipynb\"),\n", + " (schema['author'], [\n", + " OrderedDict([\n", + " (rdf[\"a\"], schema['Person']),\n", + " (schema['givenName'], \"awesome\")\n", + " ]),\n", + " ]),\n", + " ])\n", + " )\n", + ")\n", + "\n", + "# TODO\n", + "# RreprJSONLD() RDFa" + ] + }, + { + "cell_type": "code", + "execution_count": 70, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "\"\"\"\n", + "Environment(requirementstxt='../requirements-2.txt')\n", + "Include('../README.rst')\n", + "Chart(plot, data, meta={})\n", + "\"\"\"\n", + "\n", + "def _repr_html_():\n", + " # emit and collect\n", + " # ...\n", + " globals()['celldata'][cell_n] = value\n", + " return value" + ] + }, + { + "cell_type": "code", + "execution_count": 72, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'\\nthis_notebook = TODO_GET_HERE()\\nbase URI\\n XHTML\\n HTML5\\nhttps://schema.org/mainEntityOfPage\\n<>\\n'" + ] + }, + "execution_count": 72, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "\"\"\"\n", + "this_notebook = TODO_GET_HERE()\n", + "base URI\n", + " XHTML\n", + " HTML5\n", + "https://schema.org/mainEntityOfPage\n", + "<>\n", + "\"\"\"" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.12" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +}