對於各種碼農來說,用一個合適的編譯器,選擇一個舒適的顏色對於敲代碼來說,是一件非常賞心悅目的事情。或者是想要使用一些高亮的顏色來進行排版,是自己的文章或博客,不太單調,最後搭配上背景圖片、皮膚等,是看着非常舒適的。
下面給大家提供各種語言的代碼高亮顯示,其中代碼均爲測試代碼
普通代碼塊
Test code block
測試代碼塊
Bash 代碼塊
switch=true
if [[ "$switch" == true ]]
then
echo "測試代碼塊"
else
echo "測試代碼塊"
fi
C 代碼塊
#include <stdio.h>
int main () {
printf("測試代碼塊\n");
return 0;
}
C++ 代碼塊
#include <iostream>
using namespace std;
int main()
{
cout << "測試代碼塊" << endl;
return 0;
}
C# 代碼塊
#include <iostream>
using namespace std;
int main() {
cout << "測試代碼塊" << endl;
return 0;
}
CLIKE 代碼塊
#!/bin/bash
echo "測試代碼塊"
# 上一個 echo 是測試用的
CSS 代碼塊
<!DOCTYPE html>
<html>
<title>測試代碼塊</title>
<head>
<style>
div
{
width:100px;
height:75px;
background-color:red;
border:1px solid black;
}
</style>
</head>
<body>
<div>測試代碼塊</div>
</body>
</html>
Go 代碼塊
package main
import "fmt"
func main () {
fmt.Println("測試代碼塊")
}
Handlebars 代碼塊
#!/bin/bash
echo "測試代碼塊"
# 上一個 echo 是測試用的
Java 代碼塊
class Untitled {
public static void main(String[] args) {
System.out.println("測試代碼塊");
}
}
JavaScript 代碼塊
<!DOCTYPE html>
<html>
<title>Web Page Design</title>
<head>
<script>
function sayHello() {
document.write("測試代碼塊");
}
sayHello();
</script>
</head>
<body>
</body>
</html>
Kotlin 代碼塊
fun main(args: Array<String>) {
println("測試代碼塊")
}
Markup 代碼塊
A First Level Header
====================
Now is the time for all good men to come to
the aid of their country. This is just a
regular paragraph.
Objective 代碼塊
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSLog (@"測試代碼塊");
[pool drain];
return 0;
}
Perl 代碼塊
#
# Hello World Program in Perl
#
print "測試代碼塊";
PHP 代碼塊
<?php
phpinfo();
?>
Shell 代碼塊
#!/bin/bash
echo "測試代碼塊"
# 上一個 echo 是測試用的
Python 代碼塊
# encoding: utf-8
if __name__ == "__main__":
print("測試代碼塊")
Ruby 代碼塊
# Hello World Program in Ruby
puts "測試代碼塊";
Sql 代碼塊
BEGIN TRANSACTION;
/* Create a table called NAMES */
CREATE TABLE NAMES(Id integer PRIMARY KEY, Name text);
/* Create few records in this table */
INSERT INTO NAMES VALUES(1,'測試代碼塊');
INSERT INTO NAMES VALUES(2,'測試代碼塊');
INSERT INTO NAMES VALUES(3,'測試代碼塊');
INSERT INTO NAMES VALUES(4,'測試代碼塊');
INSERT INTO NAMES VALUES(5,'測試代碼塊');
COMMIT;
/* Display all the records from the table */
SELECT * FROM NAMES;
Swift 代碼塊
import Foundation
import Glibc
let player = ["rock", "paper", "scissors", "lizard", "spock"]
srandom(UInt32(NSDate().timeIntervalSince1970))
for count in 1...3 {
print(count)
}
print(player[random() % player.count]);
VB.net 代碼塊
Module VBModule
Sub Main()
Console.WriteLine("測試代碼塊")
End Sub
End Module