Typora中的Markdown
概述
Markdown Daring Fireball創建的。最初的指導手冊. 但是,它的語法在不同的解析器或編輯器之間是不同的 Typora 用的是 GitHub風格的markdown.
請注意,markdown源代碼中的HTML片段將被識別,但不會被解析或呈現。此外,在保存后,原始的markdown源代碼可能會有小的重新格式化。
塊級元素
段落和換行符
段落只是一個或多個連續的文本行。在markdown源代碼中,段落被多個空行分隔。在Typora中,你只需要按“Return”來創建一個新段落。
按 Shift
+ Return
來創建一個換行符。 但是,大多數markdown解析器將忽略單行換行符, 為了讓其他編輯器能識別您的換行符,你最好在行末添加2個空格,或者插入<br/>
。
標題
有以下1-6級標題例如:
# This is an H1
## This is an H2
###### This is an H6
在Typora中,輸入‘#’再加上你的內容,然后回車就創建了一個標題
引用
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 another blockquote with one paragraph. There is three empty line to seperate two blockquote.
在typora中,只需輸入' > ',后面跟著引號內容,就會生成塊引號。Typora會為你插入合適的>或換行符。通過添加額外的“>”級別,可以在另一個語句塊中引用塊引號。
列表
輸入 * 列表項1
將創建無序列表, *
也可以替換成 +
or -
.
輸入1. 列表項 1
將創建一個有序列表,markdown代碼如下:
## 無序列表
* 紅
* 綠
* 藍
## 有序列表
1. 紅
2. 綠
3. 藍
任務列表
任務列表是帶有標記為[]或x項的列表。例如:
- [ ] 一條任務列表項
- [ ] 任務列表的語法要求
- [ ] normal **formatting**, @mentions, #1234 refs
- [ ] incomplete
- [x] completed
你可以點擊元素前面的復選框來更改完成和未完成狀態。
保護的代碼塊
Typora只支持Github風格的Markdown。不支持markdown中的原始代碼塊。
使用保護代碼塊很簡單: 輸入 ``` 并且按 回車
. 在```之后添加一個可選的語言標識符,我們將通過語法高亮顯示運行它:
舉個栗子
```
function test() {
console.log("notice the blank line before this function?");
}
```
ruby語法高亮:
```ruby
require 'redcarpet'
markdown = Redcarpet.new("Hello World!")
puts markdown.to_html
```
數學塊
你可以使用MathJax來渲染LaTeX數學表達式。
輸入 $$
, 再按 '回車鍵' 將觸發一個輸入字段,您可以在這兒輸入 Tex/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}
在markdown源文件中,math塊是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}
$$
表格
輸入 | 標題1 | 標題2 |
再按 回車
將創建一個兩列的表格.
創建表之后,將焦點放在該表上,將彈出一個表的工具欄,您可以在其中調整、對齊或刪除表。您還可以使用上下文菜單來復制和添加/刪除列/行。
可以跳過以下描述,因為typora自動生成表的markdown源代碼。
在markdown代碼中要這么生成表格:
| 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 |
冒號左邊的一側表示左對齊列;最右邊一側冒號表示右對齊列;雙方一個冒號表示居中對齊列。
而使用Typora不用這么麻煩些表格,當你在Typora創建表格之后,會自動出現工具幫助你實現以上的功能,最大限度的聚焦在你的思路上。
注腳
您可以創建這樣的腳注[^footnote].
[^footnote]: 寫點啥呢? *寫點斜體的* 或者 **粗體的**.
這樣就能創建這樣的東西:鼠標放在在“腳注”上能看到腳注的內容。
分割線
在空白行輸入 ***
或者 ---
再按 回車
將畫一條分割線。
YAML Front Matter
Typora support YAML Front Matter now. Input ---
at the top of the article and then press Enter
will introduce one. Or insert one metadata block from the menu.
目錄 (TOC)
輸入 [toc]
再按 回車
會創建一個目錄的段落,這個目錄會提取作者的所有標題,它的內容會自動更新。樣子是這樣的:
圖(序列圖、流程圖、人魚圖)
Typora 支持, 徐磊圖, 流程圖 and 人魚圖,在系統偏好設置中能啟用這些特性。
欲知詳情請看 圖表文檔
Span 元素
在您輸入之后,Span元素將被解析并呈現。將光標移動到這些span元素的中間將把這些元素擴展為markdown源代碼。下面將解釋這些span元素的語法。
鏈接
Markdown支持兩種風格的鏈接:內聯和參考。
這2種風格,鏈接文本用[]包裹。
要創建內聯鏈接,請在鏈接文本的結束方括號之后立即使用一組常規圓括號。在括號內,將URL放置在您希望鏈接指向的地方,以及鏈接的可選標題,并在引號中包圍。例如:
這里是 [百度](http://baidu.com/ "百度的首頁") .
[沒有注釋的鏈接](http://baidu.com/) 沒有title的注釋.
will produce:
這里是 百度 .
沒有注釋的鏈接 沒有title的注釋
內部鏈接
You can set the href to headers, which will create a bookmark that allow you to jump to that section after clicking. For example:
Command(on Windows: Ctrl) + Click This link will jump to header Block Elements
. To see how to write that, please move cursor or click that link with ?
key pressed to expand the element into markdown source.
Reference Links
Reference-style links use a second set of square brackets, inside which you place a label of your choosing to identify the link:
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"
In typora, they will be rendered like:
This is an example reference-style link.
The implicit link name shortcut allows you to omit the name of the link, in which case the link text itself is used as the name. Just use an empty set of square brackets — e.g., to link the word “Google” to the google.com web site, you could simply write:
[Google][]
And then define the link:
[Google]: http://google.com/
In typora click link will expand it for editing, command+click will open the hyperlink in web browser.
URLs
Typora allows you to insert urls as links, wrapped by <
brackets>
.
<i@typora.io>
becomes i@typora.io.
Typora will aslo auto link standard URLs. e.g: www.google.com.
Images
Image looks similar with links, but it requires an additional !
char before the start of link. Image syntax looks like this:


You are able to use drag & drop to insert image from image file or we browser. And modify the markdown source code by clicking on the image. Relative path will be used if image is in same directory or sub-directory with current editing document when drag & drop.
For more tips on images, please read http://support.typora.io//Images/
Emphasis
Markdown treats asterisks (*
) and underscores (_
) as indicators of emphasis. Text wrapped with one *
or _
will be wrapped with an HTML <em>
tag. E.g:
*single asterisks*
_single underscores_
output:
single asterisks
single underscores
GFM will ignores underscores in words, which is commonly used in code and names, like this:
wow_great_stuff
do_this_and_do_that_and_another_thing.
To produce a literal asterisk or underscore at a position where it would otherwise be used as an emphasis delimiter, you can backslash escape it:
\*this text is surrounded by literal asterisks\*
Typora recommends to use *
symbol.
Strong
double *’s or _’s will be wrapped with an HTML <strong>
tag, e.g:
**double asterisks**
__double underscores__
output:
double asterisks
double underscores
Typora recommends to use **
symbol.
Code
To indicate a span of code, wrap it with backtick quotes (`). Unlike a pre-formatted code block, a code span indicates code within a normal paragraph. For example:
Use the `printf()` function.
will produce:
Use the printf()
function.
Strikethrough
GFM adds syntax to create strikethrough text, which is missing from standard Markdown.
~~Mistaken text.~~
becomes Mistaken text.
Underline
Underline is powered by raw HTML.
<u>Underline</u>
becomes <u>Underline</u>.
Emoji :smile:
Input emoji with syntax :smile:
.
User can trigger auto-complete suggestions for emoji by pressing ESC
key, or trigger it automatically after enable it on preference panel. Also, input UTF8 emoji char directly from Edit
-> Emoji & Symbols
from menu bar is also supported.
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:
<img src="http://www.w3.org/html/logo/img/mark-word-icon.png" width="200px" />
(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.
Inline Math
To use this feature, first, please enable it in Preference
Panel -> Markdown
Tab. Then use $
to wrap TeX command, for example: $\lim_{x \to \infty} \exp(-x) = 0$
will be rendered as LaTeX command.
To trigger inline preview for inline math: input “$”, then press ESC
key, then input TeX command, a preview tooltip will be visible like below:
<img src="http://typora.io/img/inline-math.gif" style="zoom:50%;" />
Subscript
To use this feature, first, please enable it in Preference
Panel -> Markdown
Tab. Then use ~
to wrap subscript content, for example: H~2~O
, X~long\ text~
/
Superscript
To use this feature, first, please enable it in Preference
Panel -> Markdown
Tab. Then use ^
to wrap superscript content, for example: X^2^
.
Highlight
To use this feature, first, please enable it in Preference
Panel -> Markdown
Tab. Then use ==
to wrap superscript content, for example: ==highlight==
.