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:
![Alt text](/path/to/img.jpg)
![Alt text](/path/to/img.jpg "Optional title")
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 href="http://typora.io" 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==
.