{"id":134,"date":"2019-04-18T23:48:24","date_gmt":"2019-04-19T03:48:24","guid":{"rendered":"http:\/\/www.eg.bucknell.edu\/~brk009\/?p=134"},"modified":"2019-04-19T00:24:56","modified_gmt":"2019-04-19T04:24:56","slug":"notebook-on-wp","status":"publish","type":"post","link":"https:\/\/www.eg.bucknell.edu\/~brk009\/notebook-on-wp\/","title":{"rendered":"Including a Jupyter Notebook file on WordPress"},"content":{"rendered":"\n<p>I&#8217;ve been exploring different mechanisms to post Python Jupyter notebook files on WordPress. Of course, I can use <code class=\"\" data-line=\"\">nbconvert<\/code> to <a href=\"https:\/\/nbconvert.readthedocs.io\/en\/latest\/usage.html#convert-html\">convert my notebook files to other formats<\/a> &#8211; including HTML &#8211; right from the command line. I can then post this file as part of an embedded HTML block in a WordPress post. However, this sounded like an unnecessary step, since I also wanted the notebook to be available in GitHub. I did not want to deal with generating this HTML file AND also managing a published notebook on GitLab as well. Smells a lot like duplicate efforts, wasted time. Thanks to a great WordPress plugin from Andy Challis, called <strong>nbconvert<\/strong>, I was able to achieve what I wanted! See his page at <a href=\"https:\/\/www.andrewchallis.co.uk\/portfolio\/php-nbconvert-a-wordpress-plugin-for-jupyter-notebooks\/\">https:\/\/www.andrewchallis.co.uk\/portfolio\/php-nbconvert-a-wordpress-plugin-for-jupyter-notebooks\/<\/a> for complete instructions.  <\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>If you haven&#8217;t yet, you must install <a href=\"https:\/\/wppusher.com\/\">WP Pusher<\/a> as a plugin in your WordPress site. (See <a href=\"http:\/\/www.eg.bucknell.edu\/~brk009\/moving-to-wordpress\/\">this<\/a> for more info.)<\/li><li>Go to his web page for <a href=\"https:\/\/www.andrewchallis.co.uk\/portfolio\/php-nbconvert-a-wordpress-plugin-for-jupyter-notebooks\/\">nbconvert<\/a>, copy the CSS custom code displayed on the page. <\/li><li>Go to your WordPress page, and add the custom CSS displayed on the page above into <strong>Appearance -&gt; Customize -&gt; Additonal CSS<\/strong><\/li><li>Go to <a href=\"https:\/\/github.com\/ghandic\/nbconvert\">https:\/\/github.com\/ghandic\/nbconvert<\/a> and verify the latest instructions. Install the nbconvert shortcode plugin through <strong>WP Pusher<\/strong>. Activate it.  <\/li><li>That&#8217;s it! <\/li><\/ol>\n\n\n\n<p>Follow the instructions to include your own Jupyter notebook file available on GitHub. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Example<\/h3>\n\n\n\n<p>Here is an example. In a standalone text (or paragraph) block, I included the following shortcode:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[nbconvert url=\"https:\/\/github.com\/bkingcs\/python_snippets\/blob\/master\/clustering\/hierarchical.ipynb\" \/]<\/pre>\n\n\n\n<p>This generates the following:<\/p>\n\n\n<div class=\"notebook\">\n    <div class=\"nbconvert-labels\">\n      <label class=\"github-link\">\n        <a href=\"https:\/\/github.com\/bkingcs\/python_snippets\/blob\/master\/clustering\/hierarchical.ipynb\" target=\"_blank\">Check it out on github<\/a>\n        <label class=\"github-last-update\"> Last updated: 19\/04\/2019 04:18:22<\/label>\n      <\/label>\n      <\/div>\n    <div class=\"nbconvert\">\n    <\/div>\n  <\/div>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been exploring different mechanisms to post Python Jupyter notebook files on WordPress. Of course, I can use nbconvert to convert my notebook files to other formats &#8211; including HTML &#8211; right from the command line. I can then post this file as part of an embedded HTML block in a WordPress post. However, this &hellip; <a href=\"https:\/\/www.eg.bucknell.edu\/~brk009\/notebook-on-wp\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Including a Jupyter Notebook file on WordPress&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[17,11,14],"post_folder":[],"class_list":["post-134","post","type-post","status-publish","format-standard","hentry","category-wp","tag-jupyter","tag-python","tag-wp"],"_links":{"self":[{"href":"https:\/\/www.eg.bucknell.edu\/~brk009\/wp-json\/wp\/v2\/posts\/134","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.eg.bucknell.edu\/~brk009\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.eg.bucknell.edu\/~brk009\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.eg.bucknell.edu\/~brk009\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.eg.bucknell.edu\/~brk009\/wp-json\/wp\/v2\/comments?post=134"}],"version-history":[{"count":26,"href":"https:\/\/www.eg.bucknell.edu\/~brk009\/wp-json\/wp\/v2\/posts\/134\/revisions"}],"predecessor-version":[{"id":253,"href":"https:\/\/www.eg.bucknell.edu\/~brk009\/wp-json\/wp\/v2\/posts\/134\/revisions\/253"}],"wp:attachment":[{"href":"https:\/\/www.eg.bucknell.edu\/~brk009\/wp-json\/wp\/v2\/media?parent=134"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.eg.bucknell.edu\/~brk009\/wp-json\/wp\/v2\/categories?post=134"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.eg.bucknell.edu\/~brk009\/wp-json\/wp\/v2\/tags?post=134"},{"taxonomy":"post_folder","embeddable":true,"href":"https:\/\/www.eg.bucknell.edu\/~brk009\/wp-json\/wp\/v2\/post_folder?post=134"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}