這篇文章簡單介紹Typora這款Markdown語法編輯器,以及精講它支持的Markdown語法。
Typora
Typora的官網是https://www.typora.io/,里面有詳盡的介紹和展示,下面我摘取一些片段介紹一下該編輯器的特性。
用它進行Markdown文件的閱讀和寫作可以用“美”字來形容,具體體現在三大體驗感中:
- 自由隨心
- 實時無縫預覽
- 所見即所得
喜歡它,因為它簡約又強大。下面看下它的一些特性——
插入圖片
生成標題
生成列表
表格
代碼塊
數學公式
圖解
行內樣式
除此之外,它可以方便地管理md文件,在文章標題間快速跳轉,支持YAML頭信息,導入和輸出成通用的文件格式。
還有大量我完全沒用過的特性,像支持其他插件進行擴展、修改主題、自動匹配等等。關鍵是開發團隊還在不斷地維護和開發這個軟件,并且我們可以免費使用它。我之前也用過不少的Markdown語法編輯器,這個是我一用上就離不開的,無論是在Windows上還是Ubuntu上,我都可以用它進行快速流暢的文檔創作(當然它也支持Mac)。
它對英文字體支持非常棒,看起來很舒服。可惜在Windows上對中文字體的顯示不太友好,看起來有點丑。好像可以更換字體,不過沒有嘗試過。
Markdown
之前推薦過Markdwon的語法介紹,像我在Github上fork的https://github.com/ShixiangWang/README。當然百度也能搜出大量的該語法介紹。這里我想根據Typora官方提供的Markdown參考精講一下它支持的語法特性。
塊元素
段落和換行符
在Markdown源碼中需要多個空行才能重啟一段,Typora中只需要按下Enter
鍵即可。
按下Shift
+Enter
鍵會創建一個單個換行符,但是大多數Markdown語法解析器都會忽略它。我們可以通過在一行的末尾加兩個空格鍵,或者插入<br/>
。
標題
在一行的開始加1-6個井號鍵,對應著文章的1-6級標題。
# 這是一級標題
## 這是二級標題
###### 這是六級標題
一般建議標題不要超過三級,不然可能層級太多影響閱讀。
引用
Markdown用>
代表引用,格式看起來如下:
> This is a blockquote with two paragraphs. This is first paragraph.
>
> This is second pragraph.Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
This is a blockquote with two paragraphs. This is first paragraph.
This is second pragraph.Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
列表
*
和+
,-
三種字符都能用來創建無序列表,但最好不要混用。有序列表用數字加.
號即可創建。
## un-ordered list
* Red
* Green
* Blue
## ordered list
1. Red
2. Green
3. Blue
un-ordered list
- Red
- Green
- Blue
ordered list
- Red
- Green
- 3.Blue
任務列表
任務列表用[]或[x]標記(未完成或完成)。、
- [ ] a task list item
- [ ] list syntax required
- [ ] normal **formatting**, @mentions, #1234 refs
- [ ] incomplete
- [x] completed
- [ ] a task list item
- [ ] list syntax required
- [ ] normal formatting, @mentions, #1234 refs
- [ ] incomplete
- [x] completed
在Typora中直接可以點擊來修改任務完成的狀態。
代碼塊
Typora只支持Github的Markdown語法,對源代碼塊(Markdown有不同的種類,所以有些地方不太一樣)不支持。
Typora中只需要鍵入```并按下Enter鍵就可以輸入代碼塊了。在```后面可以加上你使用的語言名。Typora會自動進行語法高亮。
Here's an example:
?```
function test() {
console.log("notice the blank line before this function?");
}
?```
syntax highlighting:
?```ruby
require 'redcarpet'
markdown = Redcarpet.new("Hello World!")
puts markdown.to_html
?```
function test() {
console.log("notice the blank line before this function?");
}
語法高亮:
require 'redcarpet'
markdown = Redcarpet.new("Hello World!")
puts markdown.to_html
數學公式塊
我們可以使用MathJax語法輸入LaTex數學公式。
用一個$
開始和結尾會生成行內公式。而用$$
開始和結尾并單獨生成公式塊。
$$
\mathbf{V}_1 \times \mathbf{V}_2 = \begin{vmatrix}
\mathbf{i} & \mathbf{j} & \mathbf{k} \
\frac{\partial X}{\partial u} & \frac{\partial Y}{\partial u} & 0 \
\frac{\partial X}{\partial v} & \frac{\partial Y}{\partial v} & 0 \
\end{vmatrix}
$$
比如我們如果要生成如上公式,需要輸入
$$
\mathbf{V}_1 \times \mathbf{V}_2 = \begin{vmatrix}
\mathbf{i} & \mathbf{j} & \mathbf{k} \\
\frac{\partial X}{\partial u} & \frac{\partial Y}{\partial u} & 0 \\
\frac{\partial X}{\partial v} & \frac{\partial Y}{\partial v} & 0 \\
\end{vmatrix}
$$
表格
輸入 | First Header | Second Header |
并按下 Enter
鍵會返回兩列的表。
一旦表格生成,我們可以像使用Excel一樣對表格進行對齊、添加、修改、刪除操作。
本身的源代碼是這樣的:
| First Header | Second Header |
| ------------- | ------------- |
| Content Cell | Content Cell |
| Content Cell | Content Cell |
看看效果:
First Header | Second Header |
---|---|
Content Cell | Content Cell |
Content Cell | Content Cell |
可以用:
符號進行對齊操作。
比如:
| Left-Aligned | Center Aligned | Right Aligned |
| :------------ |:---------------:| -----:|
| col 3 is | some wordy text | $1600 |
| col 2 is | centered | $12 |
| zebra stripes | are neat | $1 |
它將顯示成:
Left-Aligned | Center Aligned | Right Aligned |
---|---|---|
col 3 is | some wordy text | $1600 |
col 2 is | centered | $12 |
zebra stripes | are neat | $1 |
腳注
You can create footnotes like this[^footnote].
[^footnote]: Here is the *text* of the **footnote**.
第一行是文本,第二行是對標記字符進行解釋。當把鼠標指向腳注時,會看到解釋內容。
You can create footnotes like this[1].
水平線
有時候我們想要水平線來進行文本內容分割,可以在空白行上使用***
或者---
然后按下回車鍵即可。
YAML頭信息
Typora支持YAML頭信息,一般網頁需要寫這個。在文檔的開始鍵入---
然后按下回車鍵就會生成一個獨立的區塊可以寫入YAML頭信息。
目錄
輸入[toc]
并按下回車鍵會自動生成文章目錄(這個在Github和簡書上好像都不支持)。
圖解
不翻譯了,拷貝。
Typora supports, sequence, flowchart and mermaid, after this feature is enabled from preference panel.
See this document for detail.
Span元素
鏈接
Markdown支持兩種格式的鏈接:行內鏈接和參考鏈接。
兩種鏈接中,文本信息都用[]
限定。
常用的就是行內鏈接了,平常我們點擊網址,然后瀏覽器會自動跳轉并打開就屬于這種。
它又分為有標題的和沒標題的:
This is [an example](http://example.com/ "Title") inline link.
[This link](http://example.net/) has no title attribute.
This is an example inline link.
This link has no title attribute.
內部鏈接
我們可以把鏈接指向文本的某個標題,這樣就能夠實現文章內部的跳轉,像書簽一樣。
這個功能我沒太摸清楚,參考的markdown文章中是能用的。有興趣的可以看下,在下方留評。
參考鏈接
兩個[]
,第一個寫文本信息,第二個寫鏈接ID。
This is [an example][id] reference-style link.
Then, anywhere in the document, you define your link label like this, on a line by itself:
[id]: http://example.com/ "Optional Title Here"
This is an example reference-style link.
Then, anywhere in the document, you define your link label like this, on a line by itself:
這就像寫文章的參考文獻一樣。
有趣的是第二個方括號內內容可以省略,第一個方括號內內容會當作ID使用。
[Google][]
And then define the link:
[Google]: http://google.com/
Google
And then define the link:
URLs
直接用<>
可以插入網址。
<i@typora.io>
becomes i@typora.io.
圖片
插入圖片與插入鏈接相似,不過要在最前面加!
做區別。

# 左邊是圖片標題,右邊是地址,可以是url,也可以是本地的圖片地址(注意絕對路徑和相對路徑的區別,可以在Typora中設定)

比如我在文章最前面插的那些圖片:

效果就是
強調
有時候我們需要對文本進行強調,方式是斜體。可以用*
或_
分隔要強調的文本。
*single asterisks*
_single underscores_
輸出:
single asterisks
single underscores
它們是可以和引用,以及后面講的加粗連用的。
如果我們需要輸出*
鍵,可以用\
進行轉義。
加粗
強調用一個符號,加粗用兩個。
**double asterisks**
__double underscores__
double asterisks
double underscores
Markdown一般都推薦使用*
作為分隔符。
代碼
加入行內代碼,只需要用`分隔即可。
Use the `printf()` function.
Use the printf()
function.
刪除線
文本前后用兩個~
符號:
~~Mistaken text.~~
becomes Mistaken text.
下劃線
跟HTML語法一樣。
<u>Underline</u>
becomes <u>Underline</u>.
表情:happy:
插入笑臉用:smile
,得到:smile:
還有其他一些標簽,鍵入:
會根據后面的英文字符查找相關表情。
比如:cry:
,:cry:
遵循這樣的規則使用即可。
HTML
Typora只支持有限的HTML語法,如下,我就不翻譯了。
Typora cannot render html fragments. But typora can parse and render very limited HTML fragments, as an extension of Markdown, including:
- Underline:
<u>underline</u>
- Image:

(Andwidth
,height
attribute in HTML tag, andwidth
,height
,zoom
style instyle
attribute will be applied.) - Comments: ``
- Hyperlink:
<a target="_blank">link</a>
.
Most of their attributes, styles, or classes will be ignored. For other tags, typora will render them as raw HTML snippets.
But those HTML will be exported on print or export.
行內數學公式
前面提到了,這里舉個例子。
$\lim_{x\to\infty}\exp(-x)=0$
$\lim_{x\to\infty}\exp(-x)=0$
同樣的公式,我用$$
分隔就會變成:
$$
\lim_{x\to\infty}\exp(-x)=0
$$
可以看到顯示效果的不同哈。
下標
用一個~
,如果要寫水分子,我們可以使用H~2~O
,它就會變成H2O.
這個功能默認沒打開,To use this feature, first, please enable it in Preference
Panel -> Markdown
Tab.
現在看看H2O。
上標
用一個^
前后分隔。
X的平方可以表示為X^2^
,即X2 。
高亮
用兩個==
在前后分隔對文本高亮。
==highlight==
會變成
==highlight==
最后的話
因為個人能力有限,翻譯和講解不可能盡善盡美,望諒解。
關于Typora的使用除了查看本文檔外,還需要大家自己多摸索。用Ctrl
加逗號鍵可以打開Typora的選項設定,有的功能沒有激活,需要我們手動設定下,也可以看看有其他什么有趣有用的功能。歡迎留言評論。
最后說明,因為Markdown編輯器不同,簡書或者博客上查閱可能有一些小問題。以Typora編輯器為準。為保證文章目錄正常,去掉了一些實例顯示。
-
Here is the text of the footnote. ?