Overview

I use this page for testing how structures are rendered on the blog and for templating new posts. I leave this page openly visible as a resource for others who are interested in building their own blog.

Source code:

20151030-test.ipynb
20151030-test-full.html

Heading2

Heading3

Heading4
Heading5
Heading6

Motivations

Why am I doing this?

  • Why I'm doing this.

Body

Text with a footnote.1

Text with always-rendered dollar signs $1.12.

Text with a non-breaking space.

Text with a referenced portion.

Text referencing above.

Text with an equation \(\mathrm{SE}(X) = \sqrt{(\sum_{i=1}^{n}(X_i-X)^2)/n}\) inline.

Text with an equation

$$\mathrm{SE}(X) = \sqrt{\frac{\sum_{i=1}^{n}(X_i-X)^2}{n}}$$


as a paragraph.

Text that is collapsible:

Short answer.
Long answer.

  • A plot included via Markdown:

plot.jpg
plot.jpg

  • A screenshot included via HTML:

Chrome Secure Shell settings

  • A table:
c0 c1 c2
0 a A 10
1 b B 11
2 c C 12

table.html

  • A code snippet:
def my_print(string:str) -> None:
  r"""My docstring.

  Args:
    string (str): String to print.

  Returns:
    None

  """
  print('my '+string)
  return None
  • A Jupyter Notebook:

TODO: Add exported notebook by embedding HTML rather than copy-paste (issue 5).

Copy-pasted from 20151030-test-basic.html (all cells included):

20151030-test

Heading2

Heading3

Heading4

Heading5
Heading6

Description.

Initialization

Imports

In [1]:
cd ~

/home/samuel_harrold

In [2]:
# Import standard packages.
import os
import pdb # Debug with pdb.
import subprocess
import sys
import time
# Import installed packages.
import matplotlib.pyplot as plt
import pandas as pd
# Import local packages.
# Append current directory to module search path.
# Autoreload local packages after editing.
# dsdemos version: https://github.com/stharrold/dsdemos (master branch)
sys.path.insert(0, os.path.join(os.path.curdir, r'dsdemos'))
%reload_ext autoreload
%autoreload 2
import dsdemos as dsd
%matplotlib inline

In [3]:
print("Datestamp:")
print(time.strftime(r'%Y-%m-%dT%H:%M:%S%Z', time.gmtime()))
print()
print("Python version:")
print(sys.version_info)

Datestamp:
2016-01-04T16:44:26GMT

Python version:
sys.version_info(major=3, minor=5, micro=1, releaselevel='final', serial=0)

Globals

In [4]:
# File paths
path_static = os.path.join(os.path.expanduser(r'~'), r'stharrold.github.io/content/static')
basename = r'20151030-test'
filename = basename

Section 1

Description of section 1.

In [5]:
df = pd.DataFrame([['a', 'A', 10], ['b', 'B', 11], ['c', 'C', 12]], columns=['c0', 'c1', 'c2'])
path_html = os.path.join(path_static, basename, r'table.html')
df.to_html(buf=path_html)
print(path_html)
df

/home/samuel_harrold/stharrold.github.io/content/static/20151030-test/table.html
Out[5]:
c0 c1 c2
0 a A 10
1 b B 11
2 c C 12

In [6]:
plt.plot([0,1], [0,1])
path_jpg = os.path.join(path_static, basename, r'plot.jpg')
plt.savefig(path_jpg)
print(path_jpg)

/home/samuel_harrold/stharrold.github.io/content/static/20151030-test/plot.jpg

Export ipynb to html

In [7]:
# Export ipynb to html
path_ipynb = os.path.join(path_static, basename, filename+'.ipynb')
for template in ['basic', 'full']:
    path_html = os.path.splitext(path_ipynb)[0]+'-'+template+'.html'
    cmd = ['jupyter', 'nbconvert', '--to', 'html', '--template', template, path_ipynb, '--output', path_html]
    print(' '.join(cmd))
    subprocess.run(args=cmd, check=True)
    print()

jupyter nbconvert --to html --template basic /home/samuel_harrold/stharrold.github.io/content/static/20151030-test/20151030-test.ipynb --output /home/samuel_harrold/stharrold.github.io/content/static/20151030-test/20151030-test-basic.html

jupyter nbconvert --to html --template full /home/samuel_harrold/stharrold.github.io/content/static/20151030-test/20151030-test.ipynb --output /home/samuel_harrold/stharrold.github.io/content/static/20151030-test/20151030-test-full.html

Some links I found helpful for this blog post:

  • Some links here.

Footnotes


  1. Text as a footnote. 


Comments

comments powered by Disqus