import os
from IPython.display import HTML
import ezmarkdown as md
text_md = r"""
##This notebook shows how to use `ezmarkdown` to create standalone HTML documents
+ Based on a series of examples.
+ To install, run the following command in your terminal.
```pip install ezmarkdown```
"""
text_html = md.md_to_html(text_md)
HTML(text_html)
ezmarkdown
to create standalone HTML documentspip install ezmarkdown
# path_img1 = 'data/svgclock.svg'
# path_img2 = 'data/example2.jpg'
# path_img3 = 'data/example4.png'
path_img1 = 'http://upload.wikimedia.org/wikipedia/commons/f/fd/Ghostscript_Tiger.svg'
path_img2 = 'http://upload.wikimedia.org/wikipedia/commons/thumb/3/3e/Einstein_1921_by_F_Schmutzer_-_restoration.jpg/220px-Einstein_1921_by_F_Schmutzer_-_restoration.jpg'
path_img3 = 'http://upload.wikimedia.org/wikipedia/en/thumb/f/f9/Singing_in_the_rain_poster.jpg/220px-Singing_in_the_rain_poster.jpg'
text_md = r"""
#Header One
##Header Two
###Header Three
####Header Four
<p><em>Native</em> <strong>HTML</strong> sample</p>
##Caractères avec accents
+ Un poème de Paul Verlaine
Les sanglots longs
Des violons
De l'automne
Blessent mon cœur
D'une langueur
Monotone.
Tout suffocant
Et blême, quand
Sonne l'heure,
Je me souviens
Des jours anciens
Et je pleure
Et je m'en vais
Au vent mauvais
Qui m'emporte
Deçà, delà,
Pareil à la
Feuille morte.
+ Autre example: çà avec accent, symbole de l'Euro €
+ Et aussi équations Latex inline $\mu$ ou encore $e^{i\pi}=-1$
##Multi line Latex examples
A mathjax expression, by default left-aligned.
$$
\frac{n!}{k!(n-k)!} = \binom{n}{k}
$$
A mathjax expression, centered.
<div class="math_center">
$$
\begin{equation} x = a_0 + \cfrac{1}{a_1 + \cfrac{1}{a_2 + \cfrac{1}{a_3 + \cfrac{1}{a_4} } } } \end{equation}
$$
</div>
A mathjax expression, right-aligned.
<div class="math_right">
$$
A_{m,n} = \begin{pmatrix} a_{1,1} & a_{1,2} & \cdots & a_{1,n} \\ a_{2,1} & a_{2,2} & \cdots & a_{2,n} \\
\vdots & \vdots & \ddots & \vdots \\ a_{m,1} & a_{m,2} & \cdots & a_{m,n} \end{pmatrix}
$$
</div>
##List Example
Here is a list of items :
- Item no 1
- Item no 2
- etc
- Very long item that I need to write on 2 lines
azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty
##A block quote
> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
##Tables
**[links](http://example.com)**
4. Apples
5. Oranges
6. Pears
A centered table
<div class="table_center">
| Header 1 | *Header* 2 |
| -------- | -------- |
| `Cell 1` | [Cell 2](http://example.com) link |
| Cell 3 | **Cell 4** |
</div>
Another table, left-aligned by default.
See how the mathjax expression can be left-aligned or centered in a table cell.
|title1|title2|
|-|-|
|![alt text](%s)|$$\frac{n!}{k!(n-k)!} = \binom{n}{k}$$|
|![alt text](%s)|<div class="math_center">$$\frac{n!}{k!(n-k)!} = \binom{n}{k}$$</div>|
|![alt text](%s)|![alt text](%s)|
###Finally some variables
+ %s
+ %s
+ %s
""" % (path_img1,
path_img1,
path_img2,
path_img3,
'variableA',
'variableB',
'variableC')
text_html = md.md_to_html(text_md)
HTML(text_html)
Native HTML sample
Les sanglots longs
Des violons
De l'automne
Blessent mon cœur
D'une langueur
Monotone.
Tout suffocant
Et blême, quand
Sonne l'heure,
Je me souviens
Des jours anciens
Et je pleure
Et je m'en vais
Au vent mauvais
Qui m'emporte
Deçà, delà,
Pareil à la
Feuille morte.
A mathjax expression, by default left-aligned. $$ \frac{n!}{k!(n-k)!} = \binom{n}{k} $$
A mathjax expression, centered.
A mathjax expression, right-aligned.
Here is a list of items :
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
A centered table
Header 1 | Header 2 |
---|---|
Cell 1 |
Cell 2 link |
Cell 3 | Cell 4 |
Another table, left-aligned by default. See how the mathjax expression can be left-aligned or centered in a table cell.
title1 | title2 |
---|---|
$$\frac{n!}{k!(n-k)!} = \binom{n}{k}$$ | |
$$\frac{n!}{k!(n-k)!} = \binom{n}{k}$$ |
|
selected_cells
is the list of cells that will be written in the html docoutput
indicates.fname = 'demo_ezmarkdown.ipynb'
output = 'saved/output.html'
tpl = md.template.TEMPLATE_OUTPUT_CELLS_ONLY
selected_cells = [1, 3]
md.write_html_doc(fname, output, selected_cells, template=tpl)