0.方法零
ctrl + k ( 0 0 对!就素辣麽简单! )
1.方法一
在代码前后加<pre><code></code></pre>:
下面是我写的java源代码:
<pre><code>
package com.example; public class Test2 { public static void main(String[] args) { System.out.println("Hello World."); } }
</code></pre>
2.方法二:
To create code blocks or other preformatted text, indent by four spaces:
This will be displayed in a monospaced font. The first four spaces
will be stripped off, but all other whitespace will be preserved.
Markdown and HTML are turned off in code blocks:
<i>This is not italic</i>, and [this is not a link](http://example.com)
To create not a block, but an inline code span, use backticks:
The `$` character is just a shortcut for `window.jQuery`.
If you want to have a preformatted block within a list, indent by eight spaces:
1. This is normal text.
2. So is this, but now follows a code block:
Skip a line and indent eight spaces.
That's four spaces for the list
and four to trigger the code block.
如果想要输入一段代码,或者其他的預格式化文本,缩进4个空格:
这段文字会以一种等宽字体的格式呈现。行首的4个空格会
被屏蔽掉,但是之后的空格就会正常显示。
Markdown 和 HTML 在代码块里都会被屏蔽掉:
<i>这不会被显示成斜体</i>,以及[这也不会被显示成超链接](http://example.com)
如果要创建一个内联的代码行而不是代码块的话,就使用反引号:
~$~符号就是~window.jQuery~简写形式。
如果你想要在一个清单里插入一段预格式化的段落,就缩进8个空格:
1.这是正常的文本。
2.这也是正常的文本,但是接下来它会紧接着一段代码:
跳过一行,并缩进8个空格。
4个空格是为了清单而输入的,而另外4个是为了表示这
是一段代码。