This is a sample notebook¶
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Nisl nunc mi ipsum faucibus vitae aliquet nec. Ut sem nulla pharetra diam sit amet. Phasellus vestibulum lorem sed risus ultricies tristique nulla aliquet.
import matplotlib.pyplot as plt
f, ax = plt.subplots()
ax.plot([1, 2, 3, 4]);
This Jupyter notebook/Pelican blog post demonstrates what you can do when you combine Pelican and NBConvert with a simple Pelican Plugin, pelican-jupyter-reader.
The pelicanconf.py
for this demo includes a configuration object that is passed to NBConvert. Here are the relevant bits in pelicanconf.py
:
!tail -n20 ../pelicanconf.py
And, here is the custom NBConvert template (you can also just use one of the standard templates like basic
, or full
.
!cat ../demo.tpl
The combination of custom NBConvert template and the pelicanconf.py
settings from above enable the code styles and interactity below.
%%javascript
// note that Pygments uses the Javascript lexer here
console.log('Hello, world!')
const s = 'something'
%%bash
# ...and the Bash lexer here
echo "Hello, world!"
# By combining cell tags and a custom nbconvert template, we can style the output
# of different cells easily. This cell has the tag "red-border," and that tag is
# handled in "demo.tbl" (you can find "demo.tpl" in the base directory of this
# demo site).
print('This cell will have a red border.')
The empty cells below won't apper in your Pelican post.