测试这个代码插件
省的每次插代码都那么难看
1)用法
_Hello_ `Markdown` **Here**!
上面这行,选中,右键转换,会变成下面这样
Hello Markdown
Here!
2)自带demo
①插件自带demo
源码:
```javascript
function syntaxHighlighting() {
var n = 33;
var s = "hello, こんにちは";
console.log(s);
}
```
* plain
* *emphasis*
* **strong emphasis**
* ~~strikethrough~~
* `inline code`
1. Numbered list
1. Numbered sub-list
1. Numbered sub-sub-list
2. [Link](https://www.google.com)
An image: ![Markdown Here logo](https://raw.githubusercontent.com/adam-p/markdown-here/master/src/common/images/icon24.png)
> Block quote.
> *With* **some** `markdown`.
If **TeX Math** support is enabled, this is the quadratic equation:
$-b \pm \sqrt{b^2 - 4ac} \over 2a$
# Header 1
## Header 2
### Header 3
#### Header 4
##### Header 5
###### Header 6
| Tables | Are | Cool |
| ------------- |:-------------:| -----:|
| column 3 is | right-aligned | $1600 |
| column 2 is | centered | $12 |
| zebra stripes | are neat | $1 |
Here's a horizontal rule:
---
```
code block
with no highlighting
```
上面这一坨,选中,然后转换,会是下面这样:
function syntaxHighlighting() { var n = 33; var s = "hello, こんにちは"; console.log(s); }
- plain
- emphasis
- strong emphasis
strikethrough
- strong emphasis
inline code
- Numbered list
- Numbered sub-list
- Numbered sub-sub-list
- Numbered sub-list
- Link
Block quote.
With somemarkdown
.
If TeX Math support is enabled, this is the quadratic equation:
$-b \pm \sqrt{b^2 - 4ac} \over 2a$
Header 1
Header 2
Header 3
Header 4
Header 5
Header 6
Tables | Are | Cool |
---|---|---|
column 3 is | right-aligned | $1600 |
column 2 is | centered | $12 |
zebra stripes | are neat | $1 |
Here's a horizontal rule:
code block with no highlighting
②官网上的demo
源码:
#### Code
Code can be inline, `using backticks`. Or it can be in blocks, either with backtick "fences" or with indents of four spaces. (I prefer fences.)
```python
print('You get syntax highlighting...')
print('...if you include the language name')
```
You can also syntax-highlight some other cool stuff, like file diffs:
```diff
- This line got removed
+ This line got added
```
#### Math
Math forumlae use TeX. Some examples:
##### The quadratic equation
$-b \pm \sqrt{b^2 - 4ac} \over 2a$
##### The probability of getting (k) heads when flipping (n) coins
$\[P(E) = {n \choose k} p^k (1-p)^{ n-k} \]$
##### The Lorenz Equations
$\dot{x} = \sigma(y-x) \\ \dot{y} = \rho x - y - xz \\ \dot{z} = -\beta z + xy$
##### The Cauchy-Schwarz Inequality
$\[ \left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right) \]$
[Math examples are from here](http://www.mathjax.org/demos/tex-samples/)
效果:
Code
Code can be inline, using backticks
. Or it can be in blocks, either with backtick "fences" or with indents of four spaces. (I prefer fences.)
print('You get syntax highlighting...') print('...if you include the language name')
You can also syntax-highlight some other cool stuff, like file diffs:
- This line got removed + This line got added
Math
Math forumlae use TeX. Some examples:
The quadratic equation
$-b \pm \sqrt{b^2 - 4ac} \over 2a$
The probability of getting (k) heads when flipping (n) coins
$[P(E) = {n \choose k} p^k (1-p)^{ n-k} ]$
The Lorenz Equations
$\dot{x} = \sigma(y-x) \ \dot{y} = \rho x - y - xz \ \dot{z} = -\beta z + xy$
The Cauchy-Schwarz Inequality
$[ \left( \sum{k=1}^n a_k b_k \right)^2 \leq \left( \sum{k=1}^n ak^2 \right) \left( \sum{k=1}^n b_k^2 \right) ]$
上面那些数学公式没开启,因为google api 被GFW了。。。。
3)试用
①下面是一个js的头
```javascript转换:
function syntaxHighlighting() {
var n = 33;
var s = "hello, こんにちは";
console.log(s);
}
```
function syntaxHighlighting() { var n = 33; var s = "hello, こんにちは"; console.log(s); }
```java转换:
public void syntaxHighlighting() {
int n = 33;
String s = "hello, こんにちは";
System.out.print(s);
}
```
public void syntaxHighlighting() { int n = 33; String s = "hello, こんにちは"; System.out.print(s); }
③C的头
```c转换:
//这个就是只能在后面的subFun()中使用,不能用在main()中
char *gVar2 = "I am a global variable."; //全局变量2
void subFunc() {
char *buffer = "I am in subFunc."; //局部变量
printf("\n这是在subFunc程序中:\n");
printf("gVar1 = [%d]\n", gVar1);
// printf("num = [%d]\n", num);
printf("gVar2 = [%s]\n", gVar2);
printf("buffer = [%s]\n", buffer);
return;
}
```
//这个就是只能在后面的subFun()中使用,不能用在main()中 char *gVar2 = "I am a global variable."; //全局变量2 void subFunc() { char *buffer = "I am in subFunc."; //局部变量 printf("\n这是在subFunc程序中:\n"); printf("gVar1 = [%d]\n", gVar1); // printf("num = [%d]\n", num); printf("gVar2 = [%s]\n", gVar2); printf("buffer = [%s]\n", buffer); return; }
。。。。有什么区别吗。。。。
④python头
源码:
```python转换:
class testDict(dict):
'''
这是一个简单的文档注释
>>> d1 = testDict();
>>> d1["x"] = 100;
>>> d1.x
100
>>> d1.y = 200;
>>> d1["y"]
200
>>> d2 = testDict(a=1,b=2,c="fuck");
>>> d2.c
'fuck'
>>> d2['empty']
Traceback (most recent call last):
...
KeyError: 'empty'
>>> d2.empty
Traceback (most recent call last):
...
AttributeError: 'testDict'对象没属性 empty !
'''
def __init__(self,**kw):
super().__init__(**kw);
def __getattr__(self,key):
try:
return self[key];
except KeyError:
raise AttributeError(r"'testDict'对象没属性 %s !" % key);
def __setattr__(self,key,value):
self[key] = value;
if __name__ == "__main__":
import doctest;
doctest.testmod();
```
class testDict(dict): ''' 这是一个简单的文档注释 >>> d1 = testDict(); >>> d1["x"] = 100; >>> d1.x 100 >>> d1.y = 200; >>> d1["y"] 200 >>> d2 = testDict(a=1,b=2,c="fuck"); >>> d2.c 'fuck' >>> d2['empty'] Traceback (most recent call last): ... KeyError: 'empty' >>> d2.empty Traceback (most recent call last): ... AttributeError: 'testDict'对象没属性 empty ! ''' def __init__(self,**kw): super().__init__(**kw); def __getattr__(self,key): try: return self[key]; except KeyError: raise AttributeError(r"'testDict'对象没属性 %s !" % key); def __setattr__(self,key,value): self[key] = value; if __name__ == "__main__": import doctest; doctest.testmod();
⑤html
源码:
```html转换:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
测试
</body>
</html>
```
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> 测试 </body> </html>
⑥C#
源码:
```c#转换:
internal IDbCommand SetupCommand(IDbConnection cnn, Action<IDbCommand, object> paramReader)
{
var cmd = cnn.CreateCommand();
var init = GetInit(cmd.GetType());
if (init != null) init(cmd);
if (transaction != null)
cmd.Transaction = transaction;
cmd.CommandText = commandText;
if (commandTimeout.HasValue)
cmd.CommandTimeout = commandTimeout.Value;
if (commandType.HasValue)
cmd.CommandType = commandType.Value;
if (paramReader != null)
{
paramReader(cmd, parameters);
}
return cmd;
}
```
internal IDbCommand SetupCommand(IDbConnection cnn, Action<IDbCommand, object> paramReader) { var cmd = cnn.CreateCommand(); var init = GetInit(cmd.GetType()); if (init != null) init(cmd); if (transaction != null) cmd.Transaction = transaction; cmd.CommandText = commandText; if (commandTimeout.HasValue) cmd.CommandTimeout = commandTimeout.Value; if (commandType.HasValue) cmd.CommandType = commandType.Value; if (paramReader != null) { paramReader(cmd, parameters); } return cmd; }
⑦linux shell
源码:
```shell转换:
#!/bin/bash
user=senrsl #替换用户名
vpnuuid=08ee8704-f0c2-49a2-aa80-7cf8be4b0f63 #替换UUID
while true
do
if [[ "$(nmcli con status|grep $vpnuuid)" == "" ]]; then
echo "Disconnected, trying to reconnect..."
sleep 1s
su $user -c "nmcli con up uuid $vpnuuid"
else
echo "Already connected !" `date`
fi
sleep 900
done
#查看UUID
#senrsl@senrsl-T540p:~$ nmcli con list
#名称 UUID 类型 真实时间戳
#云梯港1 08ee8704-f0c2-49a2-aa80-7cf8be4b0f63 vpn 2015年10月21日 星期三 17时28分50秒
#启动脚本
#senrsl@senrsl-T540p:~/test/vpn$ sudo su
#[sudo] password for senrsl:
#root@senrsl-T540p:/home/senrsl/test/vpn# ./reconnect.sh
#Disconnected, trying to reconnect...
#Already connected !
```
#!/bin/bash user=senrsl #替换用户名 vpnuuid=08ee8704-f0c2-49a2-aa80-7cf8be4b0f63 #替换UUID while true do if [[ "$(nmcli con status|grep $vpnuuid)" == "" ]]; then echo "Disconnected, trying to reconnect..." sleep 1s su $user -c "nmcli con up uuid $vpnuuid" else echo "Already connected !" `date` fi sleep 900 done #查看UUID #senrsl@senrsl-T540p:~$ nmcli con list #名称 UUID 类型 真实时间戳 #云梯港1 08ee8704-f0c2-49a2-aa80-7cf8be4b0f63 vpn 2015年10月21日 星期三 17时28分50秒 #启动脚本 #senrsl@senrsl-T540p:~/test/vpn$ sudo su #[sudo] password for senrsl: #root@senrsl-T540p:/home/senrsl/test/vpn# ./reconnect.sh #Disconnected, trying to reconnect... #Already connected !
⑧make
源码:
```make
```
转换:
。。。。。好吧,不玩了
发送看看,之前用的在线的,贴过来,结果blospot显示不出来。。。。
希望这个好用吧。
2016年06月29日12:02:47
2016年06月29日10:46:16
没有评论 :
发表评论