• 27
  • 十一月

一个Wordpress中显示代码高亮的插件——wp-syntax

Kenami 发布于 15:38:17  |  阅读 302 次 |  评论  

以前用的代码高亮插件是:google-syntax-highlighter,因为博客更新了,也想找找有没有更好的代码高亮插件,看到用wp-syntax 的人比较多,所以就装个看看,总体感觉效果不错。

下面附上一些例子:
PHP

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
class NTLMSoapClient extends SoapClient {
	function __doRequest($request, $location, $action, $version) {
 
		$headers = array(
			'Method: POST',
			'Connection: Keep-Alive',
			'User-Agent: PHP-SOAP-CURL',
			'Content-Type: text/xml; charset=utf-8',
			'SOAPAction: "'.$action.'"',
		);
 
		$this->__last_request_headers = $headers;
		$ch = curl_init($location);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
		curl_setopt($ch, CURLOPT_POST, true );
		curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
		curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
		curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
		curl_setopt($ch, CURLOPT_USERPWD, $this->user.':'.$this->password);
		$response = curl_exec($ch);
 
		return $response;
	}
 
	function __getLastRequestHeaders() {
		return implode("\n", $this->__last_request_headers)."\n";
	}
}
 
// Authentification parameter
class MyServiceNTLMSoapClient extends NTLMSoapClient {
	protected $user = 'myuser';
	protected $password = '*******';
}


XML

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <SmbppSendUnicodeMessage xmlns="http://wapdm.com/SmbpHttpAgent/">
      <bstrMoMessageID>string</bstrMoMessageID>
      <bstrBusinessCode>string</bstrBusinessCode>
      <bstrLongCode>string</bstrLongCode>
      <bstrFeeMsisdn>string</bstrFeeMsisdn>
      <bstrDesMsisdn>string</bstrDesMsisdn>
      <bstrMessageContent>string</bstrMessageContent>
      <lTpPid>int</lTpPid>
      <lTpUdhi>int</lTpUdhi>
      <lSendDate>int</lSendDate>
      <lSendTime>int</lSendTime>
      <lExpireDate>int</lExpireDate>
      <lExpireTime>int</lExpireTime>
    </SmbppSendUnicodeMessage>
  </soap:Body>
</soap:Envelope>

.NET

private int parseWAPDMResponse(string inStr) 
{
	int Result=0;
	try
	{
		//创建XmlDocument实例
		XmlDocument x = new XmlDocument();
		//加载 XML 
		x.LoadXml(inStr);
		//获取根节点的名字
		string name =  x.DocumentElement.LocalName;
		//进行判断
		if(name.Equals("IMessageID"))
		{
			//读取Result节点
			XmlNodeList node = x.GetElementsByTagName("Result");
			Result = Convert.ToInt32( node.Item(0).InnerText );	
		}
		else
		{
			Result = WAPDM_ERROR;
		}
	}
	catch(Exception ex)
	{
		Result = WAPDM_ERROR;
		Console.WriteLine(ex.ToString());
	}
	return Result;
}

评论