使用jupyter notebook markdown 寫blog
在cmd下輸入以下命令
jupyter nbconvert --to html jupyter-blog.ipynb
簡化的html,用於嵌入網頁、博客等,這不包括html標題。
jupyter nbconvert --to html --template basic jupyter-blog.ipynb
還可以指定參數:ExecutePreprocessor.timeout
jupyter nbconvert --to html --no-prompt matplotlib.ipynb
jupyter nbconvert --to html --no-input matplotlib.ipynb
具體參數使用參考網站:https://nbconvert.readthedocs.io/en/latest/usage.html
Headers(標題)
<code> # this is atag(一級標題)
/<code>
## This is antag(二級標題)
###### This is antag(六級標題)
Emphasis(強調)
強調是通過在文字兩側加入星號(*)、下劃線(_)和波浪線(~)等符號實現的,注意符號和需要強調的文字之間沒有空格!
*This text will be italic* (包括在兩個*之間的文字為斜體,其他類似)_This will also be italic_ (斜體)**This text will be bold** (黑體)__This will also be bold_ (黑體)
~~This text will be deleted~~ (刪除線)
__You **can **combine them_ (可以多種格式複合使用)
List(列表)
Unordered(無序列表)
無序列表用 - + * 任何一種都可以,注意符號和文字之間有空格!
<code>* Item 1
* Item 2
* Item 2a
* Item 2b/<code>
- Item 1
- Item 2Item 2aItem 2b
Ordered(順序列表)
使用數字加點的方式,數字和點之間沒有空格,而點和後面的文字之間有空格!無序列表和有序列表都可以進行嵌套。
<code>1. Item 1
1. Item 2
* Item 2a(無序)
* Item 2b(無序)
1. Item 3
1. Item 3a
1. Item 3b/<code>
- Item 1
- Item 2Item 2a(無序)Item 2b(無序)
- Item 3Item 3aItem 3b
Blockquotes(引用)
引用的內容可以用 >來表示,比如本文中所有對命令的說明都採用了引用的方式。
<code>> We're living the future so
> the present is our past./<code>
We're living the future so the present is our past.
Code(代碼)
- Inline code(行內代碼)
代碼之間分別用一個反引號(`)包起來。
`print 'Hello world!'`
- Code blocks(代碼塊)
連用三個反引號(```)將代碼包起來。 行尾不要空兩個加回車
```
<code>def f(x):
return x**2 + 2*x + 1/<code>
```
Horizontal rules(分割線)
三個或者三個以上的 - 或者 都可以。輸入`**或者-----`
換行 用
來換行或者空兩個加回車
Useful syntax(插入對象)
介紹如何插入一些有用的對象,比如表格、圖像和公式等,以及其他一些有用的語法。
Tables(表格)
表格的插入非常簡單,只需要按照如下語法畫出表格形狀即可,在編輯代碼時不需要考慮對齊(但是為了美觀和邏輯的直觀,建議代碼整齊)。豎線(|)用於分欄,短橫線(-)用於分割表頭和其餘部分,冒號(:)用於標記表格內容的對齊方式(默認為左對齊)。如果嫌麻煩,這裡有個神奇的表格生成網站https://www.tablesgenerator.com/markdown_tables,可以直接生成你所需要的代碼,而且不止有Markdown代碼,還有Latex和HTML代碼!
|表頭|表頭|表頭| |:-------|:------:|------:| |內容|內容|內容|
表頭表頭表頭內容內容內容
Images(圖像)
用 ![名稱](圖片地址 "標題") 可以添加在線圖片或本地圖片
![Github](url "title")(添加在線圖片)![Github](/images/logo.png "title")(添加本地圖片)
Links(鏈接)
用 [名稱](地址 "標題") 可以添加超鏈接,語法和添加圖片類似,只是少了歎號。
[GitHub](http://github.com "title")
Equations(公式)
公式的編輯採用Latex語法,如果讀者對Latex語法不熟悉,同樣為大家提供一個神奇的網站https://www.codecogs.com/latex/eqneditor.php。
這是行內公式:
$E=mc^2$
E=mc2E=mc2
這是公式塊:
<code>$$
e^{i\\theta} = \\cos \\theta +i\\sin \\theta \\
e^z = 1 + \\frac{z}{1!} + \\frac{z^2}{2!} + \\frac{z^3}{3!} + \\cdots = \\sum_{n=0}^{\\infty}\\frac{z^n}{n!}
$$/<code>
效果如下:
eiθ=cosθ+isinθ ez=1+z1!+z22!+z33!+⋯=∑n=0∞znn!eiθ=cosθ+isinθ ez=1+z1!+z22!+z33!+⋯=∑n=0∞znn!
Footnotes(腳註)
<code>在文中使用[^1]的方式標記腳註,
在文末使用[^1]:加入參考文獻,注意要使用英文冒號,後面有無空格均可。/<code>
Backslash(反斜線)
如果想要插入以上內容中用到的一些符號(字面上,而非功能性應用),比如希望插入星號(*),但不是用這個星號來表示斜體或加粗等,那麼可以在符號前面加反斜線(\\)以插入這些普通符號。
<code>\\ 反斜線
` 反引號
* 星號
_ 底線
{} 花括號
[] 方括號
() 括弧
# 井字號
+ 加號
- 減號
. 英文句點
! 驚歎號/<code>
python畫圖
In [10]:
<code>%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(20)
y = x**2
plt.plot(x, y)
/<code>
Out[10]:
<code>[<matplotlib.lines.line2d>]/<matplotlib.lines.line2d>/<code>
閱讀更多 流著看看 的文章