-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: execute markdown with jupytext frontmatter (#216)
- Loading branch information
1 parent
48a3f3a
commit 7895e56
Showing
9 changed files
with
811 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
site_name: site-with-python-files | ||
site_description: mkdocs-jupyter test site | ||
|
||
nav: | ||
- Home: index.md | ||
- Demo (md): demo-jupytext.md | ||
- Equations (md): variational-inference.md | ||
|
||
plugins: | ||
- mkdocs-jupyter | ||
|
||
markdown_extensions: | ||
- codehilite: | ||
guess_lang: false | ||
- pymdownx.highlight: | ||
use_pygments: true | ||
- pymdownx.arithmatex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,187 @@ | ||
--- | ||
jupyter: | ||
jupytext: | ||
text_representation: | ||
extension: .md | ||
format_name: markdown | ||
format_version: '1.3' | ||
jupytext_version: 1.16.4 | ||
kernelspec: | ||
display_name: Python 3 | ||
language: python | ||
name: python3 | ||
--- | ||
|
||
<!-- #region --> | ||
# Demo notebook | ||
|
||
## Header 2 | ||
|
||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur purus mi, sollicitudin ac justo a, dapibus ultrices dolor. Curabitur id eros mattis, tincidunt ligula at, condimentum urna. | ||
|
||
### Header 3 | ||
|
||
A regular markdown code block | ||
|
||
```python | ||
id_ = 0 | ||
for directory in directories: | ||
rootdir = os.path.join('/Users/drodriguez/Downloads/aclImdb', directory) | ||
for subdir, dirs, files in os.walk(rootdir): | ||
for file_ in files: | ||
with open(os.path.join(subdir, file_), 'r') as f: | ||
doc_id = '_*%i' % id_ | ||
id_ = id_ + 1 | ||
|
||
text = f.read() | ||
text = text.decode('utf-8') | ||
tokens = nltk.word_tokenize(text) | ||
doc = ' '.join(tokens).lower() | ||
doc = doc.encode('ascii', 'ignore') | ||
input_file.write('%s %s\n' % (doc_id, doc)) | ||
``` | ||
|
||
### More markdown things | ||
|
||
> Pellentesque pretium euismod laoreet. Nullam eget mauris ut tellus vehicula consequat. In sed molestie metus. Nulla at various nunc, sit amet semper arcu. Integer tristique augue eget auctor aliquam. Donec ornare consectetur lectus et viverra. Duis vel elit ac lectus accumsan gravida non ac erat. | ||
Ut in ipsum id neque pellentesque iaculis. Pellentesque massa erat, rhoncus id auctor vel, tempor id neque. Nunc nec iaculis enim. Duis eget tincidunt tellus. Proin vitae ultrices velit. | ||
|
||
1. Item 1 | ||
2. Curabitur vel enim at mi dictum venenatis eget eu nulla. Suspendisse potenti. Etiam vitae nibh a odio dictum aliquam. Sed sit amet adipiscing leo, vitae euismod arcu. | ||
3. Item 3 | ||
|
||
Sed vestibulum justo et turpis ullamcorper, a interdum sapien tristique. Donec ullamcorper ipsum ac scelerisque lacinia. Quisque et eleifend odio. Curabitur vel enim at mi dictum venenatis eget eu nulla. Suspendisse potenti. Etiam vitae nibh a odio dictum aliquam. Sed sit amet adipiscing leo, vitae euismod arcu. | ||
|
||
- Item 1 | ||
- Curabitur vel enim at mi dictum venenatis eget eu nulla. Suspendisse potenti. Etiam vitae nibh a odio dictum aliquam. Sed sit amet adipiscing leo, vitae euismod arcu. | ||
- Item 3 | ||
|
||
![Alt text](http://img3.wikia.nocookie.net/__cb20130524024810/logopedia/images/f/fa/Apple_logo_black.svg "Image") | ||
|
||
<hr> | ||
|
||
Sed vestibulum justo et turpis ullamcorper, a interdum sapien tristique. Donec ullamcorper ipsum ac scelerisque lacinia. Quisque et eleifend odio. Curabitur vel enim at mi dictum venenatis eget eu nulla. Suspendisse potenti. Etiam vitae nibh a odio dictum aliquam. Sed sit amet adipiscing leo, vitae euismod arcu. | ||
<!-- #endregion --> | ||
|
||
## Code cells | ||
|
||
This first code cells have some tags | ||
|
||
```python tags=["tag1"] | ||
a = 1 | ||
``` | ||
|
||
```python tags=["tag1", "tag2"] | ||
a | ||
``` | ||
|
||
```python tags=["tag1", "tag2", "tag3"] | ||
b = "pew" | ||
``` | ||
|
||
```python | ||
b | ||
``` | ||
|
||
```python | ||
import re | ||
``` | ||
|
||
```python | ||
text = "foo bar\t baz \tqux" | ||
``` | ||
|
||
```python | ||
re.split("\s+", text) | ||
``` | ||
|
||
```latex | ||
\begin{align} | ||
\nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\ | ||
\nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\ | ||
\nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\ | ||
\nabla \cdot \vec{\mathbf{B}} & = 0 | ||
\end{align} | ||
``` | ||
|
||
```python | ||
import numpy as np | ||
import pandas as pd | ||
``` | ||
|
||
```python | ||
dates = pd.date_range("20130101", periods=6) | ||
df = pd.DataFrame(np.random.randn(6, 4), index=dates, columns=list("ABCD")) | ||
df | ||
``` | ||
|
||
```python | ||
%matplotlib inline | ||
``` | ||
|
||
```python | ||
import matplotlib.pyplot as plt | ||
``` | ||
|
||
```python | ||
from pylab import * | ||
``` | ||
|
||
```python | ||
x = linspace(0, 5, 10) | ||
y = x**2 | ||
``` | ||
|
||
```python | ||
figure() | ||
plot(x, y, "r") | ||
xlabel("x") | ||
ylabel("y") | ||
title("title") | ||
show() | ||
``` | ||
|
||
```python | ||
num_points = 130 | ||
y = np.random.random(num_points) | ||
plt.plot(y) | ||
``` | ||
|
||
This is some text, here comes some latex | ||
|
||
|
||
## Javascript plots | ||
|
||
|
||
### plotly | ||
|
||
```python | ||
import plotly.express as px | ||
``` | ||
|
||
```python | ||
df = px.data.iris() | ||
fig = px.scatter(df, x="sepal_width", y="sepal_length") | ||
fig.show() | ||
``` | ||
|
||
### bokeh | ||
|
||
```python | ||
from bokeh.plotting import figure, output_notebook, show | ||
``` | ||
|
||
```python | ||
output_notebook() | ||
``` | ||
|
||
```python | ||
p = figure() | ||
p.line([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], line_width=2) | ||
show(p) | ||
``` | ||
|
||
```python | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.