Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[译] GitHub 风格的 Markdown 语法 #13

Open
cssmagic opened this issue Jul 7, 2013 · 44 comments
Open

[译] GitHub 风格的 Markdown 语法 #13

cssmagic opened this issue Jul 7, 2013 · 44 comments
Labels

Comments

@cssmagic
Copy link
Owner

cssmagic commented Jul 7, 2013


本文已过时,最新版本已迁至:


© Creative Commons BY-NC-ND 4.0   |   我要订阅   |   我要打赏

@cssmagic
Copy link
Owner Author

cssmagic commented Jul 7, 2013

有一点比较困扰的是,我不知道怎样把 ``` 标记为代码。连输 5 个 ` 并不会得到期望的结果。

@yanxyz
Copy link

yanxyz commented Jul 7, 2013

``` 的行内代码大概只能让解析器添加考虑这种特殊情况。Fenced code blocks 我的翻译是围栏式代码块,对应空格式(缩进式)代码块。

@cssmagic
Copy link
Owner Author

cssmagic commented Jul 7, 2013

@yanxyz 谢谢,我原先也想直译的,但似乎没见过类似的称呼,感觉不够直观,所以加工了一下。如果这已经是程序语言的常见术语,或者是一个成熟的译法,我会改过来。很高兴有人对我的翻译提意见 😄

@yanxyz
Copy link

yanxyz commented Jul 7, 2013

@cssmagic 只是我个人的意见。我翻译过php markdown extra,觉得Fenced code blocks比较形象,直译能保留这种形象感。

@cssmagic
Copy link
Owner Author

cssmagic commented Jul 7, 2013

@yanxyz 谢谢,已更新。

@myst729
Copy link

myst729 commented Jul 8, 2013

不错~

@edokeh
Copy link

edokeh commented Jul 8, 2013

zen mode 经常使用,不过那个按钮在有滚动条出现的时候就悲剧了,可能是偷懒不想用 JS 吧
不知道是否有纯 css 的解决方案呢?

@cssmagic
Copy link
Owner Author

cssmagic commented Jul 8, 2013

@edokeh 不太确定你的意思。我试了一下好像没发现异常情况。

@edokeh
Copy link

edokeh commented Jul 8, 2013

qq20130708183449

@cssmagic
Copy link
Owner Author

cssmagic commented Jul 8, 2013

zen

@edokeh 看起来 GitHub 开发团队用的是 Firefox……

@edokeh
Copy link

edokeh commented Jul 8, 2013

我去。。果然 FF 好的,这个滚动条的出现位置是有什么 CSS 上的讲究嘛?

@myst729
Copy link

myst729 commented Jul 8, 2013

@edokeh 这是FF的bug……

@cssmagic
Copy link
Owner Author

cssmagic commented Jul 8, 2013

@edokeh 不同浏览器对 padding 与滚动条的布局关系的理解不一致。具体谁更标准我还没深入研究过。

@myst729
Copy link

myst729 commented Jul 8, 2013

@cssmagic FF这个是个奇葩,其他任何元素都没见过padding会把滚动条一起带跑的吧…… 规范不贴了,都找得到

@cssmagic
Copy link
Owner Author

原文版本更新到 2013-07-07,向支持团队反馈的笔误均已修正。

@cssmagic
Copy link
Owner Author

cssmagic commented Jul 11, 2013

@yanxyz
关于三个反撇号,我问过支持团队,有解决方案了。写成 ```` ``` ```` 即可。看起来很疯狂,但确实管用。
而且我发现了另一个真相,实际上 <code></code> 标签在 GitHub 这儿是支持的!!!

@myst729
Copy link

myst729 commented Jul 11, 2013

markdown 里一直都可以嵌入 HTML 啊 [挖鼻屎] 不光是 GitHub 这里……

@cssmagic
Copy link
Owner Author

@myst729 这取决于解析引擎的具体实现吧。

@yanxyz
Copy link

yanxyz commented Jul 13, 2013

@cssmagic 哈哈,这么多

@myst729
Copy link

myst729 commented Jul 13, 2013

@cssmagic markdown 语法 http://daringfireball.net/projects/markdown/syntax#html 目前的各种实现——包括 GitHub ——基本上都是它的超集。

@cssmagic
Copy link
Owner Author

@myst729
谢谢提示。不过,(我没有能力研究各种 Markdown 解析引擎的源码,只是纯粹主观臆想,)我总是感觉规范是一回事,实现又是另一回事。这种关系就好像 W3C 与浏览器、CommonJS 与 Node 等等。所以我倾向于认为,各种解析引擎究竟对 Markdown 规范具体支持到什么程度,要试了才知道。

另外,这段话是这样说的:

For any markup that is not covered by Markdown’s syntax, you simply use HTML itself.

显然 <code></code> 标签不在此列。

@cssmagic
Copy link
Owner Author

Emoji 代号速查: http://www.emoji-cheat-sheet.com/

@mistkafka
Copy link

非常谢谢~ 英语渣的痛啊。

@laike9m
Copy link

laike9m commented Nov 16, 2013

赞!虽然之前一直看原文来着

@mistkafka
Copy link

呃 好像才发现 我没有写一个 转字。 不是我翻译的。
MistKafka

On Nov 16, 2013, at 11:24, laike9m notifications@github.com wrote:

赞!虽然之前一直看原文来着


Reply to this email directly or view it on GitHub.

@xaolex
Copy link

xaolex commented Jan 2, 2014

```,在中间的反引号前后各加一个空格。输入几个反引号就要在外围多加1+n个。。

@cssmagic
Copy link
Owner Author

官方文档更新了,添加了删除线的写法:

~~Deleted~~ 将渲染为 Deleted

@spacewander
Copy link

GFM现在支持表格了。

表格

你可以使用若干列文字并于第一行下面用转折号-分开它们,然后用管道符|隔开每一列:

First Header  | Second Header
------------- | -------------
Content Cell  | Content Cell
Content Cell  | Content Cell

为了看上去美观,你也可以在两端加上额外的管道符:

| First Header  | Second Header |
| ------------- | ------------- |
| Content Cell  | Content Cell  |
| Content Cell  | Content Cell  |

注意顶部的虚线不需要准确匹配表头文本的长度:

| Name | Description          |
| ------------- | ----------- |
| Help      | Display the help window.|
| Close     | Closes a window     |

你也可以在其中包括内联Markdown元素,比如链接,加粗,斜体或删除

| Name | Description          |
| ------------- | ----------- |
| Help      | ~~Display the~~ help window.|
| Close     | _Closes_ a window     |

最后,通过在表头行加入冒号:,你可以决定文本是左对齐,右对齐,还是居中:

| Left-Aligned  | Center Aligned  | Right Aligned |
| :------------ |:---------------:| -----:|
| col 3 is      | some wordy text | $1600 |
| col 2 is      | centered        |   $12 |
| zebra stripes | are neat        |    $1 |

一个在最左边的冒号表示一个左对齐的列;一个在最右边的冒号表示一个右对齐的列;两边都有的冒号表示一个居中的列。

最后(这里不再是译文了),加上我自己的一个示范:

水果 单价 数量
苹果 3.00 2
香蕉 2.00 4

注意表格要另隔开一个空行。

@cssmagic
Copy link
Owner Author

@spacewander 谢谢补充。

@xuexb
Copy link

xuexb commented Oct 17, 2014

表格能不能合并行或者列呢...

@cssmagic
Copy link
Owner Author

@xuexb 很遗憾,不能。如果你有单元格跨行跨列的需求,说明你应该直接用 HTML 来写表格。Markdown 一般都支持直接插入 HTML 代码的。

@paddingme
Copy link

@xuexb
Copy link

xuexb commented Jan 14, 2015

@cssmagic 3q

@cssmagic
Copy link
Owner Author

@paddingme
谢谢提醒。由于官方 GFM 文档的组织方式发生了比较大的变动,本文将不再随之改动。如有重要的功能变化,请像 @spacewander 这样在评论区补充。

@JaydenGui
Copy link

good:thumbsup:

@yuanyuanlife
Copy link

哎,原来真的不能合并行列啊~

@yanxyz
Copy link

yanxyz commented Jul 2, 2015

@cssmagic 语法更新了,Newlines 只在评论等地方有效,在文件内跟其它 markdown 一样。要不把 Writing on GitHub 也翻译一下?

@cssmagic
Copy link
Owner Author

cssmagic commented Jul 2, 2015

@yanxyz 谢谢提醒。我这两天把这篇翻译一下。

@cssmagic
Copy link
Owner Author

cssmagic commented Jul 7, 2015

《Writing on GitHub》这篇文档已翻译,已发布到: baixing/FE-Blog#5

@SmartDengg
Copy link

你好,我想请教个有关MD语法的问题,这种包结构,虚线和折线,如何使用MD书写呢。

@cssmagic
Copy link
Owner Author

@SmartDengg
都是手工拼出来的啊,或者是从 bower ls 等命令的输出信息中复制出来的,然后放在代码块中以确保行列对齐。

Markdown 本身没有这方面的渲染功能。不过倒是可以写一个工具,把树形结构的数据转换成这种形式的文本(说不定已经有了)。

随便一提,图中的竖线所用的字符不对。图中用的是管道符(|),但实际上应该用表格竖线()。

@hax
Copy link

hax commented Nov 10, 2015

@SmartDengg 我个人觉得也可以用多个缩进级别的列表来替代。

@SmartDengg
Copy link

@cssmagic 好的,谢谢你的回答,我尝试写一下。

@SmartDengg
Copy link

@hax 恩恩,我试一下缩进,写一下。谢谢你的回答。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests